Skip to content

Commit 0e54c2b

Browse files
committed
fix: Adjust Entity types
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent db94e10 commit 0e54c2b

File tree

10 files changed

+44
-36
lines changed

10 files changed

+44
-36
lines changed

apps/contactsinteraction/lib/Db/RecentContact.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace OCA\ContactsInteraction\Db;
1010

1111
use OCP\AppFramework\Db\Entity;
12+
use OCP\DB\Types;
1213

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

3536
public function __construct() {
36-
$this->addType('actorUid', 'string');
37-
$this->addType('uid', 'string');
38-
$this->addType('email', 'string');
39-
$this->addType('federatedCloudId', 'string');
40-
$this->addType('card', 'blob');
41-
$this->addType('lastContact', 'int');
37+
$this->addType('actorUid', Types::STRING);
38+
$this->addType('uid', Types::STRING);
39+
$this->addType('email', Types::STRING);
40+
$this->addType('federatedCloudId', Types::STRING);
41+
$this->addType('card', Types::BLOB);
42+
$this->addType('lastContact', Types::INTEGER);
4243
}
4344
}

apps/dav/lib/CalDAV/Proxy/Proxy.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace OCA\DAV\CalDAV\Proxy;
1010

1111
use OCP\AppFramework\Db\Entity;
12+
use OCP\DB\Types;
1213

