From aab07d6617724c1f81cce6870989f667579b4bd4 Mon Sep 17 00:00:00 2001 From: Konrad Oboza Date: Thu, 10 Aug 2023 11:56:42 +0200 Subject: [PATCH] IBX-6254: Refactored `MemoryCachingHandler` to use `CacheIdentifierGeneratorInterface` with shortened persistence cache tags (#252) For more details see https://issues.ibexa.co/browse/IBX-6254 and https://github.com/ibexa/core/pull/252 Key changes: * Refactored `MemoryCachingHandler` to use `CacheIdentifierGeneratorInterface` with shortened persistence cache tags * Adjusted new `loadContentTypesByFieldDefinitionIdentifier` method to properly generate its cache key identifier --- .../Content/Type/MemoryCachingHandler.php | 304 +++++++++--------- .../storage_engines/legacy/content_type.yml | 1 + tests/lib/Persistence/Legacy/HandlerTest.php | 48 ++- 3 files changed, 179 insertions(+), 174 deletions(-) diff --git a/src/lib/Persistence/Legacy/Content/Type/MemoryCachingHandler.php b/src/lib/Persistence/Legacy/Content/Type/MemoryCachingHandler.php index 9294d4769d..ec9c7e990d 100644 --- a/src/lib/Persistence/Legacy/Content/Type/MemoryCachingHandler.php +++ b/src/lib/Persistence/Legacy/Content/Type/MemoryCachingHandler.php @@ -14,76 +14,76 @@ use Ibexa\Contracts\Core\Persistence\Content\Type\Group\UpdateStruct as GroupUpdateStruct; use Ibexa\Contracts\Core\Persistence\Content\Type\Handler as BaseContentTypeHandler; use Ibexa\Contracts\Core\Persistence\Content\Type\UpdateStruct; +use Ibexa\Core\Persistence\Cache\Identifier\CacheIdentifierGeneratorInterface; use Ibexa\Core\Persistence\Cache\InMemory\InMemoryCache; class MemoryCachingHandler implements BaseContentTypeHandler { - /** - * Inner handler to dispatch calls to. - * - * @var \Ibexa\Contracts\Core\Persistence\Content\Type\Handler - */ - protected $innerHandler; - - /** - * Type cache. - * - * @var \Ibexa\Core\Persistence\Cache\InMemory\InMemoryCache - */ - protected $cache; - - /** - * Creates a new content type handler. - * - * @param \Ibexa\Contracts\Core\Persistence\Content\Type\Handler $handler - * @param \Ibexa\Core\Persistence\Cache\InMemory\InMemoryCache $cache - */ - public function __construct(BaseContentTypeHandler $handler, InMemoryCache $cache) - { + private const CONTENT_TYPE_GROUP_LIST = 'content_type_group_list'; + private const CONTENT_TYPE_GROUP = 'content_type_group'; + private const BY_IDENTIFIER_SUFFIX = 'by_identifier_suffix'; + private const CONTENT_TYPE_GROUP_LIST_BY_GROUP = 'content_type_list_by_group'; + private const CONTENT_TYPE = 'content_type'; + private const BY_REMOTE_SUFFIX = 'by_remote_suffix'; + private const CONTENT_TYPE_LIST_BY_GROUP = 'content_type_list_by_group'; + private const CONTENT_TYPE_FIELD_MAP = 'content_type_field_map'; + private const CONTENT_TYPE_LIST_BY_FIELD_DEFINITION_IDENTIFIER = 'content_type_list_by_field_definition_identifier'; + + /** Inner handler to dispatch calls to. */ + protected BaseContentTypeHandler $innerHandler; + + protected InMemoryCache $cache; + + private CacheIdentifierGeneratorInterface $generator; + + public function __construct( + BaseContentTypeHandler $handler, + InMemoryCache $cache, + CacheIdentifierGeneratorInterface $generator + ) { $this->innerHandler = $handler; $this->cache = $cache; + $this->generator = $generator; } - /** - * {@inheritdoc} - */ - public function createGroup(GroupCreateStruct $createStruct) + public function createGroup(GroupCreateStruct $createStruct): Group { $group = $this->innerHandler->createGroup($createStruct); $this->storeGroupCache([$group]); - $this->cache->deleteMulti(['ez-content-type-group-list']); + $this->cache->deleteMulti([ + $this->generator->generateKey(self::CONTENT_TYPE_GROUP_LIST, [], true), + ]); return $group; } - /** - * {@inheritdoc} - */ - public function updateGroup(GroupUpdateStruct $struct) + public function updateGroup(GroupUpdateStruct $struct): Group { $group = $this->innerHandler->updateGroup($struct); $this->storeGroupCache([$group]); - $this->cache->deleteMulti(['ez-content-type-group-list']); + $this->cache->deleteMulti([ + $this->generator->generateKey(self::CONTENT_TYPE_GROUP_LIST, [], true), + ]); return $group; } - /** - * {@inheritdoc} - */ - public function deleteGroup($groupId) + public function deleteGroup($groupId): void { $this->innerHandler->deleteGroup($groupId); // Delete by primary key will remove the object, so we don't need to clear `-by-identifier` variant here. - $this->cache->deleteMulti(['ez-content-type-group-' . $groupId, 'ez-content-type-group-list']); + $this->cache->deleteMulti([ + $this->generator->generateKey(self::CONTENT_TYPE_GROUP, [$groupId], true), + $this->generator->generateKey(self::CONTENT_TYPE_GROUP_LIST, [], true), + ]); } - /** - * {@inheritdoc} - */ - public function loadGroup($groupId) + public function loadGroup($groupId): Group { - $group = $this->cache->get('ez-content-type-group-' . $groupId); + $group = $this->cache->get( + $this->generator->generateKey(self::CONTENT_TYPE_GROUP, [$groupId], true) + ); + if ($group === null) { $group = $this->innerHandler->loadGroup($groupId); $this->storeGroupCache([$group]); @@ -93,13 +93,17 @@ public function loadGroup($groupId) } /** - * {@inheritdoc} + * @return \Ibexa\Contracts\Core\Persistence\Content\Type\Group[] */ - public function loadGroups(array $groupIds) + public function loadGroups(array $groupIds): array { $groups = $missingIds = []; foreach ($groupIds as $groupId) { - if ($group = $this->cache->get('ez-content-type-group-' . $groupId)) { + $group = $this->cache->get( + $this->generator->generateKey(self::CONTENT_TYPE_GROUP, [$groupId], true) + ); + + if ($group !== null) { $groups[$groupId] = $group; } else { $missingIds[] = $groupId; @@ -116,12 +120,13 @@ public function loadGroups(array $groupIds) return $groups; } - /** - * {@inheritdoc} - */ - public function loadGroupByIdentifier($identifier) + public function loadGroupByIdentifier($identifier): Group { - $group = $this->cache->get('ez-content-type-group-' . $identifier . '-by-identifier'); + $group = $this->cache->get( + $this->generator->generateKey(self::CONTENT_TYPE_GROUP, [$identifier], true) . + $this->generator->generateKey(self::BY_IDENTIFIER_SUFFIX) + ); + if ($group === null) { $group = $this->innerHandler->loadGroupByIdentifier($identifier); $this->storeGroupCache([$group]); @@ -131,46 +136,57 @@ public function loadGroupByIdentifier($identifier) } /** - * {@inheritdoc} + * @return \Ibexa\Contracts\Core\Persistence\Content\Type\Group[] */ - public function loadAllGroups() + public function loadAllGroups(): array { - $groups = $this->cache->get('ez-content-type-group-list'); + $contentTypeGroupListKey = $this->generator->generateKey(self::CONTENT_TYPE_GROUP_LIST, [], true); + $groups = $this->cache->get($contentTypeGroupListKey); + if ($groups === null) { $groups = $this->innerHandler->loadAllGroups(); - $this->storeGroupCache($groups, 'ez-content-type-group-list'); + $this->storeGroupCache($groups, $contentTypeGroupListKey); } return $groups; } /** - * {@inheritdoc} + * @return \Ibexa\Contracts\Core\Persistence\Content\Type[] */ - public function loadContentTypes($groupId, $status = Type::STATUS_DEFINED) + public function loadContentTypes($groupId, $status = Type::STATUS_DEFINED): array { if ($status !== Type::STATUS_DEFINED) { return $this->innerHandler->loadContentTypes($groupId, $status); } - $types = $this->cache->get('ez-content-type-list-by-group-' . $groupId); + $contentTypeGroupListByGroup = $this->generator->generateKey(self::CONTENT_TYPE_GROUP_LIST_BY_GROUP, [$groupId], true); + $types = $this->cache->get($contentTypeGroupListByGroup); + if ($types === null) { $types = $this->innerHandler->loadContentTypes($groupId, $status); - $this->storeTypeCache($types, 'ez-content-type-list-by-group-' . $groupId); + $this->storeTypeCache($types, $contentTypeGroupListByGroup); } return $types; } /** - * {@inheritdoc} + * @return \Ibexa\Contracts\Core\Persistence\Content\Type[] */ public function loadContentTypeList(array $contentTypeIds): array { $contentTypes = $missingIds = []; foreach ($contentTypeIds as $contentTypeId) { - if ($contentType = $this->cache->get('ez-content-type-' . $contentTypeId . '-' . Type::STATUS_DEFINED)) { - $contentTypes[$contentTypeId] = $contentType; + $cacheKey = $this->generator->generateKey( + self::CONTENT_TYPE, + [$contentTypeId], + true + ) . '-' . Type::STATUS_DEFINED; + + $cacheItem = $this->cache->get($cacheKey); + if ($cacheItem !== null) { + $contentTypes[$contentTypeId] = $cacheItem; } else { $missingIds[] = $contentTypeId; } @@ -191,7 +207,11 @@ public function loadContentTypeList(array $contentTypeIds): array */ public function loadContentTypesByFieldDefinitionIdentifier(string $identifier): array { - $cacheKey = 'ibx-ctlbfdi-' . $identifier; + $cacheKey = $this->generator->generateKey( + self::CONTENT_TYPE_LIST_BY_FIELD_DEFINITION_IDENTIFIER, + [$identifier], + true + ); $types = $this->cache->get($cacheKey); if ($types === null) { @@ -207,7 +227,10 @@ public function loadContentTypesByFieldDefinitionIdentifier(string $identifier): */ public function load($contentTypeId, $status = Type::STATUS_DEFINED) { - $contentType = $this->cache->get('ez-content-type-' . $contentTypeId . '-' . $status); + $contentType = $this->cache->get( + $this->generator->generateKey(self::CONTENT_TYPE, [$contentTypeId], true) . '-' . $status + ); + if ($contentType === null) { $contentType = $this->innerHandler->load($contentTypeId, $status); $this->storeTypeCache([$contentType]); @@ -216,12 +239,13 @@ public function load($contentTypeId, $status = Type::STATUS_DEFINED) return $contentType; } - /** - * {@inheritdoc} - */ - public function loadByIdentifier($identifier) + public function loadByIdentifier($identifier): Type { - $contentType = $this->cache->get('ez-content-type-' . $identifier . '-by-identifier'); + $contentType = $this->cache->get( + $this->generator->generateKey(self::CONTENT_TYPE, [$identifier], true) . + $this->generator->generateKey(self::BY_IDENTIFIER_SUFFIX) + ); + if ($contentType === null) { $contentType = $this->innerHandler->loadByIdentifier($identifier); $this->storeTypeCache([$contentType]); @@ -230,12 +254,13 @@ public function loadByIdentifier($identifier) return $contentType; } - /** - * {@inheritdoc} - */ - public function loadByRemoteId($remoteId) + public function loadByRemoteId($remoteId): Type { - $contentType = $this->cache->get('ez-content-type-' . $remoteId . '-by-remote'); + $contentType = $this->cache->get( + $this->generator->generateKey(self::CONTENT_TYPE, [$remoteId], true) . + $this->generator->generateKey(self::BY_REMOTE_SUFFIX) + ); + if ($contentType === null) { $contentType = $this->innerHandler->loadByRemoteId($remoteId); $this->storeTypeCache([$contentType]); @@ -244,10 +269,7 @@ public function loadByRemoteId($remoteId) return $contentType; } - /** - * {@inheritdoc} - */ - public function create(CreateStruct $createStruct) + public function create(CreateStruct $createStruct): Type { $contentType = $this->innerHandler->create($createStruct); // Don't store as FieldTypeConstraints is not setup fully here from Legacy SE side @@ -256,10 +278,7 @@ public function create(CreateStruct $createStruct) return $contentType; } - /** - * {@inheritdoc} - */ - public function update($typeId, $status, UpdateStruct $contentType) + public function update($typeId, $status, UpdateStruct $contentType): Type { $contentType = $this->innerHandler->update($typeId, $status, $contentType); $this->storeTypeCache([$contentType]); @@ -267,19 +286,13 @@ public function update($typeId, $status, UpdateStruct $contentType) return $contentType; } - /** - * {@inheritdoc} - */ - public function delete($contentTypeId, $status) + public function delete($contentTypeId, $status): void { $this->innerHandler->delete($contentTypeId, $status); $this->deleteTypeCache($contentTypeId, $status); } - /** - * {@inheritdoc} - */ - public function createDraft($modifierId, $contentTypeId) + public function createDraft($modifierId, $contentTypeId): Type { $contentType = $this->innerHandler->createDraft($modifierId, $contentTypeId); // Don't store as FieldTypeConstraints is not setup fully here from Legacy SE side @@ -288,10 +301,7 @@ public function createDraft($modifierId, $contentTypeId) return $contentType; } - /** - * {@inheritdoc} - */ - public function copy($userId, $contentTypeId, $status) + public function copy($userId, $contentTypeId, $status): Type { $contentType = $this->innerHandler->copy($userId, $contentTypeId, $status); $this->storeTypeCache([$contentType]); @@ -299,53 +309,46 @@ public function copy($userId, $contentTypeId, $status) return $contentType; } - /** - * {@inheritdoc} - */ - public function unlink($groupId, $contentTypeId, $status) + public function unlink($groupId, $contentTypeId, $status): bool { - $keys = ['ez-content-type-' . $contentTypeId . '-' . $status]; + $keys = [ + $this->generator->generateKey(self::CONTENT_TYPE, [$contentTypeId], true) . '-' . $status, + ]; + if ($status === Type::STATUS_DEFINED) { - $keys[] = 'ez-content-type-list-by-group-' . $groupId; + $keys[] = $this->generator->generateKey(self::CONTENT_TYPE_LIST_BY_GROUP, [$groupId], true); } + $this->cache->deleteMulti($keys); return $this->innerHandler->unlink($groupId, $contentTypeId, $status); } - /** - * {@inheritdoc} - */ - public function link($groupId, $contentTypeId, $status) + public function link($groupId, $contentTypeId, $status): bool { - $keys = ['ez-content-type-' . $contentTypeId . '-' . $status]; + $keys = [ + $this->generator->generateKey(self::CONTENT_TYPE, [$contentTypeId], true) . '-' . $status, + ]; + if ($status === Type::STATUS_DEFINED) { - $keys[] = 'ez-content-type-list-by-group-' . $groupId; + $keys[] = $this->generator->generateKey(self::CONTENT_TYPE_LIST_BY_GROUP, [$groupId], true); } + $this->cache->deleteMulti($keys); return $this->innerHandler->link($groupId, $contentTypeId, $status); } - /** - * {@inheritdoc} - */ - public function getFieldDefinition($id, $status) + public function getFieldDefinition($id, $status): FieldDefinition { return $this->innerHandler->getFieldDefinition($id, $status); } - /** - * {@inheritdoc} - */ - public function getContentCount($contentTypeId) + public function getContentCount($contentTypeId): int { return $this->innerHandler->getContentCount($contentTypeId); } - /** - * {@inheritdoc} - */ public function addFieldDefinition($contentTypeId, $status, FieldDefinition $fieldDefinition) { $this->deleteTypeCache($contentTypeId, $status); @@ -353,9 +356,6 @@ public function addFieldDefinition($contentTypeId, $status, FieldDefinition $fie return $this->innerHandler->addFieldDefinition($contentTypeId, $status, $fieldDefinition); } - /** - * {@inheritdoc} - */ public function removeFieldDefinition( int $contentTypeId, int $status, @@ -365,47 +365,43 @@ public function removeFieldDefinition( $this->innerHandler->removeFieldDefinition($contentTypeId, $status, $fieldDefinition); } - /** - * {@inheritdoc} - */ - public function updateFieldDefinition($contentTypeId, $status, FieldDefinition $fieldDefinition) + public function updateFieldDefinition($contentTypeId, $status, FieldDefinition $fieldDefinition): void { $this->deleteTypeCache($contentTypeId, $status); - return $this->innerHandler->updateFieldDefinition($contentTypeId, $status, $fieldDefinition); + $this->innerHandler->updateFieldDefinition($contentTypeId, $status, $fieldDefinition); } - /** - * {@inheritdoc} - */ - public function publish($contentTypeId) + public function publish($contentTypeId): void { $this->clearCache(); - return $this->innerHandler->publish($contentTypeId); + $this->innerHandler->publish($contentTypeId); } /** - * {@inheritdoc} + * @return array */ - public function getSearchableFieldMap() + public function getSearchableFieldMap(): array { - $map = $this->cache->get('ez-content-type-field-map'); + $mapCacheKey = $this->generator->generateKey(self::CONTENT_TYPE_FIELD_MAP, [], true); + $map = $this->cache->get($mapCacheKey); + if ($map === null) { $map = $this->innerHandler->getSearchableFieldMap(); + $this->cache->setMulti( $map, - static function () { return []; }, - 'ez-content-type-field-map' + static function (): array { + return []; + }, + $mapCacheKey ); } return $map; } - /** - * {@inheritdoc} - */ public function removeContentTypeTranslation(int $contentTypeId, string $languageCode): Type { $this->clearCache(); @@ -416,7 +412,7 @@ public function removeContentTypeTranslation(int $contentTypeId, string $languag /** * Clear internal caches. */ - public function clearCache() + public function clearCache(): void { $this->cache->clear(); } @@ -425,7 +421,10 @@ protected function deleteTypeCache(int $contentTypeId, int $status = Type::STATU { if ($status !== Type::STATUS_DEFINED) { // Delete by primary key will remove the object, so we don't need to clear other variants here. - $this->cache->deleteMulti(['ez-content-type-' . $contentTypeId . '-' . $status, 'ez-content-type-field-map']); + $this->cache->deleteMulti([ + $this->generator->generateKey(self::CONTENT_TYPE, [$contentTypeId], true) . '-' . $status, + $this->generator->generateKey(self::CONTENT_TYPE_FIELD_MAP, [], true), + ]); } else { // We don't know group id in order to clear relevant "ez-content-type-list-by-group-$groupId". $this->cache->clear(); @@ -436,31 +435,40 @@ protected function storeTypeCache(array $types, string $listIndex = null): void { $this->cache->setMulti( $types, - static function (Type $type) { + function (Type $type): array { if ($type->status !== Type::STATUS_DEFINED) { - return ['ez-content-type-' . $type->id . '-' . $type->status]; + return [ + $this->generator->generateKey(self::CONTENT_TYPE, [$type->id], true) . '-' . $type->status, + ]; } return [ - 'ez-content-type-' . $type->id . '-' . $type->status, - 'ez-content-type-' . $type->identifier . '-by-identifier', - 'ez-content-type-' . $type->remoteId . '-by-remote', + $this->generator->generateKey(self::CONTENT_TYPE, [$type->id], true) . '-' . $type->status, + + $this->generator->generateKey(self::CONTENT_TYPE, [$type->identifier], true) . '-' . $type->status . + $this->generator->generateKey(self::BY_IDENTIFIER_SUFFIX), + + $this->generator->generateKey(self::CONTENT_TYPE, [$type->remoteId], true) . '-' . $type->status . + $this->generator->generateKey(self::BY_REMOTE_SUFFIX), ]; }, $listIndex ); - $this->cache->deleteMulti(['ez-content-type-field-map']); + $this->cache->deleteMulti([ + $this->generator->generateKey(self::CONTENT_TYPE_FIELD_MAP, [], true), + ]); } protected function storeGroupCache(array $groups, string $listIndex = null): void { $this->cache->setMulti( $groups, - static function (Group $group) { + function (Group $group): array { return [ - 'ez-content-type-group-' . $group->id, - 'ez-content-type-group-' . $group->identifier . '-by-identifier', + $this->generator->generateKey(self::CONTENT_TYPE_GROUP, [$group->id], true), + $this->generator->generateKey(self::CONTENT_TYPE_GROUP, [$group->identifier], true) . + $this->generator->generateKey(self::BY_IDENTIFIER_SUFFIX), ]; }, $listIndex diff --git a/src/lib/Resources/settings/storage_engines/legacy/content_type.yml b/src/lib/Resources/settings/storage_engines/legacy/content_type.yml index 74701d03c6..06b1059ae8 100644 --- a/src/lib/Resources/settings/storage_engines/legacy/content_type.yml +++ b/src/lib/Resources/settings/storage_engines/legacy/content_type.yml @@ -58,6 +58,7 @@ services: arguments: - '@Ibexa\Core\Persistence\Legacy\Content\Type\Handler.inner' - '@ibexa.spi.persistence.cache.inmemory' + - '@Ibexa\Core\Persistence\Cache\Identifier\CacheIdentifierGeneratorInterface' ibexa.spi.persistence.legacy.content_type.handler: alias: Ibexa\Core\Persistence\Legacy\Content\Type\MemoryCachingHandler diff --git a/tests/lib/Persistence/Legacy/HandlerTest.php b/tests/lib/Persistence/Legacy/HandlerTest.php index 104d926ea3..3000d07044 100644 --- a/tests/lib/Persistence/Legacy/HandlerTest.php +++ b/tests/lib/Persistence/Legacy/HandlerTest.php @@ -6,6 +6,7 @@ */ namespace Ibexa\Tests\Core\Persistence\Legacy; +use Ibexa\Contracts\Core\Container; use Ibexa\Contracts\Core\Persistence\Content\Handler as SPIContentHandler; use Ibexa\Contracts\Core\Persistence\Content\Language\Handler as SPILanguageHandler; use Ibexa\Contracts\Core\Persistence\Content\Location\Handler as SPILocationHandler; @@ -30,7 +31,7 @@ */ class HandlerTest extends TestCase { - public function testContentHandler() + public function testContentHandler(): void { $handler = $this->getHandlerFixture(); $contentHandler = $handler->contentHandler(); @@ -45,7 +46,7 @@ public function testContentHandler() ); } - public function testContentHandlerTwice() + public function testContentHandlerTwice(): void { $handler = $this->getHandlerFixture(); @@ -55,7 +56,7 @@ public function testContentHandlerTwice() ); } - public function testContentTypeHandler() + public function testContentTypeHandler(): void { $handler = $this->getHandlerFixture(); $contentTypeHandler = $handler->contentTypeHandler(); @@ -66,7 +67,7 @@ public function testContentTypeHandler() ); } - public function testContentLanguageHandler() + public function testContentLanguageHandler(): void { $handler = $this->getHandlerFixture(); $contentLanguageHandler = $handler->contentLanguageHandler(); @@ -77,7 +78,7 @@ public function testContentLanguageHandler() ); } - public function testContentTypeHandlerTwice() + public function testContentTypeHandlerTwice(): void { $handler = $this->getHandlerFixture(); @@ -87,7 +88,7 @@ public function testContentTypeHandlerTwice() ); } - public function testLocationHandler() + public function testLocationHandler(): void { $handler = $this->getHandlerFixture(); $locationHandler = $handler->locationHandler(); @@ -102,7 +103,7 @@ public function testLocationHandler() ); } - public function testLocationHandlerTwice() + public function testLocationHandlerTwice(): void { $handler = $this->getHandlerFixture(); @@ -112,7 +113,7 @@ public function testLocationHandlerTwice() ); } - public function testUserHandler() + public function testUserHandler(): void { $handler = $this->getHandlerFixture(); $userHandler = $handler->userHandler(); @@ -127,7 +128,7 @@ public function testUserHandler() ); } - public function testUserHandlerTwice() + public function testUserHandlerTwice(): void { $handler = $this->getHandlerFixture(); @@ -137,7 +138,7 @@ public function testUserHandlerTwice() ); } - public function testSectionHandler() + public function testSectionHandler(): void { $handler = $this->getHandlerFixture(); $sectionHandler = $handler->sectionHandler(); @@ -152,7 +153,7 @@ public function testSectionHandler() ); } - public function testSectionHandlerTwice() + public function testSectionHandlerTwice(): void { $handler = $this->getHandlerFixture(); @@ -162,7 +163,7 @@ public function testSectionHandlerTwice() ); } - public function testUrlAliasHandler() + public function testUrlAliasHandler(): void { $handler = $this->getHandlerFixture(); $urlAliasHandler = $handler->urlAliasHandler(); @@ -177,7 +178,7 @@ public function testUrlAliasHandler() ); } - public function testUrlAliasHandlerTwice() + public function testUrlAliasHandlerTwice(): void { $handler = $this->getHandlerFixture(); @@ -187,7 +188,7 @@ public function testUrlAliasHandlerTwice() ); } - public function testNotificationHandlerTwice() + public function testNotificationHandlerTwice(): void { $handler = $this->getHandlerFixture(); @@ -197,7 +198,7 @@ public function testNotificationHandlerTwice() ); } - public function testTransactionHandler() + public function testTransactionHandler(): void { $handler = $this->getHandlerFixture(); $transactionHandler = $handler->transactionHandler(); @@ -212,7 +213,7 @@ public function testTransactionHandler() ); } - public function testTransactionHandlerTwice() + public function testTransactionHandlerTwice(): void { $handler = $this->getHandlerFixture(); @@ -222,27 +223,22 @@ public function testTransactionHandlerTwice() ); } - protected static $legacyHandler; + protected static Handler $legacyHandler; - /** - * Returns the Handler. - * - * @return \Ibexa\Contracts\Core\Persistence\Handler - */ - protected function getHandlerFixture() + protected function getHandlerFixture(): Handler { if (!isset(self::$legacyHandler)) { $container = $this->getContainer(); - self::$legacyHandler = $container->get(\Ibexa\Core\Persistence\Legacy\Handler::class); + self::$legacyHandler = $container->get(Handler::class); } return self::$legacyHandler; } - protected static $container; + protected static Container $container; - protected function getContainer() + protected function getContainer(): Container { if (!isset(self::$container)) { $installDir = self::getInstallationDir();