Skip to content

Commit

Permalink
fix: Adjust Entity types
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
susnux committed Sep 20, 2024
1 parent b08f9bf commit 45e799b
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 36 deletions.
13 changes: 7 additions & 6 deletions apps/contactsinteraction/lib/Db/RecentContact.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace OCA\ContactsInteraction\Db;

use OCP\AppFramework\Db\Entity;
use OCP\DB\Types;

/**
* @method void setActorUid(string $uid)
Expand All @@ -33,11 +34,11 @@ class RecentContact extends Entity {
protected int $lastContact = -1;

public function __construct() {
$this->addType('actorUid', 'string');
$this->addType('uid', 'string');
$this->addType('email', 'string');
$this->addType('federatedCloudId', 'string');
$this->addType('card', 'blob');
$this->addType('lastContact', 'int');
$this->addType('actorUid', Types::STRING);
$this->addType('uid', Types::STRING);
$this->addType('email', Types::STRING);
$this->addType('federatedCloudId', Types::STRING);
$this->addType('card', Types::BLOB);
$this->addType('lastContact', Types::INTEGER);
}
}
7 changes: 4 additions & 3 deletions apps/dav/lib/CalDAV/Proxy/Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace OCA\DAV\CalDAV\Proxy;

use OCP\AppFramework\Db\Entity;
use OCP\DB\Types;

/**
* @method string getOwnerId()
Expand All @@ -28,8 +29,8 @@ class Proxy extends Entity {
protected $permissions;

public function __construct() {
$this->addType('ownerId', 'string');
$this->addType('proxyId', 'string');
$this->addType('permissions', 'int');
$this->addType('ownerId', Types::STRING);
$this->addType('proxyId', Types::STRING);
$this->addType('permissions', Types::INTEGER);
}
}
9 changes: 5 additions & 4 deletions apps/dav/lib/Db/Direct.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace OCA\DAV\Db;

use OCP\AppFramework\Db\Entity;
use OCP\DB\Types;

/**
* @method string getUserId()
Expand All @@ -34,9 +35,9 @@ class Direct extends Entity {
protected $expiration;

public function __construct() {
$this->addType('userId', 'string');
$this->addType('fileId', 'int');
$this->addType('token', 'string');
$this->addType('expiration', 'int');
$this->addType('userId', Types::STRING);
$this->addType('fileId', Types::INTEGER);
$this->addType('token', Types::STRING);
$this->addType('expiration', Types::INTEGER);
}
}
11 changes: 6 additions & 5 deletions apps/oauth2/lib/Db/AccessToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
namespace OCA\OAuth2\Db;

use OCP\AppFramework\Db\Entity;
use OCP\DB\Types;

/**
* @method int getTokenId()
Expand Down Expand Up @@ -36,12 +37,12 @@ class AccessToken extends Entity {
protected $tokenCount;

public function __construct() {
$this->addType('id', 'int');
$this->addType('tokenId', 'int');
$this->addType('clientId', 'int');
$this->addType('id', Types::INTEGER);
$this->addType('tokenId', Types::INTEGER);
$this->addType('clientId', Types::INTEGER);
$this->addType('hashedCode', 'string');
$this->addType('encryptedToken', 'string');
$this->addType('codeCreatedAt', 'int');
$this->addType('tokenCount', 'int');
$this->addType('codeCreatedAt', Types::INTEGER);
$this->addType('tokenCount', Types::INTEGER);
}
}
3 changes: 2 additions & 1 deletion apps/oauth2/lib/Db/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
namespace OCA\OAuth2\Db;

use OCP\AppFramework\Db\Entity;
use OCP\DB\Types;

/**
* @method string getClientIdentifier()
Expand All @@ -28,7 +29,7 @@ class Client extends Entity {
protected $secret;

public function __construct() {
$this->addType('id', 'int');
$this->addType('id', Types::INTEGER);
$this->addType('name', 'string');
$this->addType('redirectUri', 'string');
$this->addType('clientIdentifier', 'string');
Expand Down
7 changes: 4 additions & 3 deletions apps/user_status/lib/Db/UserStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace OCA\UserStatus\Db;

use OCP\AppFramework\Db\Entity;
use OCP\DB\Types;

/**
* Class UserStatus
Expand Down Expand Up @@ -73,13 +74,13 @@ class UserStatus extends Entity {
public function __construct() {
$this->addType('userId', 'string');
$this->addType('status', 'string');
$this->addType('statusTimestamp', 'int');
$this->addType('statusTimestamp', Types::INTEGER);
$this->addType('isUserDefined', 'boolean');
$this->addType('messageId', 'string');
$this->addType('customIcon', 'string');
$this->addType('customMessage', 'string');
$this->addType('clearAt', 'int');
$this->addType('clearAt', Types::INTEGER);
$this->addType('isBackup', 'boolean');
$this->addType('statusMessageTimestamp', 'int');
$this->addType('statusMessageTimestamp', Types::INTEGER);
}
}
5 changes: 3 additions & 2 deletions core/Db/LoginFlowV2.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace OC\Core\Db;

use OCP\AppFramework\Db\Entity;
use OCP\DB\Types;

/**
* @method int getTimestamp()
Expand Down Expand Up @@ -55,8 +56,8 @@ class LoginFlowV2 extends Entity {
protected $appPassword;

public function __construct() {
$this->addType('timestamp', 'int');
$this->addType('started', 'int');
$this->addType('timestamp', Types::INTEGER);
$this->addType('started', Types::INTEGER);
$this->addType('pollToken', 'string');
$this->addType('loginToken', 'string');
$this->addType('publicKey', 'string');
Expand Down
15 changes: 8 additions & 7 deletions lib/private/Authentication/Token/PublicKeyToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use OCP\AppFramework\Db\Entity;
use OCP\Authentication\Token\IToken;
use OCP\DB\Types;

/**
* @method void setId(int $id)
Expand Down Expand Up @@ -88,16 +89,16 @@ public function __construct() {
$this->addType('passwordHash', 'string');
$this->addType('name', 'string');
$this->addType('token', 'string');
$this->addType('type', 'int');
$this->addType('remember', 'int');
$this->addType('lastActivity', 'int');
$this->addType('lastCheck', 'int');
$this->addType('type', Types::INTEGER);
$this->addType('remember', Types::INTEGER);
$this->addType('lastActivity', Types::INTEGER);
$this->addType('lastCheck', Types::INTEGER);
$this->addType('scope', 'string');
$this->addType('expires', 'int');
$this->addType('expires', Types::INTEGER);
$this->addType('publicKey', 'string');
$this->addType('privateKey', 'string');
$this->addType('version', 'int');
$this->addType('passwordInvalid', 'bool');
$this->addType('version', Types::INTEGER);
$this->addType('passwordInvalid', Types::BOOLEAN);
}

public function getId(): int {
Expand Down
3 changes: 2 additions & 1 deletion lib/private/Updater/Changes.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace OC\Updater;

use OCP\AppFramework\Db\Entity;
use OCP\DB\Types;

/**
* Class Changes
Expand Down Expand Up @@ -39,7 +40,7 @@ class Changes extends Entity {
public function __construct() {
$this->addType('version', 'string');
$this->addType('etag', 'string');
$this->addType('lastCheck', 'int');
$this->addType('lastCheck', Types::INTEGER);
$this->addType('data', 'string');
}
}
7 changes: 3 additions & 4 deletions lib/public/AppFramework/Db/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
/**
* @method int getId()
* @method void setId(int $id)
* @psalm-type AllowedTypes = 'json'|'blob'|'datetime'|'string'|'int'|'integer'|'bool'|'boolean'|'float'|'double'|'array'|'object'
* @since 7.0.0
* @psalm-consistent-constructor
*/
Expand All @@ -26,7 +25,7 @@ abstract class Entity {
public $id;

private array $_updatedFields = [];
/** @var array<string, AllowedTypes> */
/** @var array<string, \OCP\DB\Types::*> */
private array $_fieldTypes = ['id' => 'integer'];

/**
Expand Down Expand Up @@ -67,7 +66,7 @@ public static function fromRow(array $row): static {


/**
* @return array<string, AllowedTypes> with attribute and type
* @return array<string, \OCP\DB\Types::*> with attribute and type
* @since 7.0.0
*/
public function getFieldTypes(): array {
Expand Down Expand Up @@ -260,7 +259,7 @@ public function getUpdatedFields(): array {
* that value once its being returned from the database
*
* @param string $fieldName the name of the attribute
* @param AllowedTypes $type the type which will be used to match a cast
* @param \OCP\DB\Types::* $type the type which will be used to match a cast
* @since 7.0.0
*/
protected function addType(string $fieldName, string $type): void {
Expand Down

0 comments on commit 45e799b

Please sign in to comment.