1314
/**
1415
* @method string getOwnerId()
@@ -28,8 +29,8 @@ class Proxy extends Entity {
2829
protected $permissions;
2930

3031
public function __construct() {
31-
$this->addType('ownerId', 'string');
32-
$this->addType('proxyId', 'string');
33-
$this->addType('permissions', 'int');
32+
$this->addType('ownerId', Types::STRING);
33+
$this->addType('proxyId', Types::STRING);
34+
$this->addType('permissions', Types::INTEGER);
3435
}
3536
}

apps/dav/lib/Db/Direct.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace OCA\DAV\Db;
1010

1111
use OCP\AppFramework\Db\Entity;
12+
use OCP\DB\Types;
1213

1314
/**
1415
* @method string getUserId()
@@ -34,9 +35,9 @@ class Direct extends Entity {
3435
protected $expiration;
3536

3637
public function __construct() {
37-
$this->addType('userId', 'string');
38-
$this->addType('fileId', 'int');
39-
$this->addType('token', 'string');
40-
$this->addType('expiration', 'int');
38+
$this->addType('userId', Types::STRING);
39+
$this->addType('fileId', Types::INTEGER);
40+
$this->addType('token', Types::STRING);
41+
$this->addType('expiration', Types::INTEGER);
4142
}
4243
}

apps/oauth2/lib/Db/AccessToken.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace OCA\OAuth2\Db;
77

88
use OCP\AppFramework\Db\Entity;
9+
use OCP\DB\Types;
910

1011
/**
1112
* @method int getTokenId()
@@ -36,12 +37,12 @@ class AccessToken extends Entity {
3637
protected $tokenCount;
3738

3839
public function __construct() {
39-
$this->addType('id', 'int');
40-
$this->addType('tokenId', 'int');
41-
$this->addType('clientId', 'int');
40+
$this->addType('id', Types::INTEGER);
41+
$this->addType('tokenId', Types::INTEGER);
42+
$this->addType('clientId', Types::INTEGER);
4243
$this->addType('hashedCode', 'string');
4344
$this->addType('encryptedToken', 'string');
44-
$this->addType('codeCreatedAt', 'int');
45-
$this->addType('tokenCount', 'int');
45+
$this->addType('codeCreatedAt', Types::INTEGER);
46+
$this->addType('tokenCount', Types::INTEGER);
4647
}
4748
}

apps/oauth2/lib/Db/Client.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace OCA\OAuth2\Db;
77

88
use OCP\AppFramework\Db\Entity;
9+
use OCP\DB\Types;
910

1011
/**
1112
* @method string getClientIdentifier()
@@ -28,7 +29,7 @@ class Client extends Entity {
2829
protected $secret;
2930

3031
public function __construct() {
31-
$this->addType('id', 'int');
32+
$this->addType('id', Types::INTEGER);
3233
$this->addType('name', 'string');
3334
$this->addType('redirectUri', 'string');
3435
$this->addType('clientIdentifier', 'string');

apps/user_status/lib/Db/UserStatus.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace OCA\UserStatus\Db;
1010

1111
use OCP\AppFramework\Db\Entity;
12+
use OCP\DB\Types;
1213

1314
/**
1415
* Class UserStatus
@@ -73,13 +74,13 @@ class UserStatus extends Entity {
7374
public function __construct() {
7475
$this->addType('userId', 'string');
7576
$this->addType('status', 'string');
76-
$this->addType('statusTimestamp', 'int');
77+
$this->addType('statusTimestamp', Types::INTEGER);
7778
$this->addType('isUserDefined', 'boolean');
7879
$this->addType('messageId', 'string');
7980
$this->addType('customIcon', 'string');
8081
$this->addType('customMessage', 'string');
81-
$this->addType('clearAt', 'int');
82+
$this->addType('clearAt', Types::INTEGER);
8283
$this->addType('isBackup', 'boolean');
83-
$this->addType('statusMessageTimestamp', 'int');
84+
$this->addType('statusMessageTimestamp', Types::INTEGER);
8485
}
8586
}

core/Db/LoginFlowV2.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace OC\Core\Db;
1010

1111
use OCP\AppFramework\Db\Entity;
12+
use OCP\DB\Types;
1213

1314
/**
1415
* @method int getTimestamp()
@@ -55,8 +56,8 @@ class LoginFlowV2 extends Entity {
5556
protected $appPassword;
5657

5758
public function __construct() {
58-
$this->addType('timestamp', 'int');
59-
$this->addType('started', 'int');
59+
$this->addType('timestamp', Types::INTEGER);
60+
$this->addType('started', Types::INTEGER);
6061
$this->addType('pollToken', 'string');
6162
$this->addType('loginToken', 'string');
6263
$this->addType('publicKey', 'string');

lib/private/Authentication/Token/PublicKeyToken.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use OCP\AppFramework\Db\Entity;
1212
use OCP\Authentication\Token\IToken;
13+
use OCP\DB\Types;
1314

1415
/**
1516
* @method void setId(int $id)
@@ -88,16 +89,16 @@ public function __construct() {
8889
$this->addType('passwordHash', 'string');
8990
$this->addType('name', 'string');
9091
$this->addType('token', 'string');
91-
$this->addType('type', 'int');
92-
$this->addType('remember', 'int');
93-
$this->addType('lastActivity', 'int');
94-
$this->addType('lastCheck', 'int');
92+
$this->addType('type', Types::INTEGER);
93+
$this->addType('remember', Types::INTEGER);
94+
$this->addType('lastActivity', Types::INTEGER);
95+
$this->addType('lastCheck', Types::INTEGER);
9596
$this->addType('scope', 'string');
96-
$this->addType('expires', 'int');
97+
$this->addType('expires', Types::INTEGER);
9798
$this->addType('publicKey', 'string');
9899
$this->addType('privateKey', 'string');
99-
$this->addType('version', 'int');
100-
$this->addType('passwordInvalid', 'bool');
100+
$this->addType('version', Types::INTEGER);
101+
$this->addType('passwordInvalid', Types::BOOLEAN);
101102
}
102103

103104
public function getId(): int {

lib/private/Updater/Changes.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace OC\Updater;
1010

1111
use OCP\AppFramework\Db\Entity;
12+
use OCP\DB\Types;
1213

1314
/**
1415
* Class Changes
@@ -39,7 +40,7 @@ class Changes extends Entity {
3940
public function __construct() {
4041
$this->addType('version', 'string');
4142
$this->addType('etag', 'string');
42-
$this->addType('lastCheck', 'int');
43+
$this->addType('lastCheck', Types::INTEGER);
4344
$this->addType('data', 'string');
4445
}
4546
}

lib/public/AppFramework/Db/Entity.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
/**
1616
* @method int getId()
1717
* @method void setId(int $id)
18-
* @psalm-type AllowedTypes = 'json'|'blob'|'datetime'|'string'|'int'|'integer'|'bool'|'boolean'|'float'|'double'|'array'|'object'
1918
* @since 7.0.0
2019
* @psalm-consistent-constructor
2120
*/
@@ -26,7 +25,7 @@ abstract class Entity {
2625
public $id;
2726

2827
private array $_updatedFields = [];
29-
/** @var array<string, AllowedTypes> */
28+
/** @var array<string, \OCP\DB\Types::*> */
3029
private array $_fieldTypes = ['id' => 'integer'];
3130

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

6867

6968
/**
70-
* @return array<string, AllowedTypes> with attribute and type
69+
* @return array<string, \OCP\DB\Types::*> with attribute and type
7170
* @since 7.0.0
7271
*/
7372
public function getFieldTypes(): array {
@@ -260,7 +259,7 @@ public function getUpdatedFields(): array {
260259
* that value once its being returned from the database
261260
*
262261
* @param string $fieldName the name of the attribute
263-
* @param AllowedTypes $type the type which will be used to match a cast
262+
* @param \OCP\DB\Types::* $type the type which will be used to match a cast
264263
* @since 7.0.0
265264
*/
266265
protected function addType(string $fieldName, string $type): void {

0 commit comments

Comments
 (0)