From a9a0a384208ad97761477b5521e17fe6a8128d5b Mon Sep 17 00:00:00 2001 From: jld3103 Date: Fri, 31 Mar 2023 09:28:22 +0200 Subject: [PATCH] Add type hints for mappers Signed-off-by: jld3103 --- apps/dav/lib/CalDAV/Proxy/ProxyMapper.php | 2 ++ apps/files/lib/Db/OpenLocalEditorMapper.php | 3 +++ apps/files/lib/Db/TransferOwnershipMapper.php | 3 +++ core/Db/LoginFlowV2Mapper.php | 3 +++ core/Db/ProfileConfigMapper.php | 3 +++ lib/private/KnownUser/KnownUserMapper.php | 2 ++ lib/private/Metadata/FileMetadataMapper.php | 7 +++++-- lib/private/Settings/AuthorizedGroupMapper.php | 3 +++ lib/private/Tagging/TagMapper.php | 2 ++ lib/private/Updater/ChangesMapper.php | 3 +++ lib/public/AppFramework/Db/QBMapper.php | 3 +-- 11 files changed, 30 insertions(+), 4 deletions(-) diff --git a/apps/dav/lib/CalDAV/Proxy/ProxyMapper.php b/apps/dav/lib/CalDAV/Proxy/ProxyMapper.php index 19c72ffa0e967..e48e283484c4c 100644 --- a/apps/dav/lib/CalDAV/Proxy/ProxyMapper.php +++ b/apps/dav/lib/CalDAV/Proxy/ProxyMapper.php @@ -34,6 +34,8 @@ * Class ProxyMapper * * @package OCA\DAV\CalDAV\Proxy + * + * @template-extends QBMapper */ class ProxyMapper extends QBMapper { public const PERMISSION_READ = 1; diff --git a/apps/files/lib/Db/OpenLocalEditorMapper.php b/apps/files/lib/Db/OpenLocalEditorMapper.php index 71573264c7431..00988adc9ccaf 100644 --- a/apps/files/lib/Db/OpenLocalEditorMapper.php +++ b/apps/files/lib/Db/OpenLocalEditorMapper.php @@ -32,6 +32,9 @@ use OCP\DB\Exception; use OCP\IDBConnection; +/** + * @template-extends QBMapper + */ class OpenLocalEditorMapper extends QBMapper { public function __construct(IDBConnection $db) { parent::__construct($db, 'open_local_editor', OpenLocalEditor::class); diff --git a/apps/files/lib/Db/TransferOwnershipMapper.php b/apps/files/lib/Db/TransferOwnershipMapper.php index f55f9e733f938..e195a5182a0ef 100644 --- a/apps/files/lib/Db/TransferOwnershipMapper.php +++ b/apps/files/lib/Db/TransferOwnershipMapper.php @@ -29,6 +29,9 @@ use OCP\AppFramework\Db\QBMapper; use OCP\IDBConnection; +/** + * @template-extends QBMapper + */ class TransferOwnershipMapper extends QBMapper { public function __construct(IDBConnection $db) { parent::__construct($db, 'user_transfer_owner', TransferOwnership::class); diff --git a/core/Db/LoginFlowV2Mapper.php b/core/Db/LoginFlowV2Mapper.php index 0e44418e0107e..feb1bd7b42dc2 100644 --- a/core/Db/LoginFlowV2Mapper.php +++ b/core/Db/LoginFlowV2Mapper.php @@ -30,6 +30,9 @@ use OCP\AppFramework\Utility\ITimeFactory; use OCP\IDBConnection; +/** + * @template-extends QBMapper + */ class LoginFlowV2Mapper extends QBMapper { private const lifetime = 1200; diff --git a/core/Db/ProfileConfigMapper.php b/core/Db/ProfileConfigMapper.php index a8b1e35f747a5..8e3375239779f 100644 --- a/core/Db/ProfileConfigMapper.php +++ b/core/Db/ProfileConfigMapper.php @@ -29,6 +29,9 @@ use OCP\AppFramework\Db\QBMapper; use OCP\IDBConnection; +/** + * @template-extends QBMapper + */ class ProfileConfigMapper extends QBMapper { public function __construct(IDBConnection $db) { parent::__construct($db, 'profile_config', ProfileConfig::class); diff --git a/lib/private/KnownUser/KnownUserMapper.php b/lib/private/KnownUser/KnownUserMapper.php index ce7dc9ead631e..fd8f22cd0aa59 100644 --- a/lib/private/KnownUser/KnownUserMapper.php +++ b/lib/private/KnownUser/KnownUserMapper.php @@ -30,6 +30,8 @@ /** * @method KnownUser mapRowToEntity(array $row) + * + * @template-extends QBMapper */ class KnownUserMapper extends QBMapper { /** diff --git a/lib/private/Metadata/FileMetadataMapper.php b/lib/private/Metadata/FileMetadataMapper.php index f8f8df4bf3bea..261b1b35d9f3d 100644 --- a/lib/private/Metadata/FileMetadataMapper.php +++ b/lib/private/Metadata/FileMetadataMapper.php @@ -30,6 +30,9 @@ use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; +/** + * @template-extends QBMapper + */ class FileMetadataMapper extends QBMapper { public function __construct(IDBConnection $db) { parent::__construct($db, 'file_metadata', FileMetadata::class); @@ -109,11 +112,11 @@ public function clear(int $fileId): void { * 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 4313ce60580b3..c7c39cc67587e 100644 --- a/lib/private/Settings/AuthorizedGroupMapper.php +++ b/lib/private/Settings/AuthorizedGroupMapper.php @@ -32,6 +32,9 @@ use OCP\IGroupManager; use OCP\IUser; +/** + * @template-extends QBMapper + */ 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 808fce2eeaef0..1ee9c33acf7f7 100644 --- a/lib/private/Tagging/TagMapper.php +++ b/lib/private/Tagging/TagMapper.php @@ -32,6 +32,8 @@ /** * Mapper for Tag entity + * + * @template-extends QBMapper */ class TagMapper extends QBMapper { /** diff --git a/lib/private/Updater/ChangesMapper.php b/lib/private/Updater/ChangesMapper.php index 03e1ae3c2c19d..af6cf372fb295 100644 --- a/lib/private/Updater/ChangesMapper.php +++ b/lib/private/Updater/ChangesMapper.php @@ -31,6 +31,9 @@ use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; +/** + * @template-extends QBMapper + */ class ChangesMapper extends QBMapper { public const TABLE_NAME = 'whats_new'; diff --git a/lib/public/AppFramework/Db/QBMapper.php b/lib/public/AppFramework/Db/QBMapper.php index 57f4cba2ff51a..cbe3d39d4d741 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|null $entityClass the name of the entity that the sql should be + * @param class-string|null $entityClass the name of the entity that the sql should be * mapped to queries without using sql * @since 14.0.0 */