diff options
author | jld3103 <jld3103yt@gmail.com> | 2023-03-31 09:28:22 +0200 |
---|---|---|
committer | jld3103 <jld3103yt@gmail.com> | 2023-04-07 09:49:42 +0200 |
commit | b153340b6292c0790666e0542677bcf47f2e9b59 (patch) | |
tree | b13fb2b10cc38833a2a05ec44a410188a571c6a6 /lib | |
parent | 012624743917cf9388f2abd33760a50d83d497e9 (diff) | |
download | nextcloud-server-b153340b6292c0790666e0542677bcf47f2e9b59.tar.gz nextcloud-server-b153340b6292c0790666e0542677bcf47f2e9b59.zip |
Add type hints for mappers
Signed-off-by: jld3103 <jld3103yt@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/composer/composer/autoload_classmap.php | 2 | ||||
-rw-r--r-- | lib/composer/composer/autoload_static.php | 2 | ||||
-rw-r--r-- | lib/private/KnownUser/KnownUserMapper.php | 2 | ||||
-rw-r--r-- | lib/private/Metadata/FileMetadataMapper.php | 7 | ||||
-rw-r--r-- | lib/private/Settings/AuthorizedGroupMapper.php | 3 | ||||
-rw-r--r-- | lib/private/Tagging/TagMapper.php | 2 | ||||
-rw-r--r-- | lib/private/Updater/Changes.php (renamed from lib/private/Updater/ChangesResult.php) | 4 | ||||
-rw-r--r-- | lib/private/Updater/ChangesCheck.php | 6 | ||||
-rw-r--r-- | lib/private/Updater/ChangesMapper.php | 7 | ||||
-rw-r--r-- | lib/public/AppFramework/Db/QBMapper.php | 3 |
10 files changed, 25 insertions, 13 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 2b320c82424..a269b440df6 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -1614,9 +1614,9 @@ return array( 'OC\\Translation\\TranslationManager' => $baseDir . '/lib/private/Translation/TranslationManager.php', 'OC\\URLGenerator' => $baseDir . '/lib/private/URLGenerator.php', 'OC\\Updater' => $baseDir . '/lib/private/Updater.php', + 'OC\\Updater\\Changes' => $baseDir . '/lib/private/Updater/Changes.php', 'OC\\Updater\\ChangesCheck' => $baseDir . '/lib/private/Updater/ChangesCheck.php', 'OC\\Updater\\ChangesMapper' => $baseDir . '/lib/private/Updater/ChangesMapper.php', - 'OC\\Updater\\ChangesResult' => $baseDir . '/lib/private/Updater/ChangesResult.php', 'OC\\Updater\\VersionCheck' => $baseDir . '/lib/private/Updater/VersionCheck.php', 'OC\\UserStatus\\ISettableProvider' => $baseDir . '/lib/private/UserStatus/ISettableProvider.php', 'OC\\UserStatus\\Manager' => $baseDir . '/lib/private/UserStatus/Manager.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index a920e67a772..bfc0f2c88ac 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -1647,9 +1647,9 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OC\\Translation\\TranslationManager' => __DIR__ . '/../../..' . '/lib/private/Translation/TranslationManager.php', 'OC\\URLGenerator' => __DIR__ . '/../../..' . '/lib/private/URLGenerator.php', 'OC\\Updater' => __DIR__ . '/../../..' . '/lib/private/Updater.php', + 'OC\\Updater\\Changes' => __DIR__ . '/../../..' . '/lib/private/Updater/Changes.php', 'OC\\Updater\\ChangesCheck' => __DIR__ . '/../../..' . '/lib/private/Updater/ChangesCheck.php', 'OC\\Updater\\ChangesMapper' => __DIR__ . '/../../..' . '/lib/private/Updater/ChangesMapper.php', - 'OC\\Updater\\ChangesResult' => __DIR__ . '/../../..' . '/lib/private/Updater/ChangesResult.php', 'OC\\Updater\\VersionCheck' => __DIR__ . '/../../..' . '/lib/private/Updater/VersionCheck.php', 'OC\\UserStatus\\ISettableProvider' => __DIR__ . '/../../..' . '/lib/private/UserStatus/ISettableProvider.php', 'OC\\UserStatus\\Manager' => __DIR__ . '/../../..' . '/lib/private/UserStatus/Manager.php', diff --git a/lib/private/KnownUser/KnownUserMapper.php b/lib/private/KnownUser/KnownUserMapper.php index ce7dc9ead63..fd8f22cd0aa 100644 --- a/lib/private/KnownUser/KnownUserMapper.php +++ b/lib/private/KnownUser/KnownUserMapper.php @@ -30,6 +30,8 @@ use OCP\IDBConnection; /** * @method KnownUser mapRowToEntity(array $row) + * + * @template-extends QBMapper<KnownUser> */ class KnownUserMapper extends QBMapper { /** diff --git a/lib/private/Metadata/FileMetadataMapper.php b/lib/private/Metadata/FileMetadataMapper.php index f3120e5e515..594ac5eafba 100644 --- a/lib/private/Metadata/FileMetadataMapper.php +++ b/lib/private/Metadata/FileMetadataMapper.php @@ -30,6 +30,9 @@ use OCP\DB\Exception; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; +/** + * @template-extends QBMapper<FileMetadata> + */ class FileMetadataMapper extends QBMapper { public function __construct(IDBConnection $db) { parent::__construct($db, 'file_metadata', FileMetadata::class); @@ -109,11 +112,11 @@ class FileMetadataMapper extends QBMapper { * Updates an entry in the db from an entity * * @param Entity $entity the entity that should be created - * @return Entity the saved entity with the set id + * @return FileMetadata the saved entity with the set id * @throws Exception * @throws \InvalidArgumentException if entity has no id */ - public function update(Entity $entity): Entity { + public function update(Entity $entity): FileMetadata { if (!($entity instanceof FileMetadata)) { throw new \Exception("Entity should be a FileMetadata entity"); } diff --git a/lib/private/Settings/AuthorizedGroupMapper.php b/lib/private/Settings/AuthorizedGroupMapper.php index 4313ce60580..c7c39cc6758 100644 --- a/lib/private/Settings/AuthorizedGroupMapper.php +++ b/lib/private/Settings/AuthorizedGroupMapper.php @@ -32,6 +32,9 @@ use OCP\IGroup; use OCP\IGroupManager; use OCP\IUser; +/** + * @template-extends QBMapper<AuthorizedGroup> + */ class AuthorizedGroupMapper extends QBMapper { public function __construct(IDBConnection $db) { parent::__construct($db, 'authorized_groups', AuthorizedGroup::class); diff --git a/lib/private/Tagging/TagMapper.php b/lib/private/Tagging/TagMapper.php index 808fce2eeae..1ee9c33acf7 100644 --- a/lib/private/Tagging/TagMapper.php +++ b/lib/private/Tagging/TagMapper.php @@ -32,6 +32,8 @@ use OCP\DB\QueryBuilder\IQueryBuilder; /** * Mapper for Tag entity + * + * @template-extends QBMapper<Tag> */ class TagMapper extends QBMapper { /** diff --git a/lib/private/Updater/ChangesResult.php b/lib/private/Updater/Changes.php index db2f730aa6a..81a57c0c871 100644 --- a/lib/private/Updater/ChangesResult.php +++ b/lib/private/Updater/Changes.php @@ -28,7 +28,7 @@ namespace OC\Updater; use OCP\AppFramework\Db\Entity; /** - * Class ChangesResult + * Class Changes * * @package OC\Updater * @method string getVersion()=1 @@ -40,7 +40,7 @@ use OCP\AppFramework\Db\Entity; * @method string getData() * @method void setData(string $data) */ -class ChangesResult extends Entity { +class Changes extends Entity { /** @var string */ protected $version = ''; diff --git a/lib/private/Updater/ChangesCheck.php b/lib/private/Updater/ChangesCheck.php index e2b66853788..2c1eb321ee0 100644 --- a/lib/private/Updater/ChangesCheck.php +++ b/lib/private/Updater/ChangesCheck.php @@ -73,7 +73,7 @@ class ChangesCheck { return json_decode($changesInfo->getData(), true); } } catch (DoesNotExistException $e) { - $changesInfo = new ChangesResult(); + $changesInfo = new Changes(); } $response = $this->queryChangesServer($uri, $changesInfo); @@ -109,7 +109,7 @@ class ChangesCheck { return self::RESPONSE_NO_CONTENT; } - protected function cacheResult(ChangesResult $entry, string $version) { + protected function cacheResult(Changes $entry, string $version) { if ($entry->getVersion() === $version) { $this->mapper->update($entry); } else { @@ -121,7 +121,7 @@ class ChangesCheck { /** * @throws \Exception */ - protected function queryChangesServer(string $uri, ChangesResult $entry): IResponse { + protected function queryChangesServer(string $uri, Changes $entry): IResponse { $headers = []; if ($entry->getEtag() !== '') { $headers['If-None-Match'] = [$entry->getEtag()]; diff --git a/lib/private/Updater/ChangesMapper.php b/lib/private/Updater/ChangesMapper.php index 03e1ae3c2c1..33d50f5844f 100644 --- a/lib/private/Updater/ChangesMapper.php +++ b/lib/private/Updater/ChangesMapper.php @@ -31,6 +31,9 @@ use OCP\AppFramework\Db\QBMapper; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; +/** + * @template-extends QBMapper<Changes> + */ class ChangesMapper extends QBMapper { public const TABLE_NAME = 'whats_new'; @@ -41,7 +44,7 @@ class ChangesMapper extends QBMapper { /** * @throws DoesNotExistException */ - public function getChanges(string $version): ChangesResult { + public function getChanges(string $version): Changes { /* @var $qb IQueryBuilder */ $qb = $this->db->getQueryBuilder(); $result = $qb->select('*') @@ -54,6 +57,6 @@ class ChangesMapper extends QBMapper { if ($data === false) { throw new DoesNotExistException('Changes info is not present'); } - return ChangesResult::fromRow($data); + return Changes::fromRow($data); } } diff --git a/lib/public/AppFramework/Db/QBMapper.php b/lib/public/AppFramework/Db/QBMapper.php index 57f4cba2ff5..cbe3d39d4d7 100644 --- a/lib/public/AppFramework/Db/QBMapper.php +++ b/lib/public/AppFramework/Db/QBMapper.php @@ -55,8 +55,7 @@ abstract class QBMapper { /** * @param IDBConnection $db Instance of the Db abstraction layer * @param string $tableName the name of the table. set this to allow entity - * @param string|null $entityClass the name of the entity that the sql should be - * @psalm-param class-string<T>|null $entityClass the name of the entity that the sql should be + * @param class-string<T>|null $entityClass the name of the entity that the sql should be * mapped to queries without using sql * @since 14.0.0 */ |