From 23e25555e62f9793391eecbdc2ef9e41d5dd824b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Nowak?= Date: Tue, 22 Sep 2026 08:37:38 +0200 Subject: [PATCH 1/6] IBX-12654: Added ibexa/phpstan to the PHPStan configuration --- composer.json | 1 + phpstan.neon.dist | 1 + 2 files changed, 2 insertions(+) diff --git a/composer.json b/composer.json index 7343054ea2..f4f7ffeaf5 100644 --- a/composer.json +++ b/composer.json @@ -68,6 +68,7 @@ "deptrac/deptrac": "^4.7", "friends-of-behat/mink-extension": "^2.7.5 || ^3.0", "ibexa/code-style": "~2.1.0", + "ibexa/phpstan": "~6.0.x-dev", "ibexa/rector": "~6.0.x-dev", "ibexa/test-core": "~6.0.x-dev", "jenner/simple_fork": "^1.2", diff --git a/phpstan.neon.dist b/phpstan.neon.dist index fcb3cbb2b3..434d4fc1e0 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,6 +1,7 @@ includes: - vendor/phpstan/phpstan-phpunit/extension.neon - vendor/phpstan/phpstan-symfony/extension.neon + - vendor/ibexa/phpstan/extension.neon - phpstan-baseline.neon.php - phpstan-baseline.neon - phpstan-baseline.pagerfanta.neon From d74b77d03a7f4d7a1184f8f651b44d245db708af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Nowak?= Date: Tue, 22 Sep 2026 09:12:01 +0200 Subject: [PATCH 2/6] IBX-12654: Fixed dynamic calls to static methods --- phpstan-baseline.neon | 18 --- .../TransformationProcessor/PcreCompiler.php | 17 ++- .../ConsoleCommandListenerTest.php | 2 +- .../IndexRequestListenerTest.php | 2 +- .../RequestEventListenerTest.php | 2 +- .../EventListener/RoutingListenerTest.php | 2 +- .../SessionSetDynamicNameListenerTest.php | 2 +- .../EventListener/SiteAccessListenerTest.php | 2 +- .../ViewControllerListenerTest.php | 10 +- .../Fragment/DirectFragmentRendererTest.php | 14 +-- .../Core/Imagine/AliasGeneratorTest.php | 4 +- .../GenericProviderTest.php | 4 +- .../VariationPurger/IOVariationPurgerTest.php | 22 ++-- .../ImageFileVariationPurgerTest.php | 18 +-- .../bundle/Core/URLChecker/URLCheckerTest.php | 8 +- .../Core/Repository/BaseTestCase.php | 6 +- ...RelationSearchBaseIntegrationTestTrait.php | 10 +- .../SearchBaseIntegrationTestCase.php | 4 +- ...archMultivaluedBaseIntegrationTestCase.php | 4 +- .../Core/Repository/FieldTypeServiceTest.php | 4 - .../Core/Repository/LocationServiceTest.php | 2 +- .../Field/TimeRangeAggregationTest.php | 14 +-- .../SearchService/RemoteIdIndexingTest.php | 2 +- .../SortClause/ContentTranslatedNameTest.php | 2 +- .../SearchServiceContentNameTest.php | 2 +- .../SearchServiceManyLanguagesTest.php | 4 +- .../Core/Repository/SearchServiceTest.php | 14 +-- .../Core/Repository/SerializationTest.php | 2 +- tests/lib/FieldType/RelationListTest.php | 14 +-- .../BaseNumericValidatorTestCase.php | 12 +- .../Validator/FloatValueValidatorTest.php | 8 +- .../Validator/IntegerValueValidatorTest.php | 8 +- .../DFSSiteAccessAwarePathPrefixerTest.php | 2 +- .../LegacyDFSClusterTest.php | 8 +- .../Limitation/MemberOfLimitationTypeTest.php | 30 ++--- .../lib/Limitation/RoleLimitationTypeTest.php | 32 +++--- .../Limitation/SubtreeLimitationTypeTest.php | 16 +-- .../Content/DownloadControllerTest.php | 4 +- .../Content/PreviewControllerTest.php | 6 +- ...kenCreatedRepositoryUserSubscriberTest.php | 2 +- ...sitoryUserAuthenticationSubscriberTest.php | 2 +- .../Templating/RenderLocationStrategyTest.php | 11 +- .../Cache/AbstractCacheHandlerTestCase.php | 24 ++-- .../AbstractInMemoryCacheHandlerTestCase.php | 24 ++-- .../Persistence/Cache/ContentHandlerTest.php | 14 +-- .../Cache/ContentTypeHandlerTest.php | 40 +++---- .../Persistence/Cache/TrashHandlerTest.php | 46 ++++---- .../lib/Persistence/Cache/URLHandlerTest.php | 26 ++--- .../lib/Persistence/Cache/UserHandlerTest.php | 28 ++--- .../Legacy/Content/FieldHandlerTest.php | 74 ++++++------- .../Content/Gateway/DoctrineDatabaseTest.php | 50 ++++----- .../Language/CachingLanguageHandlerTest.php | 14 +-- .../Language/Gateway/DoctrineDatabaseTest.php | 8 +- .../Location/Gateway/DoctrineDatabaseTest.php | 64 +++++------ .../Gateway/DoctrineDatabaseTrashTest.php | 12 +- .../Gateway/DoctrineDatabaseTest.php | 2 +- .../Section/Gateway/DoctrineDatabaseTest.php | 8 +- .../Content/Type/ContentTypeHandlerTest.php | 6 +- .../ContentUpdater/Action/AddFieldTest.php | 32 +++--- .../ContentUpdater/Action/RemoveFieldTest.php | 28 ++--- .../Content/Type/ContentUpdaterTest.php | 8 +- .../Type/Gateway/DoctrineDatabaseTest.php | 48 ++++---- .../Bookmark/IdSortClauseQueryBuilderTest.php | 4 +- .../User/Gateway/DoctrineDatabaseTest.php | 2 +- .../Role/Gateway/DoctrineDatabaseTest.php | 2 +- .../Legacy/User/UserHandlerTest.php | 52 ++++----- .../BuiltIn/AbstractQueryTypeTestCase.php | 2 +- .../FieldSortClauseParserTest.php | 10 +- .../MapDistanceSortClauseParserTest.php | 14 +-- .../DecoratedLocationServiceTest.php | 40 +++---- .../Repository/Service/Mock/BookmarkTest.php | 6 +- .../Repository/Service/Mock/ContentTest.php | 104 +++++++++--------- tests/lib/Repository/Service/Mock/UrlTest.php | 28 ++--- .../Service/Mock/UserPreferenceTest.php | 8 +- .../AbstractServiceTestCase.php | 4 +- 75 files changed, 577 insertions(+), 607 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index e85dc848c9..5a6616c608 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -15018,12 +15018,6 @@ parameters: count: 1 path: src/lib/Persistence/TransformationProcessor/PcreCompiler.php - - - message: '#^Parameter \#1 \$charCode of method Ibexa\\Core\\Persistence\\Utf8Converter\:\:toUTF8Character\(\) expects int, float\|int given\.$#' - identifier: argument.type - count: 2 - path: src/lib/Persistence/TransformationProcessor/PcreCompiler.php - - message: '#^Parameter \#1 \$codepoint of function chr expects int, float\|int given\.$#' identifier: argument.type @@ -25776,12 +25770,6 @@ parameters: count: 1 path: tests/integration/Core/Repository/FieldType/UserIntegrationTest.php - - - message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\FieldType'' and Ibexa\\Contracts\\Core\\Repository\\FieldType will always evaluate to true\.$#' - identifier: method.alreadyNarrowedType - count: 1 - path: tests/integration/Core/Repository/FieldTypeServiceTest.php - - message: '#^Cannot access property \$pathString on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Location\|null\.$#' identifier: property.nonObject @@ -31530,12 +31518,6 @@ parameters: count: 1 path: tests/lib/MVC/Symfony/Templating/RenderLocationStrategyTest.php - - - message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Symfony\\\\Component\\\\HttpKernel\\\\Controller\\\\ControllerReference'' and Symfony\\Component\\HttpKernel\\Controller\\ControllerReference will always evaluate to true\.$#' - identifier: method.alreadyNarrowedType - count: 1 - path: tests/lib/MVC/Symfony/Templating/RenderLocationStrategyTest.php - - message: '#^Argument of an invalid type string supplied for foreach, only iterables are supported\.$#' identifier: foreach.nonIterable diff --git a/src/lib/Persistence/TransformationProcessor/PcreCompiler.php b/src/lib/Persistence/TransformationProcessor/PcreCompiler.php index bcbcb98462..d10d865f6e 100644 --- a/src/lib/Persistence/TransformationProcessor/PcreCompiler.php +++ b/src/lib/Persistence/TransformationProcessor/PcreCompiler.php @@ -174,13 +174,13 @@ protected function compileTransposeModulo(array $rule) */ protected function getModuloCharRange($start, $end, $modulo): string { - $start = $this->converter->toUnicodeCodepoint($start); - $end = $this->converter->toUnicodeCodepoint($end); - $modulo = hexdec($modulo); + $start = Utf8Converter::toUnicodeCodepoint($start); + $end = Utf8Converter::toUnicodeCodepoint($end); + $modulo = (int)hexdec($modulo); $chars = ''; for ($start; $start <= $end; $start += $modulo) { - $chars .= $this->converter->toUTF8Character($start); + $chars .= Utf8Converter::toUTF8Character($start); } return $chars; @@ -198,11 +198,10 @@ protected function getModuloCharRange($start, $end, $modulo): string protected function getTransposeClosure($operator, $value) { $value = $this->hexdec($value) * ($operator === '-' ? -1 : 1); - $converter = $this->converter; - return static function ($matches) use ($value, $converter) { - return $converter->toUTF8Character( - $converter->toUnicodeCodepoint($matches[0]) + $value + return static function ($matches) use ($value): string { + return Utf8Converter::toUTF8Character( + Utf8Converter::toUnicodeCodepoint($matches[0]) + $value ); }; } @@ -263,7 +262,7 @@ protected function compileCharacter($char) { switch (true) { case preg_match('(^U\\+[0-9a-fA-F]{4}$)', $char): - return $this->converter->toUTF8Character(hexdec(substr($char, 2))); + return Utf8Converter::toUTF8Character((int)hexdec(substr($char, 2))); case preg_match('(^[0-9a-fA-F]{2}$)', $char): return chr(hexdec($char)); diff --git a/tests/bundle/Core/EventListener/ConsoleCommandListenerTest.php b/tests/bundle/Core/EventListener/ConsoleCommandListenerTest.php index 8da45863df..0bd8a53484 100644 --- a/tests/bundle/Core/EventListener/ConsoleCommandListenerTest.php +++ b/tests/bundle/Core/EventListener/ConsoleCommandListenerTest.php @@ -62,7 +62,7 @@ public function testGetSubscribedEvents(): void [ ConsoleEvents::COMMAND => [['onConsoleCommand', 128]], ], - $this->listener->getSubscribedEvents() + ConsoleCommandListener::getSubscribedEvents() ); } diff --git a/tests/bundle/Core/EventListener/IndexRequestListenerTest.php b/tests/bundle/Core/EventListener/IndexRequestListenerTest.php index 071fcb85e4..6dbb5d702f 100644 --- a/tests/bundle/Core/EventListener/IndexRequestListenerTest.php +++ b/tests/bundle/Core/EventListener/IndexRequestListenerTest.php @@ -62,7 +62,7 @@ public function testSubscribedEvents(): void ['onKernelRequestIndex', 40], ], ], - $this->indexRequestEventListener->getSubscribedEvents() + IndexRequestListener::getSubscribedEvents() ); } diff --git a/tests/bundle/Core/EventListener/RequestEventListenerTest.php b/tests/bundle/Core/EventListener/RequestEventListenerTest.php index 6edce24604..1147d8fe1f 100644 --- a/tests/bundle/Core/EventListener/RequestEventListenerTest.php +++ b/tests/bundle/Core/EventListener/RequestEventListenerTest.php @@ -74,7 +74,7 @@ public function testSubscribedEvents(): void ['onKernelRequestRedirect', 0], ], ], - $this->requestEventListener->getSubscribedEvents() + RequestEventListener::getSubscribedEvents() ); } diff --git a/tests/bundle/Core/EventListener/RoutingListenerTest.php b/tests/bundle/Core/EventListener/RoutingListenerTest.php index 9252ac101e..5b575fb5a3 100644 --- a/tests/bundle/Core/EventListener/RoutingListenerTest.php +++ b/tests/bundle/Core/EventListener/RoutingListenerTest.php @@ -44,7 +44,7 @@ public function testGetSubscribedEvents(): void [ MVCEvents::SITEACCESS => ['onSiteAccessMatch', 200], ], - $listener->getSubscribedEvents() + RoutingListener::getSubscribedEvents() ); } diff --git a/tests/bundle/Core/EventListener/SessionSetDynamicNameListenerTest.php b/tests/bundle/Core/EventListener/SessionSetDynamicNameListenerTest.php index c013c5a931..bb6f280fac 100644 --- a/tests/bundle/Core/EventListener/SessionSetDynamicNameListenerTest.php +++ b/tests/bundle/Core/EventListener/SessionSetDynamicNameListenerTest.php @@ -61,7 +61,7 @@ public function testGetSubscribedEvents(): void [ MVCEvents::SITEACCESS => ['onSiteAccessMatch', 250], ], - $listener->getSubscribedEvents() + SessionSetDynamicNameListener::getSubscribedEvents() ); } diff --git a/tests/bundle/Core/EventListener/SiteAccessListenerTest.php b/tests/bundle/Core/EventListener/SiteAccessListenerTest.php index 254949578c..4dab4f3194 100644 --- a/tests/bundle/Core/EventListener/SiteAccessListenerTest.php +++ b/tests/bundle/Core/EventListener/SiteAccessListenerTest.php @@ -39,7 +39,7 @@ public function testGetSubscribedEvents(): void [ MVCEvents::SITEACCESS => ['onSiteAccessMatch', 255], ], - $this->listener->getSubscribedEvents() + SiteAccessListener::getSubscribedEvents() ); } diff --git a/tests/bundle/Core/EventListener/ViewControllerListenerTest.php b/tests/bundle/Core/EventListener/ViewControllerListenerTest.php index d9d752e36e..e34b6ef4c9 100644 --- a/tests/bundle/Core/EventListener/ViewControllerListenerTest.php +++ b/tests/bundle/Core/EventListener/ViewControllerListenerTest.php @@ -174,14 +174,14 @@ public function testGetControllerEmitsProperEvents(): void $this->eventDispatcher ->expects($matcher) - ->method('dispatch')->willReturnCallback(function (...$parameters) use ($matcher) { + ->method('dispatch')->willReturnCallback(static function (...$parameters) use ($matcher) { if ($matcher->numberOfInvocations() === 1) { - $this->assertInstanceOf(FilterViewBuilderParametersEvent::class, $parameters[0]); - $this->assertSame(ViewEvents::FILTER_BUILDER_PARAMETERS, $parameters[1]); + self::assertInstanceOf(FilterViewBuilderParametersEvent::class, $parameters[0]); + self::assertSame(ViewEvents::FILTER_BUILDER_PARAMETERS, $parameters[1]); } if ($matcher->numberOfInvocations() === 2) { - $this->assertInstanceOf(PostBuildViewEvent::class, $parameters[0]); - $this->assertNull($parameters[1]); + self::assertInstanceOf(PostBuildViewEvent::class, $parameters[0]); + self::assertNull($parameters[1]); } return $parameters[0]; diff --git a/tests/bundle/Core/Fragment/DirectFragmentRendererTest.php b/tests/bundle/Core/Fragment/DirectFragmentRendererTest.php index 2094ba5311..5ea5bfd578 100644 --- a/tests/bundle/Core/Fragment/DirectFragmentRendererTest.php +++ b/tests/bundle/Core/Fragment/DirectFragmentRendererTest.php @@ -32,13 +32,13 @@ public function testSubRequestBuilding(): void $controllerResolver ->expects(self::any()) ->method('getController') - ->with(self::callback(function (Request $request): bool { - $this->assertEquals('/_fragment', $request->getPathInfo()); - $this->assertEquals('some::controller', $request->attributes->get('_controller')); - $this->assertEquals('attribute_value', $request->attributes->get('some')); - $this->assertEquals('else', $request->attributes->get('something')); - $this->assertInstanceOf(SiteAccess::class, $request->attributes->get('siteaccess')); - $this->assertEquals('test', $request->attributes->get('siteaccess')->name); + ->with(self::callback(static function (Request $request): bool { + self::assertEquals('/_fragment', $request->getPathInfo()); + self::assertEquals('some::controller', $request->attributes->get('_controller')); + self::assertEquals('attribute_value', $request->attributes->get('some')); + self::assertEquals('else', $request->attributes->get('something')); + self::assertInstanceOf(SiteAccess::class, $request->attributes->get('siteaccess')); + self::assertEquals('test', $request->attributes->get('siteaccess')->name); return true; })) diff --git a/tests/bundle/Core/Imagine/AliasGeneratorTest.php b/tests/bundle/Core/Imagine/AliasGeneratorTest.php index 9a6c793b85..9c7df06e4b 100644 --- a/tests/bundle/Core/Imagine/AliasGeneratorTest.php +++ b/tests/bundle/Core/Imagine/AliasGeneratorTest.php @@ -346,8 +346,8 @@ public function testGetVariationNotStoredHavingReferences(): void $this->filterManager ->expects($matcher) ->method('applyFilter') - ->willReturnCallback(function (...$parameters) use ($matcher, $expectedApplyFilterCalls, $binary) { - $this->assertSame($expectedApplyFilterCalls[$matcher->numberOfInvocations() - 1], $parameters); + ->willReturnCallback(static function (...$parameters) use ($matcher, $expectedApplyFilterCalls, $binary) { + self::assertSame($expectedApplyFilterCalls[$matcher->numberOfInvocations() - 1], $parameters); return $binary; }); diff --git a/tests/bundle/Core/Imagine/PlaceholderProvider/GenericProviderTest.php b/tests/bundle/Core/Imagine/PlaceholderProvider/GenericProviderTest.php index aa09e5df7a..3cacbf41d3 100644 --- a/tests/bundle/Core/Imagine/PlaceholderProvider/GenericProviderTest.php +++ b/tests/bundle/Core/Imagine/PlaceholderProvider/GenericProviderTest.php @@ -30,8 +30,8 @@ public function testGetPlaceholder(ImageValue $value, $expectedText, array $opti ->expects(self::atLeastOnce()) ->method('font') ->willReturnCallback(function ($fontpath, $fontsize, ColorInterface $foreground) use ($options, $font) { - $this->assertEquals($options['fontpath'], $fontpath); - $this->assertEquals($options['fontsize'], $fontsize); + self::assertEquals($options['fontpath'], $fontpath); + self::assertEquals($options['fontsize'], $fontsize); $this->assertColorEquals($options['foreground'], $foreground); return $font; diff --git a/tests/bundle/Core/Imagine/VariationPurger/IOVariationPurgerTest.php b/tests/bundle/Core/Imagine/VariationPurger/IOVariationPurgerTest.php index 1268d56b07..80bfa985c8 100644 --- a/tests/bundle/Core/Imagine/VariationPurger/IOVariationPurgerTest.php +++ b/tests/bundle/Core/Imagine/VariationPurger/IOVariationPurgerTest.php @@ -33,27 +33,27 @@ public function testPurgesAliasList(): void $matcher = self::exactly(2); $ioService ->expects($matcher) - ->method('deleteDirectory')->willReturnCallback(function (...$parameters) use ($matcher) { + ->method('deleteDirectory')->willReturnCallback(static function (...$parameters) use ($matcher) { if ($matcher->numberOfInvocations() === 1) { - $this->assertSame('_aliases/medium', $parameters[0]); + self::assertSame('_aliases/medium', $parameters[0]); } if ($matcher->numberOfInvocations() === 2) { - $this->assertSame('_aliases/large', $parameters[0]); + self::assertSame('_aliases/large', $parameters[0]); } }); $matcher = self::exactly(2); $cacheIdentifierGenerator ->expects($matcher) - ->method('generateTag')->willReturnCallback(function (...$parameters) use ($matcher) { + ->method('generateTag')->willReturnCallback(static function (...$parameters) use ($matcher) { if ($matcher->numberOfInvocations() === 1) { - $this->assertSame('image_variation_name', $parameters[0]); - $this->assertSame(['medium'], $parameters[1]); + self::assertSame('image_variation_name', $parameters[0]); + self::assertSame(['medium'], $parameters[1]); return 'ign-medium'; } if ($matcher->numberOfInvocations() === 2) { - $this->assertSame('image_variation_name', $parameters[0]); - $this->assertSame(['large'], $parameters[1]); + self::assertSame('image_variation_name', $parameters[0]); + self::assertSame(['large'], $parameters[1]); return 'ign-large'; } @@ -61,12 +61,12 @@ public function testPurgesAliasList(): void $matcher = self::exactly(2); $tagAwareAdapter ->expects($matcher) - ->method('invalidateTags')->willReturnCallback(function (...$parameters) use ($matcher) { + ->method('invalidateTags')->willReturnCallback(static function (...$parameters) use ($matcher) { if ($matcher->numberOfInvocations() === 1) { - $this->assertSame(['ign-medium'], $parameters[0]); + self::assertSame(['ign-medium'], $parameters[0]); } if ($matcher->numberOfInvocations() === 2) { - $this->assertSame(['ign-large'], $parameters[0]); + self::assertSame(['ign-large'], $parameters[0]); } return false; diff --git a/tests/bundle/Core/Imagine/VariationPurger/ImageFileVariationPurgerTest.php b/tests/bundle/Core/Imagine/VariationPurger/ImageFileVariationPurgerTest.php index abb9abb2b4..348ab153bc 100644 --- a/tests/bundle/Core/Imagine/VariationPurger/ImageFileVariationPurgerTest.php +++ b/tests/bundle/Core/Imagine/VariationPurger/ImageFileVariationPurgerTest.php @@ -45,22 +45,22 @@ public function testIteratesOverItems(): void $this->pathGeneratorMock ->expects($matcher) - ->method('getVariationPath')->willReturnCallback(function (...$parameters) use ($matcher) { + ->method('getVariationPath')->willReturnCallback(static function (...$parameters) use ($matcher) { if ($matcher->numberOfInvocations() === 1) { - $this->assertSame('path/to/1st/image.jpg', $parameters[0]); - $this->assertSame('large', $parameters[1]); + self::assertSame('path/to/1st/image.jpg', $parameters[0]); + self::assertSame('large', $parameters[1]); } if ($matcher->numberOfInvocations() === 2) { - $this->assertSame('path/to/1st/image.jpg', $parameters[0]); - $this->assertSame('gallery', $parameters[1]); + self::assertSame('path/to/1st/image.jpg', $parameters[0]); + self::assertSame('gallery', $parameters[1]); } if ($matcher->numberOfInvocations() === 3) { - $this->assertSame('path/to/2nd/image.png', $parameters[0]); - $this->assertSame('large', $parameters[1]); + self::assertSame('path/to/2nd/image.png', $parameters[0]); + self::assertSame('large', $parameters[1]); } if ($matcher->numberOfInvocations() === 4) { - $this->assertSame('path/to/2nd/image.png', $parameters[0]); - $this->assertSame('gallery', $parameters[1]); + self::assertSame('path/to/2nd/image.png', $parameters[0]); + self::assertSame('gallery', $parameters[1]); } return ''; diff --git a/tests/bundle/Core/URLChecker/URLCheckerTest.php b/tests/bundle/Core/URLChecker/URLCheckerTest.php index cb0aa4709f..cc5c7fe637 100644 --- a/tests/bundle/Core/URLChecker/URLCheckerTest.php +++ b/tests/bundle/Core/URLChecker/URLCheckerTest.php @@ -63,8 +63,8 @@ public function testCheck(): void $handler ->expects(self::once()) ->method('validate') - ->willReturnCallback(function (array $urls) use ($scheme, $groups) { - $this->assertEqualsCanonicalizing($groups[$scheme], $urls); + ->willReturnCallback(static function (array $urls) use ($scheme, $groups) { + self::assertEqualsCanonicalizing($groups[$scheme], $urls); }); } @@ -98,8 +98,8 @@ public function testCheckUnsupported(): void $handler ->expects(self::once()) ->method('validate') - ->willReturnCallback(function (array $urls) use ($scheme, $groups) { - $this->assertEqualsCanonicalizing($groups[$scheme], $urls); + ->willReturnCallback(static function (array $urls) use ($scheme, $groups) { + self::assertEqualsCanonicalizing($groups[$scheme], $urls); }); } diff --git a/tests/integration/Core/Repository/BaseTestCase.php b/tests/integration/Core/Repository/BaseTestCase.php index d771fef534..fd57a69e82 100644 --- a/tests/integration/Core/Repository/BaseTestCase.php +++ b/tests/integration/Core/Repository/BaseTestCase.php @@ -294,9 +294,9 @@ protected function assertStructPropertiesCorrect(ValueObject $expectedValues, Va */ private function sortItems(array &$items) { - $sorter = function ($a, $b): int { + $sorter = static function ($a, $b): int { if (!is_scalar($a) || !is_scalar($b)) { - $this->fail('Wrong usage: method ' . __METHOD__ . ' accepts only an array of scalar values'); + self::fail('Wrong usage: method ' . __METHOD__ . ' accepts only an array of scalar values'); } return strcmp($a, $b); @@ -532,7 +532,7 @@ public function createDateTime($timestamp = null) */ protected function refreshSearch(Repository $repository) { - if ($this->isLegacySearchEngineSetup()) { + if (self::isLegacySearchEngineSetup()) { return; } diff --git a/tests/integration/Core/Repository/FieldType/RelationSearchBaseIntegrationTestTrait.php b/tests/integration/Core/Repository/FieldType/RelationSearchBaseIntegrationTestTrait.php index 0e45c47c73..53f28ccdc1 100644 --- a/tests/integration/Core/Repository/FieldType/RelationSearchBaseIntegrationTestTrait.php +++ b/tests/integration/Core/Repository/FieldType/RelationSearchBaseIntegrationTestTrait.php @@ -40,7 +40,7 @@ public function testCreateContentRelationsProcessedCorrect(): void { $content = $this->createContent($this->getValidCreationFieldData()); - $this->assertEquals( + self::assertEquals( $this->normalizeRelations( $this->getCreateExpectedRelations($content) ), @@ -59,7 +59,7 @@ public function testUpdateContentRelationsProcessedCorrect(): void { $content = $this->updateContent($this->getValidUpdateFieldData()); - $this->assertEquals( + self::assertEquals( $this->normalizeRelations( $this->getUpdateExpectedRelations($content) ), @@ -118,7 +118,7 @@ public function testCopyContentCopiesFieldRelations(): void ); $copy = $contentService->loadContent($copy->id, null, 2); - $this->assertEquals( + self::assertEquals( $this->normalizeRelations( $this->getUpdateExpectedRelations($copy) ), @@ -130,7 +130,7 @@ public function testCopyContentCopiesFieldRelations(): void ); $firstVersion = $contentService->loadContent($copy->id, null, 1); - $this->assertEquals( + self::assertEquals( $this->normalizeRelations( $this->getCreateExpectedRelations($firstVersion) ), @@ -160,7 +160,7 @@ public function testSubtreeCopyContentCopiesFieldRelations(): void $copy = $contentService->loadContent($copiedLocation->getContentInfo()->id); - $this->assertEquals( + self::assertEquals( $this->normalizeRelations( $this->getCreateExpectedRelations($copy) ), diff --git a/tests/integration/Core/Repository/FieldType/SearchBaseIntegrationTestCase.php b/tests/integration/Core/Repository/FieldType/SearchBaseIntegrationTestCase.php index 93083d6c78..61d8e37e31 100644 --- a/tests/integration/Core/Repository/FieldType/SearchBaseIntegrationTestCase.php +++ b/tests/integration/Core/Repository/FieldType/SearchBaseIntegrationTestCase.php @@ -310,12 +310,12 @@ public function testCreateTestContent(): array $context = [ $repository, $this->createTestSearchContent( - $this->getValidSearchValueOne(), + static::getValidSearchValueOne(), $repository, $contentType )->id, $this->createTestSearchContent( - $this->getValidSearchValueTwo(), + static::getValidSearchValueTwo(), $repository, $contentType )->id, diff --git a/tests/integration/Core/Repository/FieldType/SearchMultivaluedBaseIntegrationTestCase.php b/tests/integration/Core/Repository/FieldType/SearchMultivaluedBaseIntegrationTestCase.php index 5e823919d6..22684298ff 100644 --- a/tests/integration/Core/Repository/FieldType/SearchMultivaluedBaseIntegrationTestCase.php +++ b/tests/integration/Core/Repository/FieldType/SearchMultivaluedBaseIntegrationTestCase.php @@ -160,12 +160,12 @@ public function testCreateMultivaluedTestContent(): array $context = [ $repository, $this->createTestSearchContent( - $this->getValidMultivaluedSearchValuesOne(), + static::getValidMultivaluedSearchValuesOne(), $repository, $contentType )->id, $this->createTestSearchContent( - $this->getValidMultivaluedSearchValuesTwo(), + static::getValidMultivaluedSearchValuesTwo(), $repository, $contentType )->id, diff --git a/tests/integration/Core/Repository/FieldTypeServiceTest.php b/tests/integration/Core/Repository/FieldTypeServiceTest.php index 64689aacaf..8182454626 100644 --- a/tests/integration/Core/Repository/FieldTypeServiceTest.php +++ b/tests/integration/Core/Repository/FieldTypeServiceTest.php @@ -60,10 +60,6 @@ public function testGetFieldType(): void $fieldType = $fieldTypeService->getFieldType('ibexa_url'); /* END: Use Case */ - $this->assertInstanceof( - FieldType::class, - $fieldType - ); self::assertEquals( 'ibexa_url', $fieldType->getFieldTypeIdentifier() diff --git a/tests/integration/Core/Repository/LocationServiceTest.php b/tests/integration/Core/Repository/LocationServiceTest.php index ca09f2907e..067acbccb8 100644 --- a/tests/integration/Core/Repository/LocationServiceTest.php +++ b/tests/integration/Core/Repository/LocationServiceTest.php @@ -1071,7 +1071,7 @@ public function testGetLocationChildCountWithLimitation(): void // $locationId is the ID of an existing location $locationService = $this->getRepository()->getLocationService(); $location = $locationService->loadLocation($this->generateId('location', 5)); - $this->assertSame( + self::assertSame( 2, $locationService->getLocationChildCount( $location, diff --git a/tests/integration/Core/Repository/SearchService/Aggregation/Field/TimeRangeAggregationTest.php b/tests/integration/Core/Repository/SearchService/Aggregation/Field/TimeRangeAggregationTest.php index c75828f29d..71dc777e87 100644 --- a/tests/integration/Core/Repository/SearchService/Aggregation/Field/TimeRangeAggregationTest.php +++ b/tests/integration/Core/Repository/SearchService/Aggregation/Field/TimeRangeAggregationTest.php @@ -66,13 +66,13 @@ protected function createFixturesForAggregation(Aggregation $aggregation): void $generator->setFieldDefinitionIdentifier('time_field'); $generator->setFieldTypeIdentifier('ibexa_time'); $generator->setValues([ - new TimeValue($this->mktime(6, 45, 0, 0, 0, 0)), - new TimeValue($this->mktime(7, 0, 0, 0, 0, 0)), - new TimeValue($this->mktime(6, 30, 0, 0, 0, 0)), - new TimeValue($this->mktime(11, 45, 0, 0, 0, 0)), - new TimeValue($this->mktime(16, 00, 0, 0, 0, 0)), - new TimeValue($this->mktime(17, 00, 0, 0, 0, 0)), - new TimeValue($this->mktime(17, 30, 0, 0, 0, 0)), + new TimeValue(self::mktime(6, 45, 0, 0, 0, 0)), + new TimeValue(self::mktime(7, 0, 0, 0, 0, 0)), + new TimeValue(self::mktime(6, 30, 0, 0, 0, 0)), + new TimeValue(self::mktime(11, 45, 0, 0, 0, 0)), + new TimeValue(self::mktime(16, 00, 0, 0, 0, 0)), + new TimeValue(self::mktime(17, 00, 0, 0, 0, 0)), + new TimeValue(self::mktime(17, 30, 0, 0, 0, 0)), ]); $generator->execute(); diff --git a/tests/integration/Core/Repository/SearchService/RemoteIdIndexingTest.php b/tests/integration/Core/Repository/SearchService/RemoteIdIndexingTest.php index 55e18c4953..bd94f801ca 100644 --- a/tests/integration/Core/Repository/SearchService/RemoteIdIndexingTest.php +++ b/tests/integration/Core/Repository/SearchService/RemoteIdIndexingTest.php @@ -29,7 +29,7 @@ protected function setUp(): void parent::setUp(); if (empty(self::$contentIdByRemoteIdIndex)) { - foreach ($this->getRemoteIDs() as $remoteId) { + foreach (self::getRemoteIDs() as $remoteId) { self::$contentIdByRemoteIdIndex[$remoteId] = $this->createTestFolder( $remoteId ); diff --git a/tests/integration/Core/Repository/SearchService/SortClause/ContentTranslatedNameTest.php b/tests/integration/Core/Repository/SearchService/SortClause/ContentTranslatedNameTest.php index 04a3fe1a25..2ade315b95 100644 --- a/tests/integration/Core/Repository/SearchService/SortClause/ContentTranslatedNameTest.php +++ b/tests/integration/Core/Repository/SearchService/SortClause/ContentTranslatedNameTest.php @@ -21,7 +21,7 @@ protected function setUp(): void { parent::setUp(); - if ($this->isLegacySearchEngineSetup()) { + if (self::isLegacySearchEngineSetup()) { self::markTestSkipped("Legacy search engine doesn't support ContentTranslatedName"); } } diff --git a/tests/integration/Core/Repository/SearchServiceContentNameTest.php b/tests/integration/Core/Repository/SearchServiceContentNameTest.php index 879671bd49..30f46697f8 100644 --- a/tests/integration/Core/Repository/SearchServiceContentNameTest.php +++ b/tests/integration/Core/Repository/SearchServiceContentNameTest.php @@ -71,7 +71,7 @@ protected function setUp(): void public function testCriterionFindAllContentItems(): void { $query = $this->createQuery( - $this->createContentNameCriterion('*') + self::createContentNameCriterion('*') ); self::assertSame( diff --git a/tests/integration/Core/Repository/SearchServiceManyLanguagesTest.php b/tests/integration/Core/Repository/SearchServiceManyLanguagesTest.php index 39c84465b0..a00f3ae331 100644 --- a/tests/integration/Core/Repository/SearchServiceManyLanguagesTest.php +++ b/tests/integration/Core/Repository/SearchServiceManyLanguagesTest.php @@ -53,8 +53,8 @@ public function testFindContentWithManyLanguages(): void try { $result = $searchService->findContent($query, $languageSettings); } catch (Exception $e) { - $this->fail('Search failed with many languages: ' . $e->getMessage()); + self::fail('Search failed with many languages: ' . $e->getMessage()); } - $this->assertGreaterThan(0, $result->totalCount); + self::assertGreaterThan(0, $result->totalCount); } } diff --git a/tests/integration/Core/Repository/SearchServiceTest.php b/tests/integration/Core/Repository/SearchServiceTest.php index d200ba856e..3495b37fa6 100644 --- a/tests/integration/Core/Repository/SearchServiceTest.php +++ b/tests/integration/Core/Repository/SearchServiceTest.php @@ -1045,7 +1045,7 @@ public function testFindContentFieldFiltersCaseSensitivity($queryData): void $query = new Query($queryData); $this->assertQueryFixture( $query, - $this->getFixtureDir() . 'Field.php' + self::getFixtureDir() . 'Field.php' ); } @@ -1058,7 +1058,7 @@ public function testFindLocationsFieldFiltersCaseSensitivity($queryData): void $query = new LocationQuery($queryData); $this->assertQueryFixture( $query, - $this->getFixtureDir() . 'Field.php' + self::getFixtureDir() . 'Field.php' ); } @@ -2819,7 +2819,7 @@ public function testQueryCustomField(): void ); $this->assertQueryFixture( $query, - $this->getFixtureDir() . '/QueryCustomField.php' + self::getFixtureDir() . '/QueryCustomField.php' ); } @@ -2857,7 +2857,7 @@ public function testQueryModifiedField(): void $this->assertQueryFixture( $query, - $this->getFixtureDir() . '/QueryModifiedField.php' + self::getFixtureDir() . '/QueryModifiedField.php' ); } @@ -2896,7 +2896,7 @@ public function testSortModifiedField(): void $this->assertQueryFixture( $query, - $this->getFixtureDir() . '/SortFolderName.php' + self::getFixtureDir() . '/SortFolderName.php' ); } @@ -4017,7 +4017,7 @@ public function testUserMetadataGroupHorizontalFilterContent(?string $queryType $this->simplifySearchResult($result); self::assertEqualsWithDelta( - include $this->getFixtureDir() . '/UserMetadata.php', + include self::getFixtureDir() . '/UserMetadata.php', $result, .1, // Be quite generous regarding delay -- most important for scores 'Search results do not match.', @@ -4114,7 +4114,7 @@ public function testUserMetadataGroupHorizontalFilterLocation($queryType = null) $this->simplifySearchResult($result); self::assertEqualsWithDelta( - include $this->getFixtureDir() . '/UserMetadataLocation.php', + include self::getFixtureDir() . '/UserMetadataLocation.php', $result, .1, // Be quite generous regarding delay -- most important for scores 'Search results do not match.', diff --git a/tests/integration/Core/Repository/SerializationTest.php b/tests/integration/Core/Repository/SerializationTest.php index 71385566a8..cdaa608df5 100644 --- a/tests/integration/Core/Repository/SerializationTest.php +++ b/tests/integration/Core/Repository/SerializationTest.php @@ -16,7 +16,7 @@ final class SerializationTest extends RepositoryTestCase { public function testSerialization(): void { - $serializer = $this->getContainer()->get(SerializerInterface::class); + $serializer = self::getContainer()->get(SerializerInterface::class); self::assertInstanceOf(SerializerInterface::class, $serializer); $contentService = $this->getIbexaTestCore()->getContentService(); diff --git a/tests/lib/FieldType/RelationListTest.php b/tests/lib/FieldType/RelationListTest.php index aaf682d1ce..6e36da344b 100644 --- a/tests/lib/FieldType/RelationListTest.php +++ b/tests/lib/FieldType/RelationListTest.php @@ -425,12 +425,12 @@ public function testValidateNotExistingContentRelations(): void ->expects($matcher) ->method('validate')->willReturnCallback(function (...$parameters) use ($matcher, $invalidDestinationContentId, $invalidDestinationContentId2) { if ($matcher->numberOfInvocations() === 1) { - $this->assertSame($invalidDestinationContentId, $parameters[0]); + self::assertSame($invalidDestinationContentId, $parameters[0]); return $this->generateValidationError($invalidDestinationContentId); } if ($matcher->numberOfInvocations() === 2) { - $this->assertSame($invalidDestinationContentId2, $parameters[0]); + self::assertSame($invalidDestinationContentId2, $parameters[0]); return $this->generateValidationError($invalidDestinationContentId2); } @@ -447,19 +447,19 @@ public function testValidateInvalidContentType(): void $destinationContentId = 12; $destinationContentId2 = 13; $allowedContentTypes = ['article', 'folder']; - $matcher = $this->exactly(2); + $matcher = self::exactly(2); $this->targetContentValidator->expects($matcher) ->method('validate')->willReturnCallback(function (...$parameters) use ($matcher, $destinationContentId, $allowedContentTypes, $destinationContentId2) { if ($matcher->numberOfInvocations() === 1) { - $this->assertSame($destinationContentId, $parameters[0]); - $this->assertSame($allowedContentTypes, $parameters[1]); + self::assertSame($destinationContentId, $parameters[0]); + self::assertSame($allowedContentTypes, $parameters[1]); return $this->generateContentTypeValidationError('test'); } if ($matcher->numberOfInvocations() === 2) { - $this->assertSame($destinationContentId2, $parameters[0]); - $this->assertSame($allowedContentTypes, $parameters[1]); + self::assertSame($destinationContentId2, $parameters[0]); + self::assertSame($allowedContentTypes, $parameters[1]); return $this->generateContentTypeValidationError('test'); } diff --git a/tests/lib/FieldType/Validator/BaseNumericValidatorTestCase.php b/tests/lib/FieldType/Validator/BaseNumericValidatorTestCase.php index c90d506c05..ff0727b3aa 100644 --- a/tests/lib/FieldType/Validator/BaseNumericValidatorTestCase.php +++ b/tests/lib/FieldType/Validator/BaseNumericValidatorTestCase.php @@ -184,10 +184,10 @@ public function testValidateConstraintsCorrectValues(array $data): void $constraints = []; if (array_key_exists('min', $data)) { - $constraints[$this->getMinNumericValueName()] = $data['min']; + $constraints[static::getMinNumericValueName()] = $data['min']; } if (array_key_exists('max', $data)) { - $constraints[$this->getMinNumericValueName()] = $data['max']; + $constraints[static::getMinNumericValueName()] = $data['max']; } self::assertEmpty( @@ -203,8 +203,8 @@ public function testValidateConstraintsCorrectValues(array $data): void #[DataProvider('providerForConstraintsInitializeSetGet')] final public function testConstraintsInitializeGet(array $constraints): void { - $minNumericValueName = $this->getMinNumericValueName(); - $maxNumericValueName = $this->getMaxNumericValueName(); + $minNumericValueName = static::getMinNumericValueName(); + $maxNumericValueName = static::getMaxNumericValueName(); $validator = $this->getValidatorInstance(); $validator->initializeWithConstraints( $constraints @@ -219,8 +219,8 @@ final public function testConstraintsInitializeGet(array $constraints): void #[DataProvider('providerForConstraintsInitializeSetGet')] final public function testConstraintsSetGet(array $constraints): void { - $minNumericValueName = $this->getMinNumericValueName(); - $maxNumericValueName = $this->getMaxNumericValueName(); + $minNumericValueName = static::getMinNumericValueName(); + $maxNumericValueName = static::getMaxNumericValueName(); $validator = $this->getValidatorInstance(); $validator->{$minNumericValueName} = $constraints[$minNumericValueName]; $validator->{$maxNumericValueName} = $constraints[$maxNumericValueName]; diff --git a/tests/lib/FieldType/Validator/FloatValueValidatorTest.php b/tests/lib/FieldType/Validator/FloatValueValidatorTest.php index b63f0822ea..786526a26b 100644 --- a/tests/lib/FieldType/Validator/FloatValueValidatorTest.php +++ b/tests/lib/FieldType/Validator/FloatValueValidatorTest.php @@ -68,11 +68,11 @@ public static function providerForConstraintsInitializeSetGet(): iterable public function testGetConstraintsSchema(): void { $constraintsSchema = [ - $this->getMinNumericValueName() => [ + self::getMinNumericValueName() => [ 'type' => 'float', 'default' => null, ], - $this->getMaxNumericValueName() => [ + self::getMaxNumericValueName() => [ 'type' => 'float', 'default' => null, ], @@ -132,8 +132,8 @@ public static function providerForValidateOK(): array public function testValidateWrongValues(float $value, string $message): void { $validator = $this->getValidatorInstance(); - $validator->minFloatValue = $this->getMinFloatValue(); - $validator->maxFloatValue = $this->getMaxFloatValue(); + $validator->minFloatValue = self::getMinFloatValue(); + $validator->maxFloatValue = self::getMaxFloatValue(); self::assertFalse($validator->validate(new FloatValue($value))); self::assertWrongValueValidationMessage($validator->getMessage(), $message); } diff --git a/tests/lib/FieldType/Validator/IntegerValueValidatorTest.php b/tests/lib/FieldType/Validator/IntegerValueValidatorTest.php index a0db706ca8..2cfd74ffa9 100644 --- a/tests/lib/FieldType/Validator/IntegerValueValidatorTest.php +++ b/tests/lib/FieldType/Validator/IntegerValueValidatorTest.php @@ -62,11 +62,11 @@ public static function providerForConstraintsInitializeSetGet(): iterable public function testGetConstraintsSchema(): void { $constraintsSchema = [ - $this->getMinNumericValueName() => [ + self::getMinNumericValueName() => [ 'type' => 'int', 'default' => 0, ], - $this->getMaxNumericValueName() => [ + self::getMaxNumericValueName() => [ 'type' => 'int', 'default' => null, ], @@ -120,8 +120,8 @@ public static function providerForValidateOK(): array public function testValidateWrongValues(int $value, string $message): void { $validator = $this->getValidatorInstance(); - $validator->minIntegerValue = $this->getMinIntegerValue(); - $validator->maxIntegerValue = $this->getMaxIntegerValue(); + $validator->minIntegerValue = self::getMinIntegerValue(); + $validator->maxIntegerValue = self::getMaxIntegerValue(); self::assertFalse($validator->validate(new IntegerValue($value))); self::assertWrongValueValidationMessage($validator->getMessage(), $message); } diff --git a/tests/lib/IO/Flysystem/PathPrefixer/DFSSiteAccessAwarePathPrefixerTest.php b/tests/lib/IO/Flysystem/PathPrefixer/DFSSiteAccessAwarePathPrefixerTest.php index 874ecb0736..35d050e772 100644 --- a/tests/lib/IO/Flysystem/PathPrefixer/DFSSiteAccessAwarePathPrefixerTest.php +++ b/tests/lib/IO/Flysystem/PathPrefixer/DFSSiteAccessAwarePathPrefixerTest.php @@ -69,7 +69,7 @@ protected function getPrefixer(): PathPrefixerInterface return new DFSSiteAccessAwarePathPrefixer( $configProcessor, - $this->getDFSRootDir(), + self::getDFSRootDir(), $dynamicPath ); } diff --git a/tests/lib/IO/IOMetadataHandler/LegacyDFSClusterTest.php b/tests/lib/IO/IOMetadataHandler/LegacyDFSClusterTest.php index ff378df8fb..1778f18575 100644 --- a/tests/lib/IO/IOMetadataHandler/LegacyDFSClusterTest.php +++ b/tests/lib/IO/IOMetadataHandler/LegacyDFSClusterTest.php @@ -165,12 +165,12 @@ public function testDeletedirectory(): void ->expects($matcher) ->method('setParameter')->willReturnCallback(function (...$parameters) use ($matcher) { if ($matcher->numberOfInvocations() === 1) { - $this->assertSame('esc', $parameters[0]); - $this->assertSame('\\', $parameters[1]); + self::assertSame('esc', $parameters[0]); + self::assertSame('\\', $parameters[1]); } if ($matcher->numberOfInvocations() === 2) { - $this->assertSame('spiPath', $parameters[0]); - $this->assertSame('prefix/images/\_alias/subfolder/%', $parameters[1]); + self::assertSame('spiPath', $parameters[0]); + self::assertSame('prefix/images/\_alias/subfolder/%', $parameters[1]); } return $this->qbMock; diff --git a/tests/lib/Limitation/MemberOfLimitationTypeTest.php b/tests/lib/Limitation/MemberOfLimitationTypeTest.php index 7771ef7a75..747ace7046 100644 --- a/tests/lib/Limitation/MemberOfLimitationTypeTest.php +++ b/tests/lib/Limitation/MemberOfLimitationTypeTest.php @@ -119,16 +119,16 @@ public function testValidateError(MemberOfLimitation $limitation, int $errorCoun $contentHandlerMock = $this->createMock(ContentHandlerInterface::class); if ($limitation->limitationValues !== null) { - $matcher = $this->exactly(2); + $matcher = self::exactly(2); $contentHandlerMock->expects($matcher) - ->method('loadContentInfo')->willReturnCallback(function (...$parameters) use ($matcher) { + ->method('loadContentInfo')->willReturnCallback(static function (...$parameters) use ($matcher) { if ($matcher->numberOfInvocations() === 1) { - $this->assertSame(14, $parameters[0]); + self::assertSame(14, $parameters[0]); throw new NotFoundException('UserGroup', 18); } if ($matcher->numberOfInvocations() === 2) { - $this->assertSame(18, $parameters[0]); + self::assertSame(18, $parameters[0]); return new ContentInfo(); } @@ -171,17 +171,17 @@ public function testEvaluate( new Location(['parentId' => 13]), new Location(['parentId' => 14]), ]); - $matcher = $this->exactly(2); + $matcher = self::exactly(2); $locationHandlerMock->expects($matcher) - ->method('load')->willReturnCallback(function (...$parameters) use ($matcher) { + ->method('load')->willReturnCallback(static function (...$parameters) use ($matcher) { if ($matcher->numberOfInvocations() === 1) { - $this->assertSame(13, $parameters[0]); + self::assertSame(13, $parameters[0]); return new Location(['contentId' => 14]); } if ($matcher->numberOfInvocations() === 2) { - $this->assertSame(14, $parameters[0]); + self::assertSame(14, $parameters[0]); return new Location(['contentId' => 25]); } @@ -366,11 +366,11 @@ public function testEvaluateSelfGroup( foreach ($currentUserGroupLocations as $groupLocation) { $currentUserLocation[] = new Location(['parentId' => $groupLocation->contentId - 1]); } - $matcher = $this->exactly(2); + $matcher = self::exactly(2); $locationHandlerMock->expects($matcher) ->method('loadLocationsByContent')->willReturnCallback(function (...$parameters) use ($matcher, $object, $currentUserLocation) { if ($matcher->numberOfInvocations() === 1) { - $this->assertSame($object instanceof User ? $object->getUserId() : $object->getUser()->getUserId(), $parameters[0]); + self::assertSame($object instanceof User ? $object->getUserId() : $object->getUser()->getUserId(), $parameters[0]); return [ new Location(['parentId' => 13]), @@ -378,22 +378,22 @@ public function testEvaluateSelfGroup( ]; } if ($matcher->numberOfInvocations() === 2) { - $this->assertSame($this->getUserMock()->getUserId(), $parameters[0]); + self::assertSame($this->getUserMock()->getUserId(), $parameters[0]); return $currentUserLocation; } }); - $matcher = $this->exactly(2 + count($currentUserGroupLocations)); + $matcher = self::exactly(2 + count($currentUserGroupLocations)); $locationHandlerMock->expects($matcher) - ->method('load')->willReturnCallback(function (...$parameters) use ($matcher, $currentUserGroupLocations) { + ->method('load')->willReturnCallback(static function (...$parameters) use ($matcher, $currentUserGroupLocations) { if ($matcher->numberOfInvocations() === 1) { - $this->assertSame(13, $parameters[0]); + self::assertSame(13, $parameters[0]); return new Location(['contentId' => 14]); } if ($matcher->numberOfInvocations() === 2) { - $this->assertSame(43, $parameters[0]); + self::assertSame(43, $parameters[0]); return new Location(['contentId' => 44]); } diff --git a/tests/lib/Limitation/RoleLimitationTypeTest.php b/tests/lib/Limitation/RoleLimitationTypeTest.php index 9e36564597..4da283fcc5 100644 --- a/tests/lib/Limitation/RoleLimitationTypeTest.php +++ b/tests/lib/Limitation/RoleLimitationTypeTest.php @@ -103,16 +103,16 @@ public function testValidatePass(UserRoleLimitation $limitation): void $contentHandlerMock = $this->createMock(ContentHandlerInterface::class); if ($limitation->limitationValues !== null) { - $matcher = $this->any(); + $matcher = self::any(); $userHandlerMock->expects($matcher) - ->method('loadRole')->willReturnCallback(function (...$parameters) use ($matcher) { + ->method('loadRole')->willReturnCallback(static function (...$parameters) use ($matcher) { if ($matcher->numberOfInvocations() === 1) { - $this->assertSame(4, $parameters[0]); - $this->assertSame(Role::STATUS_DEFINED, $parameters[1]); + self::assertSame(4, $parameters[0]); + self::assertSame(Role::STATUS_DEFINED, $parameters[1]); } if ($matcher->numberOfInvocations() === 2) { - $this->assertSame(8, $parameters[0]); - $this->assertSame(Role::STATUS_DEFINED, $parameters[1]); + self::assertSame(8, $parameters[0]); + self::assertSame(Role::STATUS_DEFINED, $parameters[1]); } }); @@ -122,14 +122,14 @@ public function testValidatePass(UserRoleLimitation $limitation): void } if ($limitation->limitationValues !== null) { - $matcher = $this->any(); + $matcher = self::any(); $contentHandlerMock->expects($matcher) - ->method('loadContentInfo')->willReturnCallback(function (...$parameters) use ($matcher) { + ->method('loadContentInfo')->willReturnCallback(static function (...$parameters) use ($matcher) { if ($matcher->numberOfInvocations() === 1) { - $this->assertSame(14, $parameters[0]); + self::assertSame(14, $parameters[0]); } if ($matcher->numberOfInvocations() === 2) { - $this->assertSame(21, $parameters[0]); + self::assertSame(21, $parameters[0]); } }); @@ -149,18 +149,18 @@ public function testValidateError(UserRoleLimitation $limitation, int $errorCoun $userHandlerMock = $this->createMock(UserHandlerInterface::class); if ($limitation->limitationValues !== null) { - $matcher = $this->exactly(2); + $matcher = self::exactly(2); $userHandlerMock->expects($matcher) - ->method('loadRole')->willReturnCallback(function (...$parameters) use ($matcher) { + ->method('loadRole')->willReturnCallback(static function (...$parameters) use ($matcher) { if ($matcher->numberOfInvocations() === 1) { - $this->assertSame(4, $parameters[0]); - $this->assertSame(Role::STATUS_DEFINED, $parameters[1]); + self::assertSame(4, $parameters[0]); + self::assertSame(Role::STATUS_DEFINED, $parameters[1]); throw new NotFoundException('Role', 4); } if ($matcher->numberOfInvocations() === 2) { - $this->assertSame(8, $parameters[0]); - $this->assertSame(Role::STATUS_DEFINED, $parameters[1]); + self::assertSame(8, $parameters[0]); + self::assertSame(Role::STATUS_DEFINED, $parameters[1]); return new Role(); } diff --git a/tests/lib/Limitation/SubtreeLimitationTypeTest.php b/tests/lib/Limitation/SubtreeLimitationTypeTest.php index 2ceb8585ea..cbedceebb5 100644 --- a/tests/lib/Limitation/SubtreeLimitationTypeTest.php +++ b/tests/lib/Limitation/SubtreeLimitationTypeTest.php @@ -151,8 +151,8 @@ public function testValidatePass(SubtreeLimitation $limitation): void $this->locationHandlerMock ->expects($matcher) ->method('load') - ->willReturnCallback(function (...$parameters) use ($matcher, $loadArguments, $loadReturnValues) { - $this->assertSame($loadArguments[$matcher->numberOfInvocations() - 1], $parameters[0]); + ->willReturnCallback(static function (...$parameters) use ($matcher, $loadArguments, $loadReturnValues) { + self::assertSame($loadArguments[$matcher->numberOfInvocations() - 1], $parameters[0]); return $loadReturnValues[$matcher->numberOfInvocations() - 1]; }); @@ -202,8 +202,8 @@ public function testValidateError(SubtreeLimitation $limitation, $errorCount): v $this->locationHandlerMock ->expects($matcher) ->method('load') - ->willReturnCallback(function (...$parameters) use ($matcher, $loadArguments, $loadExceptions) { - $this->assertSame($loadArguments[$matcher->numberOfInvocations() - 1], $parameters[0]); + ->willReturnCallback(static function (...$parameters) use ($matcher, $loadArguments, $loadExceptions) { + self::assertSame($loadArguments[$matcher->numberOfInvocations() - 1], $parameters[0]); throw $loadExceptions[$matcher->numberOfInvocations() - 1]; }); @@ -241,8 +241,8 @@ public function testValidateErrorWrongPath(): void $this->locationHandlerMock ->expects($matcher) ->method('load') - ->willReturnCallback(function (...$parameters) use ($matcher, $loadArguments, $loadReturnValues) { - $this->assertSame($loadArguments[$matcher->numberOfInvocations() - 1], $parameters[0]); + ->willReturnCallback(static function (...$parameters) use ($matcher, $loadArguments, $loadReturnValues) { + self::assertSame($loadArguments[$matcher->numberOfInvocations() - 1], $parameters[0]); return $loadReturnValues[$matcher->numberOfInvocations() - 1]; }); @@ -454,8 +454,8 @@ public function testEvaluate( $this->locationHandlerMock ->expects($matcher) ->method('load') - ->willReturnCallback(function (...$parameters) use ($matcher, $loadArguments, $loadReturnValues) { - $this->assertSame($loadArguments[$matcher->numberOfInvocations() - 1], $parameters[0]); + ->willReturnCallback(static function (...$parameters) use ($matcher, $loadArguments, $loadReturnValues) { + self::assertSame($loadArguments[$matcher->numberOfInvocations() - 1], $parameters[0]); return $loadReturnValues[$matcher->numberOfInvocations() - 1]; }); diff --git a/tests/lib/MVC/Symfony/Controller/Controller/Content/DownloadControllerTest.php b/tests/lib/MVC/Symfony/Controller/Controller/Content/DownloadControllerTest.php index d215e41e24..8f1b5d7fb1 100644 --- a/tests/lib/MVC/Symfony/Controller/Controller/Content/DownloadControllerTest.php +++ b/tests/lib/MVC/Symfony/Controller/Controller/Content/DownloadControllerTest.php @@ -92,7 +92,7 @@ public function testDownloadBinaryFileActionReturnsNotFoundWhenContentDoesNotExi ->with(393) ->willThrowException(new BaseNotFoundException('Content', 393)); $this->translationHelper - ->expects($this->never()) + ->expects(self::never()) ->method('getTranslatedField'); $this->expectBinaryFileNotLoaded(); @@ -134,7 +134,7 @@ public function testDownloadBinaryFileByIdActionReturnsNotFound(int $fieldId, st ->with(42, null, null) ->willReturn($content); $this->translationHelper - ->expects($this->never()) + ->expects(self::never()) ->method('getTranslatedField'); $this->expectBinaryFileNotLoaded(); diff --git a/tests/lib/MVC/Symfony/Controller/Controller/Content/PreviewControllerTest.php b/tests/lib/MVC/Symfony/Controller/Controller/Content/PreviewControllerTest.php index 358a260323..a655df993e 100644 --- a/tests/lib/MVC/Symfony/Controller/Controller/Content/PreviewControllerTest.php +++ b/tests/lib/MVC/Symfony/Controller/Controller/Content/PreviewControllerTest.php @@ -335,12 +335,12 @@ private function configurePreviewHelper( $matcher = self::exactly(2); $this->previewHelper ->expects($matcher) - ->method('setPreviewActive')->willReturnCallback(function (...$parameters) use ($matcher) { + ->method('setPreviewActive')->willReturnCallback(static function (...$parameters) use ($matcher) { if ($matcher->numberOfInvocations() === 1) { - $this->assertTrue($parameters[0]); + self::assertTrue($parameters[0]); } if ($matcher->numberOfInvocations() === 2) { - $this->assertFalse($parameters[0]); + self::assertFalse($parameters[0]); } }) ; diff --git a/tests/lib/MVC/Symfony/Security/Authentication/EventSubscriber/OnAuthenticationTokenCreatedRepositoryUserSubscriberTest.php b/tests/lib/MVC/Symfony/Security/Authentication/EventSubscriber/OnAuthenticationTokenCreatedRepositoryUserSubscriberTest.php index afbb2a6655..2725769df8 100644 --- a/tests/lib/MVC/Symfony/Security/Authentication/EventSubscriber/OnAuthenticationTokenCreatedRepositoryUserSubscriberTest.php +++ b/tests/lib/MVC/Symfony/Security/Authentication/EventSubscriber/OnAuthenticationTokenCreatedRepositoryUserSubscriberTest.php @@ -34,7 +34,7 @@ public function testGetSubscribedEvents(): void [ AuthenticationTokenCreatedEvent::class => ['onAuthenticationTokenCreated', 10], ], - $subscriber->getSubscribedEvents() + OnAuthenticationTokenCreatedRepositoryUserSubscriber::getSubscribedEvents() ); } diff --git a/tests/lib/MVC/Symfony/Security/Authentication/EventSubscriber/RepositoryUserAuthenticationSubscriberTest.php b/tests/lib/MVC/Symfony/Security/Authentication/EventSubscriber/RepositoryUserAuthenticationSubscriberTest.php index 8d7f1570d9..66e8fa9899 100644 --- a/tests/lib/MVC/Symfony/Security/Authentication/EventSubscriber/RepositoryUserAuthenticationSubscriberTest.php +++ b/tests/lib/MVC/Symfony/Security/Authentication/EventSubscriber/RepositoryUserAuthenticationSubscriberTest.php @@ -39,7 +39,7 @@ public function testGetSubscribedEvents(): void [ CheckPassportEvent::class => ['validateRepositoryUser'], ], - $this->getSubscriber()->getSubscribedEvents() + RepositoryUserAuthenticationSubscriber::getSubscribedEvents() ); } diff --git a/tests/lib/MVC/Symfony/Templating/RenderLocationStrategyTest.php b/tests/lib/MVC/Symfony/Templating/RenderLocationStrategyTest.php index a49135742c..9e7fd308b4 100644 --- a/tests/lib/MVC/Symfony/Templating/RenderLocationStrategyTest.php +++ b/tests/lib/MVC/Symfony/Templating/RenderLocationStrategyTest.php @@ -116,10 +116,9 @@ public function testExpectedMethodRenderRequestFormat(): void ->method('getName') ->willReturn('method_b'); - $controllerReferenceCallback = self::callback(function (ControllerReference $controllerReference): bool { - $this->assertInstanceOf(ControllerReference::class, $controllerReference); - $this->assertEquals('ibexa_content::viewAction', $controllerReference->controller); - $this->assertSame([ + $controllerReferenceCallback = self::callback(static function (ControllerReference $controllerReference): bool { + self::assertEquals('ibexa_content::viewAction', $controllerReference->controller); + self::assertSame([ 'contentId' => 234, 'locationId' => 345, 'viewType' => 'awesome', @@ -129,8 +128,8 @@ public function testExpectedMethodRenderRequestFormat(): void return true; }); - $requestCallback = self::callback(function (Request $request) use ($siteAccess, $content): bool { - $this->assertSame('TEST/1.0', $request->headers->get('Surrogate-Capability')); + $requestCallback = self::callback(static function (Request $request) use ($siteAccess, $content): bool { + self::assertSame('TEST/1.0', $request->headers->get('Surrogate-Capability')); return true; }); diff --git a/tests/lib/Persistence/Cache/AbstractCacheHandlerTestCase.php b/tests/lib/Persistence/Cache/AbstractCacheHandlerTestCase.php index b06a0e2a93..7a0b38f5d1 100644 --- a/tests/lib/Persistence/Cache/AbstractCacheHandlerTestCase.php +++ b/tests/lib/Persistence/Cache/AbstractCacheHandlerTestCase.php @@ -76,8 +76,8 @@ final public function testUnCachedMethods( $this->cacheIdentifierGeneratorMock ->expects($matcher) ->method('generateTag') - ->willReturnCallback(function (...$parameters) use ($matcher, $tagGeneratingArguments, $tags) { - $this->assertEquals($tagGeneratingArguments[$matcher->numberOfInvocations() - 1], $parameters); + ->willReturnCallback(static function (...$parameters) use ($matcher, $tagGeneratingArguments, $tags) { + self::assertEquals($tagGeneratingArguments[$matcher->numberOfInvocations() - 1], $parameters); return $tags[$matcher->numberOfInvocations() - 1]; }); @@ -91,8 +91,8 @@ final public function testUnCachedMethods( $this->cacheIdentifierGeneratorMock ->expects($matcher) ->method('generateKey') - ->willReturnCallback(function (...$parameters) use ($matcher, $keyGeneratingArguments, $key) { - $this->assertEquals($keyGeneratingArguments[$matcher->numberOfInvocations() - 1], $parameters); + ->willReturnCallback(static function (...$parameters) use ($matcher, $keyGeneratingArguments, $key) { + self::assertEquals($keyGeneratingArguments[$matcher->numberOfInvocations() - 1], $parameters); return $key[$matcher->numberOfInvocations() - 1]; }); @@ -168,8 +168,8 @@ final public function testLoadMethodsCacheHit( $this->cacheIdentifierGeneratorMock ->expects($matcher) ->method('generateTag') - ->willReturnCallback(function (...$parameters) use ($matcher, $tagGeneratingArguments, $tagGeneratingResults) { - $this->assertEquals($tagGeneratingArguments[$matcher->numberOfInvocations() - 1], $parameters); + ->willReturnCallback(static function (...$parameters) use ($matcher, $tagGeneratingArguments, $tagGeneratingResults) { + self::assertEquals($tagGeneratingArguments[$matcher->numberOfInvocations() - 1], $parameters); return $tagGeneratingResults[$matcher->numberOfInvocations() - 1]; }); @@ -180,8 +180,8 @@ final public function testLoadMethodsCacheHit( $this->cacheIdentifierGeneratorMock ->expects($matcher) ->method('generateKey') - ->willReturnCallback(function (...$parameters) use ($matcher, $keyGeneratingArguments, $keyGeneratingResults) { - $this->assertEquals($keyGeneratingArguments[$matcher->numberOfInvocations() - 1], $parameters); + ->willReturnCallback(static function (...$parameters) use ($matcher, $keyGeneratingArguments, $keyGeneratingResults) { + self::assertEquals($keyGeneratingArguments[$matcher->numberOfInvocations() - 1], $parameters); return $keyGeneratingResults[$matcher->numberOfInvocations() - 1]; }); @@ -262,8 +262,8 @@ final public function testLoadMethodsCacheMiss( $this->cacheIdentifierGeneratorMock ->expects($matcher) ->method('generateTag') - ->willReturnCallback(function (...$parameters) use ($matcher, $tagGeneratingArguments, $tagGeneratingResults) { - $this->assertEquals($tagGeneratingArguments[$matcher->numberOfInvocations() - 1], $parameters); + ->willReturnCallback(static function (...$parameters) use ($matcher, $tagGeneratingArguments, $tagGeneratingResults) { + self::assertEquals($tagGeneratingArguments[$matcher->numberOfInvocations() - 1], $parameters); return $tagGeneratingResults[$matcher->numberOfInvocations() - 1]; }); @@ -274,8 +274,8 @@ final public function testLoadMethodsCacheMiss( $this->cacheIdentifierGeneratorMock ->expects($matcher) ->method('generateKey') - ->willReturnCallback(function (...$parameters) use ($matcher, $keyGeneratingArguments, $keyGeneratingResults) { - $this->assertEquals($keyGeneratingArguments[$matcher->numberOfInvocations() - 1], $parameters); + ->willReturnCallback(static function (...$parameters) use ($matcher, $keyGeneratingArguments, $keyGeneratingResults) { + self::assertEquals($keyGeneratingArguments[$matcher->numberOfInvocations() - 1], $parameters); return $keyGeneratingResults[$matcher->numberOfInvocations() - 1]; }); diff --git a/tests/lib/Persistence/Cache/AbstractInMemoryCacheHandlerTestCase.php b/tests/lib/Persistence/Cache/AbstractInMemoryCacheHandlerTestCase.php index 8f457d1f6c..05e8b68c83 100644 --- a/tests/lib/Persistence/Cache/AbstractInMemoryCacheHandlerTestCase.php +++ b/tests/lib/Persistence/Cache/AbstractInMemoryCacheHandlerTestCase.php @@ -68,8 +68,8 @@ final public function testUnCachedMethods( $this->cacheIdentifierGeneratorMock ->expects($matcher) ->method('generateTag') - ->willReturnCallback(function (...$parameters) use ($matcher, $tagGeneratingArguments, $tags) { - $this->assertEquals($tagGeneratingArguments[$matcher->numberOfInvocations() - 1], $parameters); + ->willReturnCallback(static function (...$parameters) use ($matcher, $tagGeneratingArguments, $tags) { + self::assertEquals($tagGeneratingArguments[$matcher->numberOfInvocations() - 1], $parameters); return $tags[$matcher->numberOfInvocations() - 1]; }); @@ -83,8 +83,8 @@ final public function testUnCachedMethods( $this->cacheIdentifierGeneratorMock ->expects($matcher) ->method('generateKey') - ->willReturnCallback(function (...$parameters) use ($matcher, $keyGeneratingArguments, $key) { - $this->assertEquals($keyGeneratingArguments[$matcher->numberOfInvocations() - 1], $parameters); + ->willReturnCallback(static function (...$parameters) use ($matcher, $keyGeneratingArguments, $key) { + self::assertEquals($keyGeneratingArguments[$matcher->numberOfInvocations() - 1], $parameters); return $key[$matcher->numberOfInvocations() - 1]; }); @@ -157,8 +157,8 @@ final public function testLoadMethodsCacheHit( $this->cacheIdentifierGeneratorMock ->expects($matcher) ->method('generateTag') - ->willReturnCallback(function (...$parameters) use ($matcher, $tagGeneratingArguments, $tagGeneratingResults) { - $this->assertEquals($tagGeneratingArguments[$matcher->numberOfInvocations() - 1], $parameters); + ->willReturnCallback(static function (...$parameters) use ($matcher, $tagGeneratingArguments, $tagGeneratingResults) { + self::assertEquals($tagGeneratingArguments[$matcher->numberOfInvocations() - 1], $parameters); return $tagGeneratingResults[$matcher->numberOfInvocations() - 1]; }); @@ -169,8 +169,8 @@ final public function testLoadMethodsCacheHit( $this->cacheIdentifierGeneratorMock ->expects($matcher) ->method('generateKey') - ->willReturnCallback(function (...$parameters) use ($matcher, $keyGeneratingArguments, $keyGeneratingResults) { - $this->assertEquals($keyGeneratingArguments[$matcher->numberOfInvocations() - 1], $parameters); + ->willReturnCallback(static function (...$parameters) use ($matcher, $keyGeneratingArguments, $keyGeneratingResults) { + self::assertEquals($keyGeneratingArguments[$matcher->numberOfInvocations() - 1], $parameters); return $keyGeneratingResults[$matcher->numberOfInvocations() - 1]; }); @@ -245,8 +245,8 @@ final public function testLoadMethodsCacheMiss( $this->cacheIdentifierGeneratorMock ->expects($matcher) ->method('generateTag') - ->willReturnCallback(function (...$parameters) use ($matcher, $tagGeneratingArguments, $tagGeneratingResults) { - $this->assertEquals($tagGeneratingArguments[$matcher->numberOfInvocations() - 1], $parameters); + ->willReturnCallback(static function (...$parameters) use ($matcher, $tagGeneratingArguments, $tagGeneratingResults) { + self::assertEquals($tagGeneratingArguments[$matcher->numberOfInvocations() - 1], $parameters); return $tagGeneratingResults[$matcher->numberOfInvocations() - 1]; }); @@ -257,8 +257,8 @@ final public function testLoadMethodsCacheMiss( $this->cacheIdentifierGeneratorMock ->expects($matcher) ->method('generateKey') - ->willReturnCallback(function (...$parameters) use ($matcher, $keyGeneratingArguments, $keyGeneratingResults) { - $this->assertEquals($keyGeneratingArguments[$matcher->numberOfInvocations() - 1], $parameters); + ->willReturnCallback(static function (...$parameters) use ($matcher, $keyGeneratingArguments, $keyGeneratingResults) { + self::assertEquals($keyGeneratingArguments[$matcher->numberOfInvocations() - 1], $parameters); return $keyGeneratingResults[$matcher->numberOfInvocations() - 1]; }); diff --git a/tests/lib/Persistence/Cache/ContentHandlerTest.php b/tests/lib/Persistence/Cache/ContentHandlerTest.php index 89d9a469c2..de7b495f39 100644 --- a/tests/lib/Persistence/Cache/ContentHandlerTest.php +++ b/tests/lib/Persistence/Cache/ContentHandlerTest.php @@ -469,18 +469,18 @@ public function testDeleteContent(): void $this->cacheIdentifierGeneratorMock ->expects($matcher) - ->method('generateTag')->willReturnCallback(function (...$parameters) use ($matcher) { + ->method('generateTag')->willReturnCallback(static function (...$parameters) use ($matcher) { if ($matcher->numberOfInvocations() === 1) { - $this->assertSame('content', $parameters[0]); - $this->assertSame([42], $parameters[1]); - $this->assertFalse($parameters[2]); + self::assertSame('content', $parameters[0]); + self::assertSame([42], $parameters[1]); + self::assertFalse($parameters[2]); return 'c-42'; } if ($matcher->numberOfInvocations() === 2) { - $this->assertSame('content', $parameters[0]); - $this->assertSame([2], $parameters[1]); - $this->assertFalse($parameters[2]); + self::assertSame('content', $parameters[0]); + self::assertSame([2], $parameters[1]); + self::assertFalse($parameters[2]); return 'c-2'; } diff --git a/tests/lib/Persistence/Cache/ContentTypeHandlerTest.php b/tests/lib/Persistence/Cache/ContentTypeHandlerTest.php index 33a398c05d..e286168b5a 100644 --- a/tests/lib/Persistence/Cache/ContentTypeHandlerTest.php +++ b/tests/lib/Persistence/Cache/ContentTypeHandlerTest.php @@ -429,25 +429,25 @@ public function testPublish(): void $this->cacheIdentifierGeneratorMock ->expects($matcher) - ->method('generateTag')->willReturnCallback(function (...$parameters) use ($matcher) { + ->method('generateTag')->willReturnCallback(static function (...$parameters) use ($matcher) { if ($matcher->numberOfInvocations() === 1) { - $this->assertSame('type', $parameters[0]); - $this->assertSame([5], $parameters[1]); - $this->assertFalse($parameters[2]); + self::assertSame('type', $parameters[0]); + self::assertSame([5], $parameters[1]); + self::assertFalse($parameters[2]); return 't-5'; } if ($matcher->numberOfInvocations() === 2) { - $this->assertSame('type_map', $parameters[0]); - $this->assertSame([], $parameters[1]); - $this->assertFalse($parameters[2]); + self::assertSame('type_map', $parameters[0]); + self::assertSame([], $parameters[1]); + self::assertFalse($parameters[2]); return 'tm'; } if ($matcher->numberOfInvocations() === 3) { - $this->assertSame('content_fields_type', $parameters[0]); - $this->assertSame([5], $parameters[1]); - $this->assertFalse($parameters[2]); + self::assertSame('content_fields_type', $parameters[0]); + self::assertSame([5], $parameters[1]); + self::assertFalse($parameters[2]); return 'cft-5'; } @@ -456,25 +456,25 @@ public function testPublish(): void $this->cacheIdentifierGeneratorMock ->expects($matcher) - ->method('generateKey')->willReturnCallback(function (...$parameters) use ($matcher) { + ->method('generateKey')->willReturnCallback(static function (...$parameters) use ($matcher) { if ($matcher->numberOfInvocations() === 1) { - $this->assertSame('content_type', $parameters[0]); - $this->assertSame([], $parameters[1]); - $this->assertTrue($parameters[2]); + self::assertSame('content_type', $parameters[0]); + self::assertSame([], $parameters[1]); + self::assertTrue($parameters[2]); return 'ibx-ct'; } if ($matcher->numberOfInvocations() === 2) { - $this->assertSame('content_type_list_by_group', $parameters[0]); - $this->assertSame([3], $parameters[1]); - $this->assertTrue($parameters[2]); + self::assertSame('content_type_list_by_group', $parameters[0]); + self::assertSame([3], $parameters[1]); + self::assertTrue($parameters[2]); return 'ibx-ctlbg-3'; } if ($matcher->numberOfInvocations() === 3) { - $this->assertSame('content_type_list_by_group', $parameters[0]); - $this->assertSame([4], $parameters[1]); - $this->assertTrue($parameters[2]); + self::assertSame('content_type_list_by_group', $parameters[0]); + self::assertSame([4], $parameters[1]); + self::assertTrue($parameters[2]); return 'ibx-ctlbg-4'; } diff --git a/tests/lib/Persistence/Cache/TrashHandlerTest.php b/tests/lib/Persistence/Cache/TrashHandlerTest.php index b33718c347..4fb289f13b 100644 --- a/tests/lib/Persistence/Cache/TrashHandlerTest.php +++ b/tests/lib/Persistence/Cache/TrashHandlerTest.php @@ -83,7 +83,7 @@ public function testTrashSubtree(): void $contentId = 42; $roleId = 1; - $this->loggerMock->expects($this->once())->method('logCall'); + $this->loggerMock->expects(self::once())->method('logCall'); $innerHandler = $this->setUpRoleAssignmentInvalidation($locationId, $contentId, $roleId); @@ -145,25 +145,25 @@ private function setUpRoleAssignmentInvalidation(int $locationId, int $contentId $this->cacheIdentifierGeneratorMock ->expects($matcher) - ->method('generateTag')->willReturnCallback(function (...$parameters) use ($matcher, $roleId, $contentId, $locationId) { + ->method('generateTag')->willReturnCallback(static function (...$parameters) use ($matcher, $roleId, $contentId, $locationId) { if ($matcher->numberOfInvocations() === 1) { - $this->assertSame('role_assignment_role_list', $parameters[0]); - $this->assertSame([$roleId], $parameters[1]); - $this->assertFalse($parameters[2]); + self::assertSame('role_assignment_role_list', $parameters[0]); + self::assertSame([$roleId], $parameters[1]); + self::assertFalse($parameters[2]); return 'rarl-' . $roleId; } if ($matcher->numberOfInvocations() === 2) { - $this->assertSame('content', $parameters[0]); - $this->assertSame([$contentId], $parameters[1]); - $this->assertFalse($parameters[2]); + self::assertSame('content', $parameters[0]); + self::assertSame([$contentId], $parameters[1]); + self::assertFalse($parameters[2]); return 'c-' . $contentId; } if ($matcher->numberOfInvocations() === 3) { - $this->assertSame('location_path', $parameters[0]); - $this->assertSame([$locationId], $parameters[1]); - $this->assertFalse($parameters[2]); + self::assertSame('location_path', $parameters[0]); + self::assertSame([$locationId], $parameters[1]); + self::assertFalse($parameters[2]); return 'lp-' . $locationId; } @@ -225,25 +225,25 @@ public function testDeleteTrashItem(): void $this->cacheIdentifierGeneratorMock ->expects($matcher) - ->method('generateTag')->willReturnCallback(function (...$parameters) use ($matcher, $relationSourceContentId, $contentId, $trashedId) { + ->method('generateTag')->willReturnCallback(static function (...$parameters) use ($matcher, $relationSourceContentId, $contentId, $trashedId) { if ($matcher->numberOfInvocations() === 1) { - $this->assertSame('content', $parameters[0]); - $this->assertSame([$relationSourceContentId], $parameters[1]); - $this->assertFalse($parameters[2]); + self::assertSame('content', $parameters[0]); + self::assertSame([$relationSourceContentId], $parameters[1]); + self::assertFalse($parameters[2]); return 'c-' . $relationSourceContentId; } if ($matcher->numberOfInvocations() === 2) { - $this->assertSame('content', $parameters[0]); - $this->assertSame([$contentId], $parameters[1]); - $this->assertFalse($parameters[2]); + self::assertSame('content', $parameters[0]); + self::assertSame([$contentId], $parameters[1]); + self::assertFalse($parameters[2]); return 'c-' . $contentId; } if ($matcher->numberOfInvocations() === 3) { - $this->assertSame('location_path', $parameters[0]); - $this->assertSame([$trashedId], $parameters[1]); - $this->assertFalse($parameters[2]); + self::assertSame('location_path', $parameters[0]); + self::assertSame([$trashedId], $parameters[1]); + self::assertFalse($parameters[2]); return 'lp-' . $trashedId; } @@ -311,8 +311,8 @@ public function testEmptyTrash(): void $this->cacheIdentifierGeneratorMock ->expects($matcher) ->method('generateTag') - ->willReturnCallback(function (...$parameters) use ($matcher, $cacheIdentifierGeneratorArguments, $tags) { - $this->assertSame(array_merge($cacheIdentifierGeneratorArguments, $cacheIdentifierGeneratorArguments)[$matcher->numberOfInvocations() - 1], $parameters); + ->willReturnCallback(static function (...$parameters) use ($matcher, $cacheIdentifierGeneratorArguments, $tags) { + self::assertSame(array_merge($cacheIdentifierGeneratorArguments, $cacheIdentifierGeneratorArguments)[$matcher->numberOfInvocations() - 1], $parameters); return array_merge($tags, $tags)[$matcher->numberOfInvocations() - 1]; }); diff --git a/tests/lib/Persistence/Cache/URLHandlerTest.php b/tests/lib/Persistence/Cache/URLHandlerTest.php index 585f18ffb0..5280025f85 100644 --- a/tests/lib/Persistence/Cache/URLHandlerTest.php +++ b/tests/lib/Persistence/Cache/URLHandlerTest.php @@ -95,32 +95,32 @@ public function testUpdateUrlWhenAddressIsUpdated(): void $this->cacheIdentifierGeneratorMock ->expects($matcher) - ->method('generateTag')->willReturnCallback(function (...$parameters) use ($matcher) { + ->method('generateTag')->willReturnCallback(static function (...$parameters) use ($matcher) { if ($matcher->numberOfInvocations() === 1) { - $this->assertSame('url', $parameters[0]); - $this->assertSame([1], $parameters[1]); - $this->assertFalse($parameters[2]); + self::assertSame('url', $parameters[0]); + self::assertSame([1], $parameters[1]); + self::assertFalse($parameters[2]); return 'url-1'; } if ($matcher->numberOfInvocations() === 2) { - $this->assertSame('content', $parameters[0]); - $this->assertSame([2], $parameters[1]); - $this->assertFalse($parameters[2]); + self::assertSame('content', $parameters[0]); + self::assertSame([2], $parameters[1]); + self::assertFalse($parameters[2]); return 'c-2'; } if ($matcher->numberOfInvocations() === 3) { - $this->assertSame('content', $parameters[0]); - $this->assertSame([3], $parameters[1]); - $this->assertFalse($parameters[2]); + self::assertSame('content', $parameters[0]); + self::assertSame([3], $parameters[1]); + self::assertFalse($parameters[2]); return 'c-3'; } if ($matcher->numberOfInvocations() === 4) { - $this->assertSame('content', $parameters[0]); - $this->assertSame([5], $parameters[1]); - $this->assertFalse($parameters[2]); + self::assertSame('content', $parameters[0]); + self::assertSame([5], $parameters[1]); + self::assertFalse($parameters[2]); return 'c-5'; } diff --git a/tests/lib/Persistence/Cache/UserHandlerTest.php b/tests/lib/Persistence/Cache/UserHandlerTest.php index 62fdb726ae..64ae71b155 100644 --- a/tests/lib/Persistence/Cache/UserHandlerTest.php +++ b/tests/lib/Persistence/Cache/UserHandlerTest.php @@ -574,24 +574,24 @@ public function testAssignRole(): void $this->cacheIdentifierGeneratorMock ->expects($matcher) - ->method('generateTag')->willReturnCallback(function (...$parameters) use ($matcher, $tags) { + ->method('generateTag')->willReturnCallback(static function (...$parameters) use ($matcher, $tags) { if ($matcher->numberOfInvocations() === 1) { - $this->assertSame('role_assignment_group_list', $parameters[0]); - $this->assertSame([14], $parameters[1]); - $this->assertFalse($parameters[2]); + self::assertSame('role_assignment_group_list', $parameters[0]); + self::assertSame([14], $parameters[1]); + self::assertFalse($parameters[2]); return $tags[0]; } if ($matcher->numberOfInvocations() === 2) { - $this->assertSame('role_assignment_role_list', $parameters[0]); - $this->assertSame([9], $parameters[1]); - $this->assertFalse($parameters[2]); + self::assertSame('role_assignment_role_list', $parameters[0]); + self::assertSame([9], $parameters[1]); + self::assertFalse($parameters[2]); return $tags[1]; } - $this->assertSame('location_path', $parameters[0]); - $this->assertEquals([43], $parameters[1]); - $this->assertFalse($parameters[2]); + self::assertSame('location_path', $parameters[0]); + self::assertEquals([43], $parameters[1]); + self::assertFalse($parameters[2]); return $tags[2]; }); @@ -643,18 +643,18 @@ public function testRemoveRoleAssignment(): void $matcher = self::exactly(count($tags)); $this->cacheIdentifierGeneratorMock ->expects($matcher) - ->method('generateTag')->willReturnCallback(function (...$parameters) use ($matcher, $tags) { + ->method('generateTag')->willReturnCallback(static function (...$parameters) use ($matcher, $tags) { if ($matcher->numberOfInvocations() === 1) { - $this->assertSame('role_assignment', $parameters[0]); + self::assertSame('role_assignment', $parameters[0]); return $tags[0]; } if ($matcher->numberOfInvocations() === 2) { - $this->assertSame('role_assignment_group_list', $parameters[0]); + self::assertSame('role_assignment_group_list', $parameters[0]); return $tags[1]; } - $this->assertSame('role_assignment_role_list', $parameters[0]); + self::assertSame('role_assignment_role_list', $parameters[0]); return $tags[2]; }); diff --git a/tests/lib/Persistence/Legacy/Content/FieldHandlerTest.php b/tests/lib/Persistence/Legacy/Content/FieldHandlerTest.php index 6dbc495ef8..876c70b436 100644 --- a/tests/lib/Persistence/Legacy/Content/FieldHandlerTest.php +++ b/tests/lib/Persistence/Legacy/Content/FieldHandlerTest.php @@ -111,9 +111,9 @@ protected function assertCreateNewFields($storageHandlerUpdatesFields = false) $invocationOrder = 0; $storageHandlerMock->expects(self::exactly(5)) ->method('storeFieldData') - ->willReturnCallback(function (...$parameters) use (&$invocationOrder, $expectedStoreFields, $storageHandlerUpdatesFields) { - $this->assertInstanceOf(VersionInfo::class, $parameters[0]); - $this->assertEquals($expectedStoreFields[$invocationOrder], $parameters[1]); + ->willReturnCallback(static function (...$parameters) use (&$invocationOrder, $expectedStoreFields, $storageHandlerUpdatesFields) { + self::assertInstanceOf(VersionInfo::class, $parameters[0]); + self::assertEquals($expectedStoreFields[$invocationOrder], $parameters[1]); ++$invocationOrder; return $storageHandlerUpdatesFields; @@ -123,11 +123,11 @@ protected function assertCreateNewFields($storageHandlerUpdatesFields = false) /* @var $originalField */ $storageHandlerMock->expects(self::once()) ->method('copyFieldData') - ->willReturnCallback(function (...$parameters) use (&$invocationOrder, $copyField, $originalField, $storageHandlerUpdatesFields) { - $this->assertSame(5, $invocationOrder); - $this->assertInstanceOf(VersionInfo::class, $parameters[0]); - $this->assertEquals($copyField, $parameters[1]); - $this->assertEquals($originalField, $parameters[2]); + ->willReturnCallback(static function (...$parameters) use (&$invocationOrder, $copyField, $originalField, $storageHandlerUpdatesFields) { + self::assertSame(5, $invocationOrder); + self::assertInstanceOf(VersionInfo::class, $parameters[0]); + self::assertEquals($copyField, $parameters[1]); + self::assertEquals($originalField, $parameters[2]); ++$invocationOrder; return $storageHandlerUpdatesFields; @@ -217,9 +217,9 @@ protected function assertCreateNewFieldsForMainLanguage($storageHandlerUpdatesFi $matcher = self::exactly(3); $storageHandlerMock->expects($matcher) ->method('storeFieldData') - ->willReturnCallback(function (...$parameters) use ($matcher, $expectedFields, $storageHandlerUpdatesFields) { - $this->assertInstanceOf(VersionInfo::class, $parameters[0]); - $this->assertEquals($expectedFields[$matcher->numberOfInvocations() - 1], $parameters[1]); + ->willReturnCallback(static function (...$parameters) use ($matcher, $expectedFields, $storageHandlerUpdatesFields) { + self::assertInstanceOf(VersionInfo::class, $parameters[0]); + self::assertEquals($expectedFields[$matcher->numberOfInvocations() - 1], $parameters[1]); return $storageHandlerUpdatesFields; }); @@ -307,11 +307,11 @@ protected function assertCreateExistingFieldsInNewVersion($storageHandlerUpdates $matcher = self::exactly(6); $storageHandlerMock->expects($matcher) ->method('copyFieldData') - ->willReturnCallback(function (...$parameters) use ($matcher, $expectedCopyCalls, $storageHandlerUpdatesFields) { + ->willReturnCallback(static function (...$parameters) use ($matcher, $expectedCopyCalls, $storageHandlerUpdatesFields) { $index = $matcher->numberOfInvocations() - 1; - $this->assertInstanceOf(VersionInfo::class, $parameters[0]); - $this->assertEquals($expectedCopyCalls[$index]['field'], $parameters[1]); - $this->assertEquals($expectedCopyCalls[$index]['original'], $parameters[2]); + self::assertInstanceOf(VersionInfo::class, $parameters[0]); + self::assertEquals($expectedCopyCalls[$index]['field'], $parameters[1]); + self::assertEquals($expectedCopyCalls[$index]['original'], $parameters[2]); return $storageHandlerUpdatesFields; }); @@ -516,9 +516,9 @@ public function assertUpdateFieldsWithNewLanguage($storageHandlerUpdatesFields = $invocationOrder = 0; $storageHandlerMock->expects(self::exactly(2)) ->method('storeFieldData') - ->willReturnCallback(function (...$parameters) use (&$invocationOrder, $expectedStoreFields, $storageHandlerUpdatesFields) { - $this->assertInstanceOf(VersionInfo::class, $parameters[0]); - $this->assertEquals($expectedStoreFields[$invocationOrder], $parameters[1]); + ->willReturnCallback(static function (...$parameters) use (&$invocationOrder, $expectedStoreFields, $storageHandlerUpdatesFields) { + self::assertInstanceOf(VersionInfo::class, $parameters[0]); + self::assertEquals($expectedStoreFields[$invocationOrder], $parameters[1]); ++$invocationOrder; return $storageHandlerUpdatesFields; @@ -528,11 +528,11 @@ public function assertUpdateFieldsWithNewLanguage($storageHandlerUpdatesFields = /* @var $originalField */ $storageHandlerMock->expects(self::once()) ->method('copyFieldData') - ->willReturnCallback(function (...$parameters) use (&$invocationOrder, $copyField, $originalField, $storageHandlerUpdatesFields) { - $this->assertSame(2, $invocationOrder); - $this->assertInstanceOf(VersionInfo::class, $parameters[0]); - $this->assertEquals($copyField, $parameters[1]); - $this->assertEquals($originalField, $parameters[2]); + ->willReturnCallback(static function (...$parameters) use (&$invocationOrder, $copyField, $originalField, $storageHandlerUpdatesFields) { + self::assertSame(2, $invocationOrder); + self::assertInstanceOf(VersionInfo::class, $parameters[0]); + self::assertEquals($copyField, $parameters[1]); + self::assertEquals($originalField, $parameters[2]); ++$invocationOrder; return $storageHandlerUpdatesFields; @@ -652,9 +652,9 @@ public function assertUpdateFieldsExistingLanguages($storageHandlerUpdatesFields $storeCount = count($expectedStoreFields); $storageHandlerMock->expects(self::exactly($storeCount)) ->method('storeFieldData') - ->willReturnCallback(function (...$parameters) use (&$invocationOrder, $expectedStoreFields, $storageHandlerUpdatesFields) { - $this->assertInstanceOf(VersionInfo::class, $parameters[0]); - $this->assertEquals($expectedStoreFields[$invocationOrder], $parameters[1]); + ->willReturnCallback(static function (...$parameters) use (&$invocationOrder, $expectedStoreFields, $storageHandlerUpdatesFields) { + self::assertInstanceOf(VersionInfo::class, $parameters[0]); + self::assertEquals($expectedStoreFields[$invocationOrder], $parameters[1]); ++$invocationOrder; return $storageHandlerUpdatesFields; @@ -662,11 +662,11 @@ public function assertUpdateFieldsExistingLanguages($storageHandlerUpdatesFields $storageHandlerMock->expects(self::exactly(count($fieldsToCopy))) ->method('copyFieldData') - ->willReturnCallback(function (...$parameters) use (&$invocationOrder, $fieldsToCopy, $storeCount, $storageHandlerUpdatesFields) { + ->willReturnCallback(static function (...$parameters) use (&$invocationOrder, $fieldsToCopy, $storeCount, $storageHandlerUpdatesFields) { $index = $invocationOrder - $storeCount; - $this->assertInstanceOf(VersionInfo::class, $parameters[0]); - $this->assertEquals($fieldsToCopy[$index]['copy'], $parameters[1]); - $this->assertEquals($fieldsToCopy[$index]['original'], $parameters[2]); + self::assertInstanceOf(VersionInfo::class, $parameters[0]); + self::assertEquals($fieldsToCopy[$index]['copy'], $parameters[1]); + self::assertEquals($fieldsToCopy[$index]['original'], $parameters[2]); ++$invocationOrder; return $storageHandlerUpdatesFields; @@ -767,9 +767,9 @@ public function assertUpdateFieldsForInitialLanguage($storageHandlerUpdatesField $storeCount = count($expectedStoreFields); $storageHandlerMock->expects(self::exactly($storeCount)) ->method('storeFieldData') - ->willReturnCallback(function (...$parameters) use (&$invocationOrder, $expectedStoreFields, $storageHandlerUpdatesFields) { - $this->assertInstanceOf(VersionInfo::class, $parameters[0]); - $this->assertEquals($expectedStoreFields[$invocationOrder], $parameters[1]); + ->willReturnCallback(static function (...$parameters) use (&$invocationOrder, $expectedStoreFields, $storageHandlerUpdatesFields) { + self::assertInstanceOf(VersionInfo::class, $parameters[0]); + self::assertEquals($expectedStoreFields[$invocationOrder], $parameters[1]); ++$invocationOrder; return $storageHandlerUpdatesFields; @@ -777,11 +777,11 @@ public function assertUpdateFieldsForInitialLanguage($storageHandlerUpdatesField $storageHandlerMock->expects(self::exactly(count($fieldsToCopy))) ->method('copyFieldData') - ->willReturnCallback(function (...$parameters) use (&$invocationOrder, $fieldsToCopy, $storeCount, $storageHandlerUpdatesFields) { + ->willReturnCallback(static function (...$parameters) use (&$invocationOrder, $fieldsToCopy, $storeCount, $storageHandlerUpdatesFields) { $index = $invocationOrder - $storeCount; - $this->assertInstanceOf(VersionInfo::class, $parameters[0]); - $this->assertEquals($fieldsToCopy[$index]['copy'], $parameters[1]); - $this->assertEquals($fieldsToCopy[$index]['original'], $parameters[2]); + self::assertInstanceOf(VersionInfo::class, $parameters[0]); + self::assertEquals($fieldsToCopy[$index]['copy'], $parameters[1]); + self::assertEquals($fieldsToCopy[$index]['original'], $parameters[2]); ++$invocationOrder; return $storageHandlerUpdatesFields; diff --git a/tests/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabaseTest.php b/tests/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabaseTest.php index f95f16a903..e3ee5a83dd 100644 --- a/tests/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabaseTest.php +++ b/tests/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabaseTest.php @@ -44,7 +44,7 @@ public function testInsertContentObject(): void $gateway = $this->getDatabaseGateway(); $gateway->insertContentObject($struct); - $this->assertQueryResult( + self::assertQueryResult( [ [ 'name' => 'Content name', @@ -168,7 +168,7 @@ public function testInsertVersion(): void $gateway = $this->getDatabaseGateway(); $gateway->insertVersion($version, []); - $this->assertQueryResult( + self::assertQueryResult( [ [ 'contentobject_id' => '2342', @@ -217,7 +217,7 @@ public function testSetStatus(): void $gateway->setStatus($version->contentInfo->id, $version->versionNo, VersionInfo::STATUS_PENDING) ); - $this->assertQueryResult( + self::assertQueryResult( [[VersionInfo::STATUS_PENDING]], $this->getDatabaseConnection() ->createQueryBuilder() @@ -226,7 +226,7 @@ public function testSetStatus(): void ); // check that content status has not been set to published - $this->assertQueryResult( + self::assertQueryResult( [[VersionInfo::STATUS_DRAFT]], $this->getDatabaseConnection() ->createQueryBuilder() @@ -252,7 +252,7 @@ public function testSetStatusPublished(): void $gateway->setStatus($version->contentInfo->id, $version->versionNo, VersionInfo::STATUS_PUBLISHED) ); - $this->assertQueryResult( + self::assertQueryResult( [[VersionInfo::STATUS_PUBLISHED]], $this->getDatabaseConnection() ->createQueryBuilder() @@ -261,7 +261,7 @@ public function testSetStatusPublished(): void ); // check that content status has been set to published - $this->assertQueryResult( + self::assertQueryResult( [[ContentInfo::STATUS_PUBLISHED]], $this->getDatabaseConnection() ->createQueryBuilder() @@ -291,7 +291,7 @@ public function testUpdateContent(): void $gateway->updateContent(10, $metadataStruct); - $this->assertQueryResult( + self::assertQueryResult( [ [ 'initial_language_id' => '3', @@ -361,7 +361,7 @@ public function testUpdateVersion(): void $query = $this->getDatabaseConnection()->createQueryBuilder(); $expr = $query->expr(); - $this->assertQueryResult( + self::assertQueryResult( [ [ 'creator_id' => '23', @@ -396,7 +396,7 @@ public function testInsertNewField(): void $gateway = $this->getDatabaseGateway(); $gateway->insertNewField($content, $field, $value); - $this->assertQueryResult( + self::assertQueryResult( [ [ 'content_type_field_definition_id' => '231', @@ -443,7 +443,7 @@ public function testInsertNewAlwaysAvailableField(): void $gateway = $this->getDatabaseGateway(); $gateway->insertNewField($content, $field, $value); - $this->assertQueryResult( + self::assertQueryResult( [ [ 'content_type_field_definition_id' => '231', @@ -500,7 +500,7 @@ public function testUpdateField(): void $gateway->updateField($field, $newValue); - $this->assertQueryResult( + self::assertQueryResult( [ [ 'data_float' => '124.42', @@ -549,7 +549,7 @@ public function testUpdateNonTranslatableField(): void $gateway->updateNonTranslatableField($fieldGb, $newValue, $content->versionInfo->contentInfo->id); - $this->assertQueryResult( + self::assertQueryResult( [ // Both fields updated [ @@ -949,7 +949,7 @@ public function testDeleteField(): void $this->countContentFields() ); - $this->assertQueryResult( + self::assertQueryResult( [], $this->getDatabaseConnection()->createQueryBuilder() ->select('*') @@ -1076,7 +1076,7 @@ public function testSetName(): void $gateway->setName(14, 2, 'Hello world!', self::ENG_GB); $query = $this->getDatabaseConnection()->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [[self::ENG_GB, 2, 14, 4, 'Hello world!', self::ENG_GB]], $query ->select( @@ -1350,7 +1350,7 @@ public function testInsertRelation(): void $gateway = $this->getDatabaseGateway(); $gateway->insertRelation($struct); - $this->assertQueryResult( + self::assertQueryResult( [ [ 'id' => 1, @@ -1399,7 +1399,7 @@ public function testDeleteRelationWithCompositeBitmask(): void $gateway->deleteRelation(11, RelationType::COMMON->value); $query = $this->getDatabaseConnection()->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [['relation_type' => RelationType::LINK->value]], $query ->select('relation_type') @@ -1427,7 +1427,7 @@ public function testUpdateAlwaysAvailableFlagRemove(): void $connection = $this->getDatabaseConnection(); $query = $connection->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [['id' => 2]], $query ->select('language_mask') @@ -1441,7 +1441,7 @@ public function testUpdateAlwaysAvailableFlagRemove(): void ); $query = $connection->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [['language_id' => 2]], $query ->select( @@ -1463,7 +1463,7 @@ public function testUpdateAlwaysAvailableFlagRemove(): void ); $query = $connection->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [ ['language_id' => 2], ], @@ -1494,7 +1494,7 @@ public function testUpdateAlwaysAvailableFlagAdd(): void $connection = $this->getDatabaseConnection(); $expectedLanguageId = 3; - $this->assertQueryResult( + self::assertQueryResult( [['id' => $expectedLanguageId]], $connection->createQueryBuilder() ->select('language_mask') @@ -1504,7 +1504,7 @@ public function testUpdateAlwaysAvailableFlagAdd(): void $versionNo = 1; $query = $this->getDatabaseConnection()->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [ ['language_id' => $expectedLanguageId], ], @@ -1526,7 +1526,7 @@ public function testUpdateAlwaysAvailableFlagAdd(): void ); $query = $this->getDatabaseConnection()->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [ ['language_id' => $expectedLanguageId], ], @@ -1567,7 +1567,7 @@ public function testUpdateContentAddAlwaysAvailableFlagMultilingual(): void ); $gateway->updateContent(4, $contentMetadataUpdateStruct); - $this->assertQueryResult( + self::assertQueryResult( [['id' => 7]], $this->getDatabaseConnection()->createQueryBuilder()->select( 'language_mask' @@ -1616,7 +1616,7 @@ public function testUpdateContentRemoveAlwaysAvailableFlagMultilingual(): void ); $gateway->updateContent(4, $contentMetadataUpdateStruct); - $this->assertQueryResult( + self::assertQueryResult( [['id' => 6]], $this->getDatabaseConnection()->createQueryBuilder()->select( 'language_mask' @@ -1923,7 +1923,7 @@ private function assertContentVersionAttributesLanguages( array $expectation ): void { $query = $this->getDatabaseConnection()->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( $expectation, $query ->select('DISTINCT id, language_id') diff --git a/tests/lib/Persistence/Legacy/Content/Language/CachingLanguageHandlerTest.php b/tests/lib/Persistence/Legacy/Content/Language/CachingLanguageHandlerTest.php index b5bed5210d..620bff8e3a 100644 --- a/tests/lib/Persistence/Legacy/Content/Language/CachingLanguageHandlerTest.php +++ b/tests/lib/Persistence/Legacy/Content/Language/CachingLanguageHandlerTest.php @@ -256,18 +256,18 @@ public function testDelete(): void $matcher = self::exactly(2); $cacheIdentifierGeneratorMock->expects($matcher) - ->method('generateKey')->willReturnCallback(function (...$parameters) use ($matcher) { + ->method('generateKey')->willReturnCallback(static function (...$parameters) use ($matcher) { if ($matcher->numberOfInvocations() === 1) { - $this->assertSame('language', $parameters[0]); - $this->assertSame([2], $parameters[1]); - $this->assertTrue($parameters[2]); + self::assertSame('language', $parameters[0]); + self::assertSame([2], $parameters[1]); + self::assertTrue($parameters[2]); return 'ibx-la-2'; } if ($matcher->numberOfInvocations() === 2) { - $this->assertSame('language_list', $parameters[0]); - $this->assertSame([], $parameters[1]); - $this->assertTrue($parameters[2]); + self::assertSame('language_list', $parameters[0]); + self::assertSame([], $parameters[1]); + self::assertTrue($parameters[2]); return 'ibx-lal'; } diff --git a/tests/lib/Persistence/Legacy/Content/Language/Gateway/DoctrineDatabaseTest.php b/tests/lib/Persistence/Legacy/Content/Language/Gateway/DoctrineDatabaseTest.php index 80f7edec92..c8fe356351 100644 --- a/tests/lib/Persistence/Legacy/Content/Language/Gateway/DoctrineDatabaseTest.php +++ b/tests/lib/Persistence/Legacy/Content/Language/Gateway/DoctrineDatabaseTest.php @@ -41,7 +41,7 @@ public function testInsertLanguage(): void $gateway->insertLanguage($this->getLanguageFixture()); - $this->assertQueryResult( + self::assertQueryResult( [ [ 'id' => '8', @@ -82,7 +82,7 @@ public function testUpdateLanguage(): void $gateway->updateLanguage($language); - $this->assertQueryResult( + self::assertQueryResult( [ [ 'id' => '2', @@ -148,7 +148,7 @@ public function testDeleteLanguage(): void $result = $gateway->deleteLanguage(2); - $this->assertQueryResult( + self::assertQueryResult( [ [ 'count' => '1', @@ -159,7 +159,7 @@ public function testDeleteLanguage(): void ->from(Gateway::CONTENT_LANGUAGE_TABLE) ); - $this->assertQueryResult( + self::assertQueryResult( [ [ 'count' => '0', diff --git a/tests/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabaseTest.php b/tests/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabaseTest.php index 2ff5d41cb0..a86ed9bccf 100644 --- a/tests/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabaseTest.php +++ b/tests/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabaseTest.php @@ -168,7 +168,7 @@ public function testMoveSubtreePathUpdate(): void ); $query = $this->getDatabaseConnection()->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [ [65, '/1/2/', '', 1, 1, 0, 0], [67, '/1/2/77/69/', 'solutions/products', 77, 3, 0, 0], @@ -214,7 +214,7 @@ public function testMoveHiddenDestinationUpdate(): void ); $query = $this->getDatabaseConnection()->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [ [65, '/1/2/', '', 1, 1, 0, 0], [67, '/1/2/77/69/', 'solutions/products', 77, 3, 0, 1], @@ -260,7 +260,7 @@ public function testMoveHiddenSourceUpdate(): void ); $query = $this->getDatabaseConnection()->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [ [65, '/1/2/', '', 1, 1, 0, 0], [67, '/1/2/77/69/', 'solutions/products', 77, 3, 1, 1], @@ -307,7 +307,7 @@ public function testMoveHiddenSourceChildUpdate(): void ); $query = $this->getDatabaseConnection()->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [ [65, '/1/2/', '', 1, 1, 0, 0], [67, '/1/2/77/69/', 'solutions/products', 77, 3, 0, 0], @@ -342,7 +342,7 @@ public function testMoveSubtreeAssignmentUpdate(): void $gateway->updateNodeAssignment(67, 2, 77, 5); $query = $this->getDatabaseConnection()->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [ [67, 1, 0, 53, 1, 5, 77, '9cec85d730eec7578190ee95ce5a36f5', 0, 2, 1, 0, 0], ], @@ -374,7 +374,7 @@ public function testHideUpdateHidden(): void $gateway->hideSubtree('/1/2/69/'); $query = $this->getDatabaseConnection()->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [ [1, 0, 0], [2, 0, 0], @@ -398,7 +398,7 @@ public function testHideUnhideUpdateHidden(): void $gateway->unhideSubtree('/1/2/69/'); $query = $this->getDatabaseConnection()->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [ [1, 0, 0], [2, 0, 0], @@ -423,7 +423,7 @@ public function testHideUnhideParentTree(): void $gateway->unhideSubtree('/1/2/69/'); $query = $this->getDatabaseConnection()->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [ [1, 0, 0], [2, 0, 0], @@ -450,7 +450,7 @@ public function testHideUnhidePartialSubtree(): void $gateway->unhideSubtree('/1/2/69/70/'); $query = $this->getDatabaseConnection()->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [ [1, 0, 0], [2, 0, 0], @@ -474,7 +474,7 @@ public function testSwapLocations(): void $gateway->swap(70, 78); $query = $this->getDatabaseConnection()->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [ [70, 76], [78, 68], @@ -506,7 +506,7 @@ public function testCreateLocation(): void ); $query = $this->getDatabaseConnection()->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [ [70, '/1/2/69/70/'], [77, '/1/2/77/'], @@ -615,7 +615,7 @@ public function testCreateLocationValues($field, $value): void ); $query = $this->getDatabaseConnection()->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [[$value]], $query ->select($field) @@ -708,7 +708,7 @@ public function testUpdateLocation($field, $value): void ); $query = $this->getDatabaseConnection()->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [[$value]], $query ->select($field) @@ -822,7 +822,7 @@ public function testCreateLocationNodeAssignmentCreation(string $field, array $e DoctrineDatabase::NODE_ASSIGNMENT_OP_CODE_CREATE ); - $this->assertQueryResult( + self::assertQueryResult( [$expectedResult], $this->buildNodeAssignmentSelectContentWithParentQuery(68, 77, [$field]) ); @@ -849,7 +849,7 @@ public function testCreateLocationNodeAssignmentCreationMainLocation(): void DoctrineDatabase::NODE_ASSIGNMENT_OP_CODE_CREATE ); - $this->assertQueryResult( + self::assertQueryResult( [[1]], $this->buildNodeAssignmentSelectContentWithParentQuery(68, 77, ['is_main']) ); @@ -878,7 +878,7 @@ public function testUpdateLocationsContentVersionNo(): void $gateway->updateLocationsContentVersionNo(4096, 2); $query = $this->getDatabaseConnection()->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [ [2], ], @@ -903,7 +903,7 @@ public function testDeleteNodeAssignment(): void $gateway->deleteNodeAssignment(11); $query = $this->getDatabaseConnection()->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [[0]], $query ->select('count(*)') @@ -932,7 +932,7 @@ public function testDeleteNodeAssignmentWithSecondArgument(): void $gateway->deleteNodeAssignment(11, 1); $query = $this->getDatabaseConnection()->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [[$nodeAssignmentsCount - 1]], $query ->select('count(*)') @@ -1019,7 +1019,7 @@ public function testConvertNodeAssignments($field, $value): void $result = $statement->fetchAssociative(); self::assertGreaterThanOrEqual($value, $result); } else { - $this->assertQueryResult( + self::assertQueryResult( [[$value]], $query ); @@ -1054,7 +1054,7 @@ public function testConvertNodeAssignmentsMainLocation(): void $gateway->createLocationsFromNodeAssignments(68, 1); - $this->assertQueryResult( + self::assertQueryResult( [[228]], $this->buildContentTreeSelectContentWithParentQuery(68, 77, ['main_node_id']) ); @@ -1088,7 +1088,7 @@ public function testConvertNodeAssignmentsParentHidden(): void $gateway->createLocationsFromNodeAssignments(68, 1); - $this->assertQueryResult( + self::assertQueryResult( [[0, 1]], $this->buildContentTreeSelectContentWithParentQuery( 68, @@ -1126,7 +1126,7 @@ public function testConvertNodeAssignmentsParentInvisible(): void $gateway->createLocationsFromNodeAssignments(68, 1); - $this->assertQueryResult( + self::assertQueryResult( [[0, 1]], $this->buildContentTreeSelectContentWithParentQuery( 68, @@ -1160,7 +1160,7 @@ public function testConvertNodeAssignmentsUpdateAssignment(): void $gateway->createLocationsFromNodeAssignments(68, 1); - $this->assertQueryResult( + self::assertQueryResult( [[DoctrineDatabase::NODE_ASSIGNMENT_OP_CODE_CREATE_NOP]], $this->buildNodeAssignmentSelectContentWithParentQuery(68, 77, ['op_code']) ); @@ -1177,7 +1177,7 @@ public function testSetSectionForSubtree(): void $query = $this->getDatabaseConnection()->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [[68], [69]], $query ->select('id') @@ -1263,7 +1263,7 @@ public function testChangeMainLocation(): void ); $query = $connection->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [[228], [228]], $query ->select('main_node_id') @@ -1277,7 +1277,7 @@ public function testChangeMainLocation(): void ); $query = $connection->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [[1]], $query ->select('is_main') @@ -1301,7 +1301,7 @@ public function testChangeMainLocation(): void ); $query = $connection->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [[0]], $query ->select('is_main') @@ -1434,7 +1434,7 @@ public function testUpdatePathIdentificationString( $gateway->updatePathIdentificationString($locationId, $parentLocationId, $text); $query = $this->getDatabaseConnection()->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [[$expected]], $query->select( 'path_identification_string' @@ -1465,7 +1465,7 @@ public function testCreateLocationsFromNodeAssignmentsCreatesMainLocation(): voi $gateway->createLocationsFromNodeAssignments(68, 1); - $this->assertQueryResult( + self::assertQueryResult( [[68, 77, 0, 0]], $this->buildContentTreeSelectContentWithParentQuery( 68, @@ -1494,7 +1494,7 @@ public function testCreateLocationsFromNodeAssignmentsUpdatesNodeAssignmentOpcod $gateway->createLocationsFromNodeAssignments(68, 1); - $this->assertQueryResult( + self::assertQueryResult( [[DoctrineDatabase::NODE_ASSIGNMENT_OP_CODE_CREATE_NOP]], $this->buildNodeAssignmentSelectContentWithParentQuery( 68, @@ -1523,7 +1523,7 @@ public function testCreateLocationsFromNodeAssignmentsCreatesSecondaryLocation() $gateway->createLocationsFromNodeAssignments(75, 1); - $this->assertQueryResult( + self::assertQueryResult( [[75, 69]], $this->buildContentTreeSelectContentWithParentQuery( 75, @@ -1559,7 +1559,7 @@ public function testCreateLocationsFromNodeAssignmentsCreatesInvisibleLocationFo $gateway->createLocationsFromNodeAssignments(68, 1); - $this->assertQueryResult( + self::assertQueryResult( [[0, 1]], $this->buildContentTreeSelectContentWithParentQuery( 68, diff --git a/tests/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabaseTrashTest.php b/tests/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabaseTrashTest.php index fc2bcc5842..22f8d50839 100644 --- a/tests/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabaseTrashTest.php +++ b/tests/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabaseTrashTest.php @@ -41,7 +41,7 @@ public function testTrashLocation(): void $handler->trashLocation(71); $query = $this->getDatabaseConnection()->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [ [1, 0], [2, 0], @@ -62,7 +62,7 @@ public function testTrashLocationUpdateTrashTable(): void $handler->trashLocation(71); $query = $this->getDatabaseConnection()->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [ [71, '/1/2/69/70/71/'], ], @@ -105,7 +105,7 @@ public function testUntrashLocationDefault($property, $value): void $handler->untrashLocation(71); $query = $this->getDatabaseConnection()->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [[$value]], $query ->select($property) @@ -123,7 +123,7 @@ public function testUntrashLocationNewParent(): void $handler->untrashLocation(71, 1); $query = $this->getDatabaseConnection()->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [['228', '1', '/1/228/']], $query ->select('node_id', 'parent_node_id', 'path_string') @@ -379,7 +379,7 @@ public function testCleanupTrash(): void $handler->cleanupTrash(); $query = $this->getDatabaseConnection()->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [], $query ->select('*') @@ -395,7 +395,7 @@ public function testRemoveElementFromTrash(): void $handler->removeElementFromTrash(71); $query = $this->getDatabaseConnection()->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [], $query ->select('*') diff --git a/tests/lib/Persistence/Legacy/Content/ObjectState/Gateway/DoctrineDatabaseTest.php b/tests/lib/Persistence/Legacy/Content/ObjectState/Gateway/DoctrineDatabaseTest.php index ebd6fb587c..9849a7d0c8 100644 --- a/tests/lib/Persistence/Legacy/Content/ObjectState/Gateway/DoctrineDatabaseTest.php +++ b/tests/lib/Persistence/Legacy/Content/ObjectState/Gateway/DoctrineDatabaseTest.php @@ -394,7 +394,7 @@ public function testSetContentState(): void $gateway->setContentState(42, 2, 2); - $this->assertQueryResult( + self::assertQueryResult( [ [ 'contentobject_id' => 42, diff --git a/tests/lib/Persistence/Legacy/Content/Section/Gateway/DoctrineDatabaseTest.php b/tests/lib/Persistence/Legacy/Content/Section/Gateway/DoctrineDatabaseTest.php index 91e2327c82..3275a4649d 100644 --- a/tests/lib/Persistence/Legacy/Content/Section/Gateway/DoctrineDatabaseTest.php +++ b/tests/lib/Persistence/Legacy/Content/Section/Gateway/DoctrineDatabaseTest.php @@ -42,7 +42,7 @@ public function testInsertSection(): void $gateway->insertSection('New Section', 'new_section'); $query = $this->getDatabaseConnection()->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [ [ 'id' => '7', @@ -69,7 +69,7 @@ public function testUpdateSection(): void $gateway->updateSection(2, 'New Section', 'new_section'); - $this->assertQueryResult( + self::assertQueryResult( [ [ 'id' => '2', @@ -208,7 +208,7 @@ public function testDeleteSection(): void $gateway->deleteSection(2); - $this->assertQueryResult( + self::assertQueryResult( [ [ 'count' => '5', @@ -219,7 +219,7 @@ public function testDeleteSection(): void ->from(Gateway::CONTENT_SECTION_TABLE) ); - $this->assertQueryResult( + self::assertQueryResult( [ [ 'count' => '0', diff --git a/tests/lib/Persistence/Legacy/Content/Type/ContentTypeHandlerTest.php b/tests/lib/Persistence/Legacy/Content/Type/ContentTypeHandlerTest.php index d1d4803faf..f4cb258a79 100644 --- a/tests/lib/Persistence/Legacy/Content/Type/ContentTypeHandlerTest.php +++ b/tests/lib/Persistence/Legacy/Content/Type/ContentTypeHandlerTest.php @@ -1039,14 +1039,14 @@ public function testPublishNoOldType(): void $matcher = self::exactly(2); $handler->expects($matcher) ->method('load') - ->willReturnCallback(function (...$parameters) use ($matcher) { + ->willReturnCallback(static function (...$parameters) use ($matcher) { if ($matcher->numberOfInvocations() === 1) { - $this->assertSame([23, 1], $parameters); + self::assertSame([23, 1], $parameters); return new Type(); } - $this->assertSame([23, 0], $parameters); + self::assertSame([23, 0], $parameters); throw new Exception\TypeNotFound((string)23, 0); }); diff --git a/tests/lib/Persistence/Legacy/Content/Type/ContentUpdater/Action/AddFieldTest.php b/tests/lib/Persistence/Legacy/Content/Type/ContentUpdater/Action/AddFieldTest.php index 9598581a70..65e549baa8 100644 --- a/tests/lib/Persistence/Legacy/Content/Type/ContentUpdater/Action/AddFieldTest.php +++ b/tests/lib/Persistence/Legacy/Content/Type/ContentUpdater/Action/AddFieldTest.php @@ -147,12 +147,12 @@ public function testApplySingleVersionMultipleTranslations(): void ->method('insertField') ->willReturnCallback(function (...$parameters) use ($matcher, $content) { if ($matcher->numberOfInvocations() === 1) { - $this->assertEquals([$content, $this->getFieldReference(null, 1, 'eng-GB')], $parameters); + self::assertEquals([$content, $this->getFieldReference(null, 1, 'eng-GB')], $parameters); return 'fieldId1'; } - $this->assertEquals([$content, $this->getFieldReference(null, 1, 'ger-DE')], $parameters); + self::assertEquals([$content, $this->getFieldReference(null, 1, 'ger-DE')], $parameters); return 'fieldId2'; }); @@ -184,8 +184,8 @@ public function testApplyMultipleVersionsSingleTranslation(): void $this->getContentGatewayMock() ->expects($loadMatcher) ->method('load') - ->willReturnCallback(function (...$parameters) use ($loadMatcher, $contentId) { - $this->assertSame([$contentId, $loadMatcher->numberOfInvocations(), null], $parameters); + ->willReturnCallback(static function (...$parameters) use ($loadMatcher, $contentId) { + self::assertSame([$contentId, $loadMatcher->numberOfInvocations(), null], $parameters); return []; }); @@ -194,8 +194,8 @@ public function testApplyMultipleVersionsSingleTranslation(): void $this->getContentMapperMock() ->expects($extractMatcher) ->method('extractContentFromRows') - ->willReturnCallback(function (...$parameters) use ($extractMatcher, $content1, $content2) { - $this->assertSame([[], [], 'content_', null], $parameters); + ->willReturnCallback(static function (...$parameters) use ($extractMatcher, $content1, $content2) { + self::assertSame([[], [], 'content_', null], $parameters); return $extractMatcher->numberOfInvocations() === 1 ? [$content1] : [$content2]; }); @@ -206,9 +206,9 @@ public function testApplyMultipleVersionsSingleTranslation(): void ->method('insertField') ->willReturnCallback(function (...$parameters) use ($insertMatcher, $content1, $content2) { if ($insertMatcher->numberOfInvocations() === 1) { - $this->assertEquals([$content1, $this->getFieldReference(null, 1, 'eng-GB')], $parameters); + self::assertEquals([$content1, $this->getFieldReference(null, 1, 'eng-GB')], $parameters); } else { - $this->assertEquals([$content2, $this->getFieldReference('fieldId1', 2, 'eng-GB')], $parameters); + self::assertEquals([$content2, $this->getFieldReference('fieldId1', 2, 'eng-GB')], $parameters); } return 'fieldId1'; @@ -241,8 +241,8 @@ public function testApplyMultipleVersionsMultipleTranslations(): void $this->getContentGatewayMock() ->expects($loadMatcher) ->method('load') - ->willReturnCallback(function (...$parameters) use ($loadMatcher, $contentId) { - $this->assertSame([$contentId, $loadMatcher->numberOfInvocations(), null], $parameters); + ->willReturnCallback(static function (...$parameters) use ($loadMatcher, $contentId) { + self::assertSame([$contentId, $loadMatcher->numberOfInvocations(), null], $parameters); return []; }); @@ -251,8 +251,8 @@ public function testApplyMultipleVersionsMultipleTranslations(): void $this->getContentMapperMock() ->expects($extractMatcher) ->method('extractContentFromRows') - ->willReturnCallback(function (...$parameters) use ($extractMatcher, $content1, $content2) { - $this->assertSame([[], [], 'content_', null], $parameters); + ->willReturnCallback(static function (...$parameters) use ($extractMatcher, $content1, $content2) { + self::assertSame([[], [], 'content_', null], $parameters); return $extractMatcher->numberOfInvocations() === 1 ? [$content1] : [$content2]; }); @@ -264,19 +264,19 @@ public function testApplyMultipleVersionsMultipleTranslations(): void ->willReturnCallback(function (...$parameters) use ($insertMatcher, $content1, $content2) { switch ($insertMatcher->numberOfInvocations()) { case 1: - $this->assertEquals([$content1, $this->getFieldReference(null, 1, 'eng-GB')], $parameters); + self::assertEquals([$content1, $this->getFieldReference(null, 1, 'eng-GB')], $parameters); return 'fieldId1'; case 2: - $this->assertEquals([$content1, $this->getFieldReference(null, 1, 'ger-DE')], $parameters); + self::assertEquals([$content1, $this->getFieldReference(null, 1, 'ger-DE')], $parameters); return 'fieldId2'; case 3: - $this->assertEquals([$content2, $this->getFieldReference('fieldId1', 2, 'eng-GB')], $parameters); + self::assertEquals([$content2, $this->getFieldReference('fieldId1', 2, 'eng-GB')], $parameters); return 'fieldId1'; default: - $this->assertEquals([$content2, $this->getFieldReference('fieldId2', 2, 'ger-DE')], $parameters); + self::assertEquals([$content2, $this->getFieldReference('fieldId2', 2, 'ger-DE')], $parameters); return 'fieldId2'; } diff --git a/tests/lib/Persistence/Legacy/Content/Type/ContentUpdater/Action/RemoveFieldTest.php b/tests/lib/Persistence/Legacy/Content/Type/ContentUpdater/Action/RemoveFieldTest.php index 857e7fc1d3..bb2525bdd8 100644 --- a/tests/lib/Persistence/Legacy/Content/Type/ContentUpdater/Action/RemoveFieldTest.php +++ b/tests/lib/Persistence/Legacy/Content/Type/ContentUpdater/Action/RemoveFieldTest.php @@ -115,8 +115,8 @@ public function testApplyMultipleVersionsSingleTranslation(): void $this->getContentGatewayMock() ->expects($loadMatcher) ->method('load') - ->willReturnCallback(function (...$parameters) use ($loadMatcher, $contentId) { - $this->assertSame([$contentId, $loadMatcher->numberOfInvocations(), null], $parameters); + ->willReturnCallback(static function (...$parameters) use ($loadMatcher, $contentId) { + self::assertSame([$contentId, $loadMatcher->numberOfInvocations(), null], $parameters); return []; }); @@ -125,8 +125,8 @@ public function testApplyMultipleVersionsSingleTranslation(): void $this->getContentMapperMock() ->expects($extractMatcher) ->method('extractContentFromRows') - ->willReturnCallback(function (...$parameters) use ($extractMatcher, $content1, $content2) { - $this->assertSame([[], [], 'content_', null], $parameters); + ->willReturnCallback(static function (...$parameters) use ($extractMatcher, $content1, $content2) { + self::assertSame([[], [], 'content_', null], $parameters); return $extractMatcher->numberOfInvocations() === 1 ? [$content1] : [$content2]; }); @@ -140,11 +140,11 @@ public function testApplyMultipleVersionsSingleTranslation(): void $this->getContentStorageHandlerMock() ->expects($deleteFieldDataMatcher) ->method('deleteFieldData') - ->willReturnCallback(function (...$parameters) use ($deleteFieldDataMatcher, $content1, $content2, $fieldId) { + ->willReturnCallback(static function (...$parameters) use ($deleteFieldDataMatcher, $content1, $content2, $fieldId) { $expectedVersionInfo = $deleteFieldDataMatcher->numberOfInvocations() === 1 ? $content1->versionInfo : $content2->versionInfo; - $this->assertSame(['ibexa_string', $expectedVersionInfo, [$fieldId]], $parameters); + self::assertSame(['ibexa_string', $expectedVersionInfo, [$fieldId]], $parameters); }); $action->apply($contentId); @@ -176,8 +176,8 @@ public function testApplyMultipleVersionsMultipleTranslations(): void $this->getContentGatewayMock() ->expects($loadMatcher) ->method('load') - ->willReturnCallback(function (...$parameters) use ($loadMatcher, $contentId) { - $this->assertSame([$contentId, $loadMatcher->numberOfInvocations(), null], $parameters); + ->willReturnCallback(static function (...$parameters) use ($loadMatcher, $contentId) { + self::assertSame([$contentId, $loadMatcher->numberOfInvocations(), null], $parameters); return []; }); @@ -186,8 +186,8 @@ public function testApplyMultipleVersionsMultipleTranslations(): void $this->getContentMapperMock() ->expects($extractMatcher) ->method('extractContentFromRows') - ->willReturnCallback(function (...$parameters) use ($extractMatcher, $content1, $content2) { - $this->assertSame([[], [], 'content_', null], $parameters); + ->willReturnCallback(static function (...$parameters) use ($extractMatcher, $content1, $content2) { + self::assertSame([[], [], 'content_', null], $parameters); return $extractMatcher->numberOfInvocations() === 1 ? [$content1] : [$content2]; }); @@ -196,20 +196,20 @@ public function testApplyMultipleVersionsMultipleTranslations(): void $this->getContentGatewayMock() ->expects($deleteFieldMatcher) ->method('deleteField') - ->willReturnCallback(function (...$parameters) use ($deleteFieldMatcher, $fieldId1, $fieldId2) { + ->willReturnCallback(static function (...$parameters) use ($deleteFieldMatcher, $fieldId1, $fieldId2) { $expected = $deleteFieldMatcher->numberOfInvocations() === 1 ? $fieldId1 : $fieldId2; - $this->assertSame([$expected], $parameters); + self::assertSame([$expected], $parameters); }); $deleteFieldDataMatcher = self::exactly(2); $this->getContentStorageHandlerMock() ->expects($deleteFieldDataMatcher) ->method('deleteFieldData') - ->willReturnCallback(function (...$parameters) use ($deleteFieldDataMatcher, $content1, $content2, $fieldId1, $fieldId2) { + ->willReturnCallback(static function (...$parameters) use ($deleteFieldDataMatcher, $content1, $content2, $fieldId1, $fieldId2) { $expectedVersionInfo = $deleteFieldDataMatcher->numberOfInvocations() === 1 ? $content1->versionInfo : $content2->versionInfo; - $this->assertSame(['ibexa_string', $expectedVersionInfo, [$fieldId1, $fieldId2]], $parameters); + self::assertSame(['ibexa_string', $expectedVersionInfo, [$fieldId1, $fieldId2]], $parameters); }); $this->getContentGatewayMock() diff --git a/tests/lib/Persistence/Legacy/Content/Type/ContentUpdaterTest.php b/tests/lib/Persistence/Legacy/Content/Type/ContentUpdaterTest.php index 4c509f10a1..892a1a8225 100644 --- a/tests/lib/Persistence/Legacy/Content/Type/ContentUpdaterTest.php +++ b/tests/lib/Persistence/Legacy/Content/Type/ContentUpdaterTest.php @@ -111,8 +111,8 @@ public function testApplyUpdates(): void $actionAMatcher = self::exactly(2); $actionA->expects($actionAMatcher) ->method('apply') - ->willReturnCallback(function (...$parameters) use ($actionAMatcher) { - $this->assertSame([$actionAMatcher->numberOfInvocations() === 1 ? 11 : 22], $parameters); + ->willReturnCallback(static function (...$parameters) use ($actionAMatcher) { + self::assertSame([$actionAMatcher->numberOfInvocations() === 1 ? 11 : 22], $parameters); }); $actionB = $this->getMockForAbstractClass( Action::class, @@ -123,8 +123,8 @@ public function testApplyUpdates(): void $actionBMatcher = self::exactly(2); $actionB->expects($actionBMatcher) ->method('apply') - ->willReturnCallback(function (...$parameters) use ($actionBMatcher) { - $this->assertSame([$actionBMatcher->numberOfInvocations() === 1 ? 11 : 22], $parameters); + ->willReturnCallback(static function (...$parameters) use ($actionBMatcher) { + self::assertSame([$actionBMatcher->numberOfInvocations() === 1 ? 11 : 22], $parameters); }); $actions = [$actionA, $actionB]; diff --git a/tests/lib/Persistence/Legacy/Content/Type/Gateway/DoctrineDatabaseTest.php b/tests/lib/Persistence/Legacy/Content/Type/Gateway/DoctrineDatabaseTest.php index 8ddc307ec5..6320226fa2 100644 --- a/tests/lib/Persistence/Legacy/Content/Type/Gateway/DoctrineDatabaseTest.php +++ b/tests/lib/Persistence/Legacy/Content/Type/Gateway/DoctrineDatabaseTest.php @@ -46,7 +46,7 @@ public function testInsertGroup(): void $id = $gateway->insertGroup($group); - $this->assertQueryResult( + self::assertQueryResult( [ [ 'id' => '1', @@ -108,7 +108,7 @@ public function testUpdateGroup(): void $res = $gateway->updateGroup($struct); - $this->assertQueryResult( + self::assertQueryResult( [ ['4'], ], @@ -129,7 +129,7 @@ public function testUpdateGroup(): void ) ->from(Gateway::CONTENT_TYPE_GROUP_TABLE) ->orderBy('id'); - $this->assertQueryResult( + self::assertQueryResult( [ [ 'id' => 1, @@ -239,7 +239,7 @@ public function testDeleteGroup(): void $gateway->deleteGroup(2); - $this->assertQueryResult( + self::assertQueryResult( [ ['1'], ['3'], @@ -446,7 +446,7 @@ public function testInsertType($column, $expectation): void $gateway->insertType($type); - $this->assertQueryResult( + self::assertQueryResult( [[$expectation]], $this->getDatabaseConnection()->createQueryBuilder() ->select($column) @@ -478,7 +478,7 @@ public function testInsertTypeContentClassName($column, $expectation): void $gateway->insertType($type); - $this->assertQueryResult( + self::assertQueryResult( array_map( static function ($value) { return [$value]; @@ -540,7 +540,7 @@ public function testInsertFieldDefinition(): void $gateway->insertFieldDefinition(23, 1, $field, $storageField); - $this->assertQueryResult( + self::assertQueryResult( [ [ 'content_type_id' => '23', @@ -679,7 +679,7 @@ public function testDeleteFieldDefinition(): void $gateway->deleteFieldDefinition(1, 0, 119); - $this->assertQueryResult( + self::assertQueryResult( [[5]], $this->getDatabaseConnection()->createQueryBuilder() ->select('COUNT(*)') @@ -699,7 +699,7 @@ public function testUpdateFieldDefinition(): void $gateway = $this->getGateway(); $gateway->updateFieldDefinition(2, 0, $fieldDefinitionFixture, $storageFieldDefinitionFixture); - $this->assertQueryResult( + self::assertQueryResult( [ // "random" sample [ @@ -769,7 +769,7 @@ public function testInsertGroupAssignment(): void $gateway->insertGroupAssignment(3, 42, 1); - $this->assertQueryResult( + self::assertQueryResult( [ [ 'content_type_id' => '42', @@ -798,7 +798,7 @@ public function testDeleteGroupAssignment(): void $gateway->deleteGroupAssignment(1, 1, 0); - $this->assertQueryResult( + self::assertQueryResult( [['1']], $this->getDatabaseConnection()->createQueryBuilder() ->select( @@ -821,7 +821,7 @@ public function testUpdateType($fieldName, $expectedValue): void $gateway->updateType(1, 0, $type); - $this->assertQueryResult( + self::assertQueryResult( [ [ $fieldName => $expectedValue, @@ -848,7 +848,7 @@ public function testUpdateTypeName(): void $gateway->updateType(1, 0, $type); - $this->assertQueryResult( + self::assertQueryResult( [ [ 'content_type_id' => 1, @@ -982,7 +982,7 @@ public function testDeleteFieldDefinitionsForTypeExisting(): void ) ); // 1 left with version 1 - $this->assertQueryResult( + self::assertQueryResult( [[1]], $countAffectedAttr ); @@ -991,7 +991,7 @@ public function testDeleteFieldDefinitionsForTypeExisting(): void $countNotAffectedAttr->select('COUNT(*)') ->from(Gateway::FIELD_DEFINITION_TABLE); - $this->assertQueryResult( + self::assertQueryResult( [[2]], $countNotAffectedAttr ); @@ -1011,7 +1011,7 @@ public function testDeleteFieldDefinitionsForTypeNotExisting(): void $countNotAffectedAttr->select('COUNT(*)') ->from(Gateway::FIELD_DEFINITION_TABLE); - $this->assertQueryResult( + self::assertQueryResult( [[5]], $countNotAffectedAttr ); @@ -1031,7 +1031,7 @@ public function testDeleteGroupAssignmentsForTypeExisting(): void $countAffectedAttr->select('COUNT(*)') ->from(Gateway::CONTENT_TYPE_TO_GROUP_ASSIGNMENT_TABLE); - $this->assertQueryResult( + self::assertQueryResult( [[2]], $countAffectedAttr ); @@ -1051,7 +1051,7 @@ public function testDeleteGroupAssignmentsForTypeNotExisting(): void $countAffectedAttr->select('COUNT(*)') ->from(Gateway::CONTENT_TYPE_TO_GROUP_ASSIGNMENT_TABLE); - $this->assertQueryResult( + self::assertQueryResult( [[3]], $countAffectedAttr ); @@ -1071,7 +1071,7 @@ public function testDeleteTypeExisting(): void $countAffectedAttr->select('COUNT(*)') ->from(Gateway::CONTENT_TYPE_TABLE); - $this->assertQueryResult( + self::assertQueryResult( [[1]], $countAffectedAttr ); @@ -1091,7 +1091,7 @@ public function testDeleteTypeNotExisting(): void $countAffectedAttr->select('COUNT(*)') ->from(Gateway::CONTENT_TYPE_TABLE); - $this->assertQueryResult( + self::assertQueryResult( [[2]], $countAffectedAttr ); @@ -1106,7 +1106,7 @@ public function testPublishTypeAndFields(): void $gateway = $this->getGateway(); $gateway->publishTypeAndFields(1, 1, 0); - $this->assertQueryResult( + self::assertQueryResult( [[1]], $this->getDatabaseConnection()->createQueryBuilder() ->select('COUNT( * )') @@ -1114,7 +1114,7 @@ public function testPublishTypeAndFields(): void ->where('id = 1 AND status = 0') ); - $this->assertQueryResult( + self::assertQueryResult( [[2]], $this->getDatabaseConnection()->createQueryBuilder() ->select('COUNT( * )') @@ -1122,7 +1122,7 @@ public function testPublishTypeAndFields(): void ->where('content_type_id = 1 AND content_type_status = 0') ); - $this->assertQueryResult( + self::assertQueryResult( [[3]], $this->getDatabaseConnection()->createQueryBuilder() ->select('COUNT( * )') @@ -1130,7 +1130,7 @@ public function testPublishTypeAndFields(): void ->where('content_type_id = 1 AND status = 0') ); - $this->assertQueryResult( + self::assertQueryResult( [[1]], $this->getDatabaseConnection()->createQueryBuilder() ->select('COUNT( * )') diff --git a/tests/lib/Persistence/Legacy/Filter/SortClauseQueryBuilder/Location/Bookmark/IdSortClauseQueryBuilderTest.php b/tests/lib/Persistence/Legacy/Filter/SortClauseQueryBuilder/Location/Bookmark/IdSortClauseQueryBuilderTest.php index 89cd5240e7..d6ee1c30d9 100644 --- a/tests/lib/Persistence/Legacy/Filter/SortClauseQueryBuilder/Location/Bookmark/IdSortClauseQueryBuilderTest.php +++ b/tests/lib/Persistence/Legacy/Filter/SortClauseQueryBuilder/Location/Bookmark/IdSortClauseQueryBuilderTest.php @@ -36,7 +36,7 @@ final class IdSortClauseQueryBuilderTest extends TestCase */ public function testBuildQueryInLocationFilteringContext(): void { - $queryBuilder = $this->createLocationFilteringQueryBuilder(); + $queryBuilder = self::createLocationFilteringQueryBuilder(); $builder = $this->createBuilder(); $sortClause = new Id(Query::SORT_DESC); @@ -77,7 +77,7 @@ public function testBuildQueryInLocationFilteringContext(): void */ public function testBuildQueryInContentFilteringContext(): void { - $queryBuilder = $this->createContentFilteringQueryBuilder(); + $queryBuilder = self::createContentFilteringQueryBuilder(); $this->createBuilder()->buildQuery($queryBuilder, new Id(Query::SORT_DESC)); diff --git a/tests/lib/Persistence/Legacy/User/Gateway/DoctrineDatabaseTest.php b/tests/lib/Persistence/Legacy/User/Gateway/DoctrineDatabaseTest.php index 38cd26aa42..8c24465080 100644 --- a/tests/lib/Persistence/Legacy/User/Gateway/DoctrineDatabaseTest.php +++ b/tests/lib/Persistence/Legacy/User/Gateway/DoctrineDatabaseTest.php @@ -43,7 +43,7 @@ public function testRemoveRoleByAssignmentId(): void $gateway->removeRoleAssignmentById(38); $query = $this->getDatabaseConnection()->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [ [ 'contentobject_id' => '11', diff --git a/tests/lib/Persistence/Legacy/User/Role/Gateway/DoctrineDatabaseTest.php b/tests/lib/Persistence/Legacy/User/Role/Gateway/DoctrineDatabaseTest.php index 96ce017ed2..86c31054b9 100644 --- a/tests/lib/Persistence/Legacy/User/Role/Gateway/DoctrineDatabaseTest.php +++ b/tests/lib/Persistence/Legacy/User/Role/Gateway/DoctrineDatabaseTest.php @@ -53,7 +53,7 @@ public function testCreateRole(): void $gateway->createRole($spiRole); $query = $this->getDatabaseConnection()->createQueryBuilder(); - $this->assertQueryResult( + self::assertQueryResult( [ [ 'id' => '6', diff --git a/tests/lib/Persistence/Legacy/User/UserHandlerTest.php b/tests/lib/Persistence/Legacy/User/UserHandlerTest.php index 05566c107c..080f959ec6 100644 --- a/tests/lib/Persistence/Legacy/User/UserHandlerTest.php +++ b/tests/lib/Persistence/Legacy/User/UserHandlerTest.php @@ -291,7 +291,7 @@ public function testUpdateUserToken(): void $handler->updateUserToken($this->getValidUserToken(1234567890)); - $this->assertQueryResult( + self::assertQueryResult( [['0800fc577294c34e0b28ad2839435945', 1, 1234567890, self::TEST_USER_ID]], $this->getDatabaseConnection()->createQueryBuilder()->select( 'hash_key', @@ -304,7 +304,7 @@ public function testUpdateUserToken(): void $handler->updateUserToken($this->getValidUserToken(2234567890)); - $this->assertQueryResult( + self::assertQueryResult( [['0800fc577294c34e0b28ad2839435945', 1, 2234567890, self::TEST_USER_ID]], $this->getDatabaseConnection()->createQueryBuilder()->select( 'hash_key', @@ -322,7 +322,7 @@ public function testExpireUserToken(): void $handler->updateUserToken($userToken = $this->getValidUserToken(1234567890)); - $this->assertQueryResult( + self::assertQueryResult( [['0800fc577294c34e0b28ad2839435945', 1, 1234567890, self::TEST_USER_ID]], $this->getDatabaseConnection()->createQueryBuilder()->select( 'hash_key', @@ -335,7 +335,7 @@ public function testExpireUserToken(): void $handler->expireUserToken($userToken->hashKey); - $this->assertQueryResult( + self::assertQueryResult( [['0800fc577294c34e0b28ad2839435945', 1, 0, self::TEST_USER_ID]], $this->getDatabaseConnection()->createQueryBuilder()->select( 'hash_key', @@ -384,7 +384,7 @@ public function testCreateNewRoleWithoutPolicies(): void $handler->createRole($createStruct); - $this->assertQueryResult( + self::assertQueryResult( [[1, 'Test', -1]], $this->getDatabaseConnection()->createQueryBuilder()->select( 'id', @@ -408,7 +408,7 @@ public function testCreateRoleDraftWithoutPolicies(): void $handler->createRoleDraft($roleDraft->id); $publishedRoleId = 1; - $this->assertQueryResult( + self::assertQueryResult( [ [$publishedRoleId, 'Test', APIRole::STATUS_DEFINED], [2, 'Test', $publishedRoleId], @@ -593,7 +593,7 @@ public function testUpdateRole(): void $handler->updateRole($update); - $this->assertQueryResult( + self::assertQueryResult( [[1, 'Changed']], $this->getDatabaseConnection()->createQueryBuilder()->select('id', 'name')->from(Gateway::ROLE_TABLE), 'Expected a changed role.' @@ -608,19 +608,19 @@ public function testDeleteRole(): void // 3 is the ID of Editor role $handler->deleteRole(3); - $this->assertQueryResult( + self::assertQueryResult( [], $this->getDatabaseConnection()->createQueryBuilder()->select('id')->from(Gateway::ROLE_TABLE)->where('id = 3'), 'Expected an empty set.' ); - $this->assertQueryResult( + self::assertQueryResult( [], $this->getDatabaseConnection()->createQueryBuilder()->select('role_id')->from(Gateway::POLICY_TABLE)->where('role_id = 3'), 'Expected an empty set.' ); - $this->assertQueryResult( + self::assertQueryResult( [], $this->getDatabaseConnection()->createQueryBuilder()->select('role_id')->from(Gateway::USER_ROLE_TABLE)->where('role_id = 3'), 'Expected an empty set.' @@ -636,19 +636,19 @@ public function testDeleteRoleDraft(): void $roleDraft = $handler->createRoleDraft(3); $handler->deleteRole($roleDraft->id, APIRole::STATUS_DRAFT); - $this->assertQueryResult( + self::assertQueryResult( [['3', APIRole::STATUS_DEFINED]], $this->getDatabaseConnection()->createQueryBuilder()->select('id, version')->from(Gateway::ROLE_TABLE)->where('id = 3'), 'Expected a published role.' ); - $this->assertQueryResult( + self::assertQueryResult( [[implode("\n", array_fill(0, 28, '3, ' . APIRole::STATUS_DEFINED))]], $this->getDatabaseConnection()->createQueryBuilder()->select('role_id, original_id')->from(Gateway::POLICY_TABLE)->where('role_id = 3'), 'Expected 28 policies for the published role.' ); - $this->assertQueryResult( + self::assertQueryResult( [[3], [3]], $this->getDatabaseConnection()->createQueryBuilder()->select('role_id')->from(Gateway::USER_ROLE_TABLE)->where('role_id = 3'), 'Expected that role assignments still exist.' @@ -667,7 +667,7 @@ public function testAddPolicyToRoleLimitations(): void $handler->addPolicy($role->id, $policy); - $this->assertQueryResult( + self::assertQueryResult( [[1, 'foo', 'bar', 1]], $this->getDatabaseConnection()->createQueryBuilder()->select('id', 'module_name', 'function_name', 'role_id')->from(Gateway::POLICY_TABLE), 'Expected a new policy.' @@ -693,7 +693,7 @@ public function testAddPolicyLimitations(): void { $this->createTestRoleWithTestPolicy(); - $this->assertQueryResult( + self::assertQueryResult( [ [1, 'Subtree', 1], [2, 'Foo', 1], @@ -707,7 +707,7 @@ public function testAddPolicyLimitationValues(): void { $this->createTestRoleWithTestPolicy(); - $this->assertQueryResult( + self::assertQueryResult( [ [1, '/1', 1], [2, '/1/2', 1], @@ -748,7 +748,7 @@ public function testImplicitlyCreatePolicies(): void { $this->createRole(); - $this->assertQueryResult( + self::assertQueryResult( [ [1, 'foo', 'bar', 1], [2, 'foo', 'blubb', 1], @@ -766,7 +766,7 @@ public function testDeletePolicy(): void $handler->publishRoleDraft($roleDraft->id); $handler->deletePolicy($roleDraft->policies[0]->id, $roleDraft->policies[0]->roleId); - $this->assertQueryResult( + self::assertQueryResult( [ [2, 'foo', 'blubb', 1], ], @@ -782,7 +782,7 @@ public function testDeletePolicyLimitations(): void $roleDraft = $this->createRole(); $handler->deletePolicy($roleDraft->policies[0]->id, $roleDraft->policies[0]->roleId); - $this->assertQueryResult( + self::assertQueryResult( [[3, 'Foo', 2]], $this->getDatabaseConnection()->createQueryBuilder()->select('*')->from(Gateway::POLICY_LIMITATION_TABLE) ); @@ -795,7 +795,7 @@ public function testDeletePolicyLimitationValues(): void $roleDraft = $this->createRole(); $handler->deletePolicy($roleDraft->policies[0]->id, $roleDraft->policies[0]->roleId); - $this->assertQueryResult( + self::assertQueryResult( [[4, 3, 'Blubb']], $this->getDatabaseConnection()->createQueryBuilder()->select('*')->from(Gateway::POLICY_LIMITATION_VALUE_TABLE) ); @@ -814,7 +814,7 @@ public function testUpdatePolicies(): void $handler->updatePolicy($policy); - $this->assertQueryResult( + self::assertQueryResult( [ [3, 'Foo', 2], [4, 'new', 1], @@ -822,7 +822,7 @@ public function testUpdatePolicies(): void $this->getDatabaseConnection()->createQueryBuilder()->select('*')->from(Gateway::POLICY_LIMITATION_TABLE) ); - $this->assertQueryResult( + self::assertQueryResult( [ [4, 3, 'Blubb'], [5, 4, 'something'], @@ -842,7 +842,7 @@ public function testAddRoleToUser(): void $handler->assignRole($user->id, $role->id, []); - $this->assertQueryResult( + self::assertQueryResult( [ [1, self::TEST_USER_ID, 1, null, null], ], @@ -868,7 +868,7 @@ public function testAddRoleToUserWithLimitation(): void ] ); - $this->assertQueryResult( + self::assertQueryResult( [ [1, self::TEST_USER_ID, 1, 'Subtree', '/1'], ], @@ -895,7 +895,7 @@ public function testAddRoleToUserWithComplexLimitation(): void ] ); - $this->assertQueryResult( + self::assertQueryResult( [ [1, self::TEST_USER_ID, 1, 'Subtree', '/1'], [2, self::TEST_USER_ID, 1, 'Subtree', '/1/2'], @@ -926,7 +926,7 @@ public function testRemoveUserRoleAssociation(): void $handler->unassignRole($user->id, $role->id); - $this->assertQueryResult( + self::assertQueryResult( [], $this->getDatabaseConnection()->createQueryBuilder()->select('id', 'contentobject_id', 'role_id', 'limit_identifier', 'limit_value')->from(Gateway::USER_ROLE_TABLE), 'Expected no user policy associations.' diff --git a/tests/lib/QueryType/BuiltIn/AbstractQueryTypeTestCase.php b/tests/lib/QueryType/BuiltIn/AbstractQueryTypeTestCase.php index b84aa54265..1bcc5a76f7 100644 --- a/tests/lib/QueryType/BuiltIn/AbstractQueryTypeTestCase.php +++ b/tests/lib/QueryType/BuiltIn/AbstractQueryTypeTestCase.php @@ -76,7 +76,7 @@ final public function testGetName(): void { self::assertEquals( $this->getExpectedName(), - $this->queryType->getName() + $this->queryType::getName() ); } diff --git a/tests/lib/QueryType/BuiltIn/SortSpec/SortClauseParser/FieldSortClauseParserTest.php b/tests/lib/QueryType/BuiltIn/SortSpec/SortClauseParser/FieldSortClauseParserTest.php index e6f1652df5..7b0bb97a40 100644 --- a/tests/lib/QueryType/BuiltIn/SortSpec/SortClauseParser/FieldSortClauseParserTest.php +++ b/tests/lib/QueryType/BuiltIn/SortSpec/SortClauseParser/FieldSortClauseParserTest.php @@ -31,21 +31,21 @@ protected function setUp(): void public function testParse(): void { $parser = $this->createMock(SortSpecParserInterface::class); - $matcher = $this->exactly(3); + $matcher = self::exactly(3); $parser->expects($matcher) - ->method('match')->willReturnCallback(function (...$parameters) use ($matcher) { + ->method('match')->willReturnCallback(static function (...$parameters) use ($matcher) { if ($matcher->numberOfInvocations() === 1) { - $this->assertSame(Token::TYPE_ID, $parameters[0]); + self::assertSame(Token::TYPE_ID, $parameters[0]); return new Token(Token::TYPE_ID, self::EXAMPLE_CONTENT_TYPE_ID); } if ($matcher->numberOfInvocations() === 2) { - $this->assertSame(Token::TYPE_DOT, $parameters[0]); + self::assertSame(Token::TYPE_DOT, $parameters[0]); return new Token(Token::TYPE_DOT); } if ($matcher->numberOfInvocations() === 3) { - $this->assertSame(Token::TYPE_ID, $parameters[0]); + self::assertSame(Token::TYPE_ID, $parameters[0]); return new Token(Token::TYPE_ID, self::EXAMPLE_FIELD_ID); } diff --git a/tests/lib/QueryType/BuiltIn/SortSpec/SortClauseParser/MapDistanceSortClauseParserTest.php b/tests/lib/QueryType/BuiltIn/SortSpec/SortClauseParser/MapDistanceSortClauseParserTest.php index 1755e42758..ebe7d89bd1 100644 --- a/tests/lib/QueryType/BuiltIn/SortSpec/SortClauseParser/MapDistanceSortClauseParserTest.php +++ b/tests/lib/QueryType/BuiltIn/SortSpec/SortClauseParser/MapDistanceSortClauseParserTest.php @@ -33,31 +33,31 @@ protected function setUp(): void public function testParse(): void { $parser = $this->createMock(SortSpecParserInterface::class); - $matcher = $this->exactly(5); + $matcher = self::exactly(5); $parser->expects($matcher) - ->method('match')->willReturnCallback(function (...$parameters) use ($matcher) { + ->method('match')->willReturnCallback(static function (...$parameters) use ($matcher) { if ($matcher->numberOfInvocations() === 1) { - $this->assertSame(Token::TYPE_ID, $parameters[0]); + self::assertSame(Token::TYPE_ID, $parameters[0]); return new Token(Token::TYPE_ID, self::EXAMPLE_CONTENT_TYPE_ID); } if ($matcher->numberOfInvocations() === 2) { - $this->assertSame(Token::TYPE_DOT, $parameters[0]); + self::assertSame(Token::TYPE_DOT, $parameters[0]); return new Token(Token::TYPE_DOT); } if ($matcher->numberOfInvocations() === 3) { - $this->assertSame(Token::TYPE_ID, $parameters[0]); + self::assertSame(Token::TYPE_ID, $parameters[0]); return new Token(Token::TYPE_ID, self::EXAMPLE_FIELD_ID); } if ($matcher->numberOfInvocations() === 4) { - $this->assertSame(Token::TYPE_FLOAT, $parameters[0]); + self::assertSame(Token::TYPE_FLOAT, $parameters[0]); return new Token(Token::TYPE_FLOAT, (string)self::EXAMPLE_LAT); } if ($matcher->numberOfInvocations() === 5) { - $this->assertSame(Token::TYPE_FLOAT, $parameters[0]); + self::assertSame(Token::TYPE_FLOAT, $parameters[0]); return new Token(Token::TYPE_FLOAT, (string)self::EXAMPLE_LON); } diff --git a/tests/lib/Repository/Mapper/ContentLocationMapper/DecoratedLocationServiceTest.php b/tests/lib/Repository/Mapper/ContentLocationMapper/DecoratedLocationServiceTest.php index edbe7189c1..28a79793f6 100644 --- a/tests/lib/Repository/Mapper/ContentLocationMapper/DecoratedLocationServiceTest.php +++ b/tests/lib/Repository/Mapper/ContentLocationMapper/DecoratedLocationServiceTest.php @@ -87,14 +87,14 @@ public function testLoadLocationList(): void $this->mapper ->expects($matcher) - ->method('setMapping')->willReturnCallback(function (...$parameters) use ($matcher) { + ->method('setMapping')->willReturnCallback(static function (...$parameters) use ($matcher) { if ($matcher->numberOfInvocations() === 1) { - $this->assertSame(1, $parameters[0]); - $this->assertSame(2, $parameters[1]); + self::assertSame(1, $parameters[0]); + self::assertSame(2, $parameters[1]); } if ($matcher->numberOfInvocations() === 2) { - $this->assertSame(3, $parameters[0]); - $this->assertSame(4, $parameters[1]); + self::assertSame(3, $parameters[0]); + self::assertSame(4, $parameters[1]); } }); @@ -139,14 +139,14 @@ public function testLoadLocations(): void $this->mapper ->expects($matcher) - ->method('setMapping')->willReturnCallback(function (...$parameters) use ($matcher) { + ->method('setMapping')->willReturnCallback(static function (...$parameters) use ($matcher) { if ($matcher->numberOfInvocations() === 1) { - $this->assertSame(1, $parameters[0]); - $this->assertSame(2, $parameters[1]); + self::assertSame(1, $parameters[0]); + self::assertSame(2, $parameters[1]); } if ($matcher->numberOfInvocations() === 2) { - $this->assertSame(3, $parameters[0]); - $this->assertSame(4, $parameters[1]); + self::assertSame(3, $parameters[0]); + self::assertSame(4, $parameters[1]); } }); @@ -193,14 +193,14 @@ public function testLoadLocationChildren(): void $this->mapper ->expects($matcher) - ->method('setMapping')->willReturnCallback(function (...$parameters) use ($matcher) { + ->method('setMapping')->willReturnCallback(static function (...$parameters) use ($matcher) { if ($matcher->numberOfInvocations() === 1) { - $this->assertSame(1, $parameters[0]); - $this->assertSame(2, $parameters[1]); + self::assertSame(1, $parameters[0]); + self::assertSame(2, $parameters[1]); } if ($matcher->numberOfInvocations() === 2) { - $this->assertSame(3, $parameters[0]); - $this->assertSame(4, $parameters[1]); + self::assertSame(3, $parameters[0]); + self::assertSame(4, $parameters[1]); } }); @@ -241,14 +241,14 @@ public function testLoadAllLocations(): void $this->mapper ->expects($matcher) - ->method('setMapping')->willReturnCallback(function (...$parameters) use ($matcher) { + ->method('setMapping')->willReturnCallback(static function (...$parameters) use ($matcher) { if ($matcher->numberOfInvocations() === 1) { - $this->assertSame(1, $parameters[0]); - $this->assertSame(2, $parameters[1]); + self::assertSame(1, $parameters[0]); + self::assertSame(2, $parameters[1]); } if ($matcher->numberOfInvocations() === 2) { - $this->assertSame(3, $parameters[0]); - $this->assertSame(4, $parameters[1]); + self::assertSame(3, $parameters[0]); + self::assertSame(4, $parameters[1]); } }); diff --git a/tests/lib/Repository/Service/Mock/BookmarkTest.php b/tests/lib/Repository/Service/Mock/BookmarkTest.php index 810b3dbeb3..76de78bd2a 100644 --- a/tests/lib/Repository/Service/Mock/BookmarkTest.php +++ b/tests/lib/Repository/Service/Mock/BookmarkTest.php @@ -68,9 +68,9 @@ public function testCreateBookmark(): void $this->bookmarkHandler ->expects($this->once()) ->method('create') - ->willReturnCallback(function (CreateStruct $createStruct) { - $this->assertEquals(self::LOCATION_ID, $createStruct->locationId); - $this->assertEquals(self::CURRENT_USER_ID, $createStruct->userId); + ->willReturnCallback(static function (CreateStruct $createStruct) { + self::assertEquals(self::LOCATION_ID, $createStruct->locationId); + self::assertEquals(self::CURRENT_USER_ID, $createStruct->userId); return new Bookmark(); }); diff --git a/tests/lib/Repository/Service/Mock/ContentTest.php b/tests/lib/Repository/Service/Mock/ContentTest.php index 3dc9f011d8..282ae4ad31 100644 --- a/tests/lib/Repository/Service/Mock/ContentTest.php +++ b/tests/lib/Repository/Service/Mock/ContentTest.php @@ -1300,7 +1300,6 @@ protected function assertForTestCreateContentNonRedundantFieldSet( $repositoryMock->expects(self::once())->method('beginTransaction'); - $that = $this; $permissionResolverMock->expects(self::once()) ->method('canUser') ->with( @@ -1310,15 +1309,15 @@ protected function assertForTestCreateContentNonRedundantFieldSet( self::equalTo($locationCreateStructs) )->will( self::returnCallback( - static function () use ($that, $contentCreateStruct): bool { - $that->assertEquals($contentCreateStruct, func_get_arg(2)); + static function () use ($contentCreateStruct): bool { + self::assertEquals($contentCreateStruct, func_get_arg(2)); return true; } ) ); - $this->getUniqueHashDomainMapperMock($domainMapperMock, $that, $contentCreateStruct); + $this->getUniqueHashDomainMapperMock($domainMapperMock, $contentCreateStruct); $this->acceptFieldTypeValueMock($fieldTypeMock); $this->toHashFieldTypeMock($fieldTypeMock); @@ -1916,7 +1915,6 @@ static function ($languageCode) { ->method('getContentTypeService') ->will(self::returnValue($contentTypeServiceMock)); - $that = $this; $permissionResolver->expects(self::any()) ->method('canUser') ->with( @@ -1926,8 +1924,8 @@ static function ($languageCode) { self::equalTo([]) )->will( self::returnCallback( - static function () use ($that, $contentCreateStruct): bool { - $that->assertEquals($contentCreateStruct, func_get_arg(2)); + static function () use ($contentCreateStruct): bool { + self::assertEquals($contentCreateStruct, func_get_arg(2)); return true; } @@ -1939,8 +1937,8 @@ static function () use ($that, $contentCreateStruct): bool { ->with(self::isInstanceOf(APIContentCreateStruct::class)) ->will( self::returnCallback( - static function ($object) use ($that, $contentCreateStruct): string { - $that->assertEquals($contentCreateStruct, $object); + static function ($object) use ($contentCreateStruct): string { + self::assertEquals($contentCreateStruct, $object); return 'hash'; } @@ -2197,7 +2195,6 @@ protected function assertForTestCreateContentRequiredField( $contentType ); - $that = $this; $permissionResolver->expects(self::once()) ->method('canUser') ->with( @@ -2207,15 +2204,15 @@ protected function assertForTestCreateContentRequiredField( self::equalTo([]) )->will( self::returnCallback( - static function () use ($that, $contentCreateStruct): bool { - $that->assertEquals($contentCreateStruct, func_get_arg(2)); + static function () use ($contentCreateStruct): bool { + self::assertEquals($contentCreateStruct, func_get_arg(2)); return true; } ) ); - $this->getUniqueHashDomainMapperMock($domainMapperMock, $that, $contentCreateStruct); + $this->getUniqueHashDomainMapperMock($domainMapperMock, $contentCreateStruct); $this->acceptFieldTypeValueMock($fieldTypeMock); $this->toHashFieldTypeMock($fieldTypeMock); @@ -2349,7 +2346,6 @@ protected function assertForTestCreateContentThrowsContentFieldValidationExcepti $contentType ); - $that = $this; $permissionResolver->expects(self::once()) ->method('canUser') ->with( @@ -2359,15 +2355,15 @@ protected function assertForTestCreateContentThrowsContentFieldValidationExcepti self::equalTo([]) )->will( self::returnCallback( - static function () use ($that, $contentCreateStruct): bool { - $that->assertEquals($contentCreateStruct, func_get_arg(2)); + static function () use ($contentCreateStruct): bool { + self::assertEquals($contentCreateStruct, func_get_arg(2)); return true; } ) ); - $this->getUniqueHashDomainMapperMock($domainMapperMock, $that, $contentCreateStruct); + $this->getUniqueHashDomainMapperMock($domainMapperMock, $contentCreateStruct); $this->getFieldTypeRegistryMock()->expects(self::any()) ->method('getFieldType') @@ -2515,7 +2511,6 @@ static function (ValueStub $value) use ($emptyValue): bool { private function getUniqueHashDomainMapperMock( \PHPUnit\Framework\MockObject\MockObject $domainMapperMock, - self $that, ContentCreateStruct $contentCreateStruct ): void { $domainMapperMock->expects(self::once()) @@ -2523,8 +2518,8 @@ private function getUniqueHashDomainMapperMock( ->with(self::isInstanceOf(APIContentCreateStruct::class)) ->will( self::returnCallback( - static function ($object) use ($that, $contentCreateStruct): string { - $that->assertEquals($contentCreateStruct, $object); + static function ($object) use ($contentCreateStruct): string { + self::assertEquals($contentCreateStruct, $object); return 'hash'; } @@ -2759,7 +2754,6 @@ static function ($valueString) { ->method('getContentTypeService') ->will(self::returnValue($contentTypeServiceMock)); - $that = $this; $permissionResolver->expects(self::once()) ->method('canUser') ->with( @@ -2769,8 +2763,8 @@ static function ($valueString) { self::equalTo($locationCreateStructs) )->will( self::returnCallback( - static function () use ($that, $contentCreateStruct): bool { - $that->assertEquals($contentCreateStruct, func_get_arg(2)); + static function () use ($contentCreateStruct): bool { + self::assertEquals($contentCreateStruct, func_get_arg(2)); return true; } @@ -2782,8 +2776,8 @@ static function () use ($that, $contentCreateStruct): bool { ->with(self::isInstanceOf(APIContentCreateStruct::class)) ->will( self::returnCallback( - static function ($object) use ($that, $contentCreateStruct): string { - $that->assertEquals($contentCreateStruct, $object); + static function ($object) use ($contentCreateStruct): string { + self::assertEquals($contentCreateStruct, $object); return 'hash'; } @@ -5639,22 +5633,22 @@ public function testCopyContent(): void $repositoryMock->expects(self::once())->method('commit'); $destinationLocationTarget = (new DestinationLocation($locationCreateStruct->parentLocationId, $contentInfoMock)); - $matcher = $this->exactly(2); + $matcher = self::exactly(2); $permissionResolverMock->expects($matcher) - ->method('canUser')->willReturnCallback(function (...$parameters) use ($matcher, $contentInfoMock, $location, $destinationLocationTarget) { + ->method('canUser')->willReturnCallback(static function (...$parameters) use ($matcher, $contentInfoMock, $location, $destinationLocationTarget) { if ($matcher->numberOfInvocations() === 1) { - $this->assertSame('content', $parameters[0]); - $this->assertSame('create', $parameters[1]); - $this->assertSame($contentInfoMock, $parameters[2]); - $this->assertEquals([$location, $destinationLocationTarget], $parameters[3]); + self::assertSame('content', $parameters[0]); + self::assertSame('create', $parameters[1]); + self::assertSame($contentInfoMock, $parameters[2]); + self::assertEquals([$location, $destinationLocationTarget], $parameters[3]); return true; } if ($matcher->numberOfInvocations() === 2) { - $this->assertSame('content', $parameters[0]); - $this->assertSame('manage_locations', $parameters[1]); - $this->assertSame($contentInfoMock, $parameters[2]); - $this->assertSame([$location], $parameters[3]); + self::assertSame('content', $parameters[0]); + self::assertSame('manage_locations', $parameters[1]); + self::assertSame($contentInfoMock, $parameters[2]); + self::assertSame([$location], $parameters[3]); return true; } @@ -5780,22 +5774,22 @@ public function testCopyContentWithVersionInfo(): void $repositoryMock->expects(self::once())->method('commit'); $destinationLocationTarget = (new DestinationLocation($locationCreateStruct->parentLocationId, $contentInfoMock)); - $matcher = $this->exactly(2); + $matcher = self::exactly(2); $permissionResolverMock->expects($matcher) - ->method('canUser')->willReturnCallback(function (...$parameters) use ($matcher, $contentInfoMock, $location, $destinationLocationTarget) { + ->method('canUser')->willReturnCallback(static function (...$parameters) use ($matcher, $contentInfoMock, $location, $destinationLocationTarget) { if ($matcher->numberOfInvocations() === 1) { - $this->assertSame('content', $parameters[0]); - $this->assertSame('create', $parameters[1]); - $this->assertSame($contentInfoMock, $parameters[2]); - $this->assertEquals([$location, $destinationLocationTarget], $parameters[3]); + self::assertSame('content', $parameters[0]); + self::assertSame('create', $parameters[1]); + self::assertSame($contentInfoMock, $parameters[2]); + self::assertEquals([$location, $destinationLocationTarget], $parameters[3]); return true; } if ($matcher->numberOfInvocations() === 2) { - $this->assertSame('content', $parameters[0]); - $this->assertSame('manage_locations', $parameters[1]); - $this->assertSame($contentInfoMock, $parameters[2]); - $this->assertSame([$location], $parameters[3]); + self::assertSame('content', $parameters[0]); + self::assertSame('manage_locations', $parameters[1]); + self::assertSame($contentInfoMock, $parameters[2]); + self::assertSame([$location], $parameters[3]); return true; } @@ -5895,22 +5889,22 @@ public function testCopyContentWithRollback(): void $repositoryMock->expects(self::once())->method('rollback'); $destinationLocationTarget = (new DestinationLocation($locationCreateStruct->parentLocationId, $contentInfoMock)); - $matcher = $this->exactly(2); + $matcher = self::exactly(2); $permissionResolverMock->expects($matcher) - ->method('canUser')->willReturnCallback(function (...$parameters) use ($matcher, $contentInfoMock, $location, $destinationLocationTarget) { + ->method('canUser')->willReturnCallback(static function (...$parameters) use ($matcher, $contentInfoMock, $location, $destinationLocationTarget) { if ($matcher->numberOfInvocations() === 1) { - $this->assertSame('content', $parameters[0]); - $this->assertSame('create', $parameters[1]); - $this->assertSame($contentInfoMock, $parameters[2]); - $this->assertEquals([$location, $destinationLocationTarget], $parameters[3]); + self::assertSame('content', $parameters[0]); + self::assertSame('create', $parameters[1]); + self::assertSame($contentInfoMock, $parameters[2]); + self::assertEquals([$location, $destinationLocationTarget], $parameters[3]); return true; } if ($matcher->numberOfInvocations() === 2) { - $this->assertSame('content', $parameters[0]); - $this->assertSame('manage_locations', $parameters[1]); - $this->assertSame($contentInfoMock, $parameters[2]); - $this->assertSame([$location], $parameters[3]); + self::assertSame('content', $parameters[0]); + self::assertSame('manage_locations', $parameters[1]); + self::assertSame($contentInfoMock, $parameters[2]); + self::assertSame([$location], $parameters[3]); return true; } diff --git a/tests/lib/Repository/Service/Mock/UrlTest.php b/tests/lib/Repository/Service/Mock/UrlTest.php index ddec18b28f..4798c9581b 100644 --- a/tests/lib/Repository/Service/Mock/UrlTest.php +++ b/tests/lib/Repository/Service/Mock/UrlTest.php @@ -161,12 +161,12 @@ public function testUpdateUrl(): void $this->urlHandler ->expects(self::once()) ->method('updateUrl') - ->willReturnCallback(function ($id, $struct) use ($apiUrl, $apiStruct) { - $this->assertEquals($apiUrl->id, $id); + ->willReturnCallback(static function ($id, $struct) use ($apiUrl, $apiStruct) { + self::assertEquals($apiUrl->id, $id); - $this->assertEquals($apiStruct->url, $struct->url); - $this->assertEquals(0, $struct->lastChecked); - $this->assertTrue($struct->isValid); + self::assertEquals($apiStruct->url, $struct->url); + self::assertEquals(0, $struct->lastChecked); + self::assertTrue($struct->isValid); }); $this->urlHandler @@ -221,12 +221,12 @@ public function testUpdateUrlStatus(): void $this->urlHandler ->expects(self::once()) ->method('updateUrl') - ->willReturnCallback(function ($id, $struct) use ($apiUrl, $apiStruct) { - $this->assertEquals($apiUrl->id, $id); + ->willReturnCallback(static function ($id, $struct) use ($apiUrl, $apiStruct) { + self::assertEquals($apiUrl->id, $id); - $this->assertEquals($apiUrl->url, $struct->url); - $this->assertEquals($apiStruct->lastChecked->getTimestamp(), $struct->lastChecked); - $this->assertTrue($apiStruct->isValid, $struct->isValid); + self::assertEquals($apiUrl->url, $struct->url); + self::assertEquals($apiStruct->lastChecked->getTimestamp(), $struct->lastChecked); + self::assertTrue($apiStruct->isValid, $struct->isValid); }); $this->urlHandler @@ -351,8 +351,8 @@ public function testFindUsages($offset, $limit, ContentQuery $expectedQuery, arr $searchService ->expects(self::once()) ->method('findContentInfo') - ->willReturnCallback(function ($query) use ($expectedQuery, $usages) { - $this->assertEquals($expectedQuery, $query); + ->willReturnCallback(static function ($query) use ($expectedQuery, $usages) { + self::assertEquals($expectedQuery, $query); return new ContentSearchResults([ 'searchHits' => array_map(static function ($id) { @@ -467,8 +467,8 @@ protected function configurePermissions(array $permissions) $this->permissionResolver ->expects($matcher) ->method('canUser') - ->willReturnCallback(function (...$parameters) use ($matcher, $permissions) { - $this->assertEquals($permissions[$matcher->numberOfInvocations() - 1], $parameters); + ->willReturnCallback(static function (...$parameters) use ($matcher, $permissions) { + self::assertEquals($permissions[$matcher->numberOfInvocations() - 1], $parameters); return true; }); diff --git a/tests/lib/Repository/Service/Mock/UserPreferenceTest.php b/tests/lib/Repository/Service/Mock/UserPreferenceTest.php index 635130c451..06e308aec0 100644 --- a/tests/lib/Repository/Service/Mock/UserPreferenceTest.php +++ b/tests/lib/Repository/Service/Mock/UserPreferenceTest.php @@ -55,10 +55,10 @@ public function testSetUserPreference(): void $this->userSPIPreferenceHandler ->expects($this->once()) ->method('setUserPreference') - ->willReturnCallback(function (UserPreferenceSetStruct $setStruct) { - $this->assertEquals(self::USER_PREFERENCE_NAME, $setStruct->name); - $this->assertEquals(self::USER_PREFERENCE_VALUE, $setStruct->value); - $this->assertEquals(self::CURRENT_USER_ID, $setStruct->userId); + ->willReturnCallback(static function (UserPreferenceSetStruct $setStruct) { + self::assertEquals(self::USER_PREFERENCE_NAME, $setStruct->name); + self::assertEquals(self::USER_PREFERENCE_VALUE, $setStruct->value); + self::assertEquals(self::CURRENT_USER_ID, $setStruct->userId); return new UserPreference(); }); diff --git a/tests/lib/Repository/SiteAccessAware/AbstractServiceTestCase.php b/tests/lib/Repository/SiteAccessAware/AbstractServiceTestCase.php index f8a56069ca..a7cfea24da 100644 --- a/tests/lib/Repository/SiteAccessAware/AbstractServiceTestCase.php +++ b/tests/lib/Repository/SiteAccessAware/AbstractServiceTestCase.php @@ -289,10 +289,10 @@ final public function testIfThereIsMissingTest(): void { $tested = array_merge( array_diff( - array_column(self::toArray($this->providerForLanguagesLookupMethods()), 0), + array_column(self::toArray(static::providerForLanguagesLookupMethods()), 0), [self::NO_DATA_METHOD] ), - array_column(self::toArray($this->providerForPassTroughMethods()), 0) + array_column(self::toArray(static::providerForPassTroughMethods()), 0) ); $class = new ReflectionClass($this->getSiteAccessAwareServiceClassName()); From 49d33112e253a26bf1d4055bfac84d8fc9be8fd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Nowak?= Date: Tue, 22 Sep 2026 14:25:50 +0200 Subject: [PATCH 3/6] IBX-12654: Fixed issues reported by ibexa/phpstan rules --- .../Command/RegenerateUrlAliasesCommand.php | 15 +++--- .../DependencyInjection/Configuration.php | 8 +-- .../Configuration/Parser/Image.php | 2 +- .../ContentDownloadRouteReferenceListener.php | 4 +- .../Core/Features/Context/ContentContext.php | 8 +-- .../Command/InstallPlatformCommand.php | 2 +- .../Target/Builder/VersionBuilder.php | 2 +- src/lib/FieldType/Author/Type.php | 4 +- .../Gateway/DoctrineStorage.php | 2 +- .../UserStorage/Gateway/DoctrineStorage.php | 2 +- .../FileExtensionBlackListValidator.php | 13 ++--- .../SudoMainLocationLoader.php | 2 +- .../IO/ConfigScopeChangeAwareIOService.php | 45 ++++++++++------ .../Limitation/ObjectStateLimitationType.php | 2 +- .../TwigVariableProviderExtension.php | 2 +- .../ImageAsset/ParameterProvider.php | 2 +- .../Symfony/Matcher/ContentBased/Depth.php | 2 +- .../ContentBased/Id/ParentContentType.php | 6 +-- .../ContentBased/Id/ParentLocation.php | 2 +- .../Identifier/ParentContentType.php | 4 +- .../ContentBased/Identifier/Section.php | 6 +-- .../Symfony/Matcher/ContentBased/UrlAlias.php | 2 +- .../Provider/StaticSiteAccessProvider.php | 2 +- .../Extension/FieldRenderingExtension.php | 4 +- .../View/Builder/ContentViewBuilder.php | 4 +- .../TransactionalInMemoryCacheAdapter.php | 2 +- src/lib/Persistence/Cache/BookmarkHandler.php | 4 +- src/lib/Persistence/Cache/ContentHandler.php | 24 ++++----- .../Cache/ContentLanguageHandler.php | 14 ++--- .../Persistence/Cache/ContentTypeHandler.php | 44 +++++++-------- src/lib/Persistence/Cache/LocationHandler.php | 16 +++--- .../Persistence/Cache/ObjectStateHandler.php | 2 +- src/lib/Persistence/Cache/TrashHandler.php | 6 +-- src/lib/Persistence/Cache/URLHandler.php | 2 +- src/lib/Persistence/Cache/UrlAliasHandler.php | 8 +-- src/lib/Persistence/Cache/UserHandler.php | 40 +++++++------- .../Cache/UserPreferenceHandler.php | 6 +-- .../Persistence/Legacy/Content/Handler.php | 2 +- .../Content/Language/CachingHandler.php | 2 +- .../Legacy/Content/TreeHandler.php | 2 +- .../Type/ContentUpdater/Action/AddField.php | 2 +- .../ContentUpdater/Action/RemoveField.php | 2 +- .../Legacy/Content/Type/Mapper.php | 2 +- .../Legacy/Content/UrlAlias/Handler.php | 2 +- .../Mapper/DoctrineGatewayDataMapper.php | 2 +- .../Legacy/Token/AbstractGateway.php | 2 +- src/lib/Persistence/Legacy/User/Mapper.php | 2 +- .../TransformationProcessor/PcreCompiler.php | 6 +-- .../QueryType/BuiltIn/AbstractQueryType.php | 2 +- .../BuiltIn/GeoLocationQueryType.php | 2 +- .../BuiltIn/RelatedToContentQueryType.php | 4 +- src/lib/Repository/ContentService.php | 2 +- src/lib/Repository/ContentTypeService.php | 2 +- src/lib/Repository/LocationService.php | 2 +- src/lib/Repository/NotificationService.php | 4 +- .../ProxyFactory/ProxyGenerator.php | 2 +- src/lib/Repository/RoleService.php | 4 +- src/lib/Repository/SectionService.php | 4 +- src/lib/Repository/UserPreferenceService.php | 2 +- .../LocationEventSubscriber.php | 2 +- .../ContentTypeInputGeneratorStrategyTest.php | 2 +- .../ConfigurationProcessorTest.php | 2 +- .../ViewControllerListenerTest.php | 8 +-- .../Fragment/DirectFragmentRendererTest.php | 8 +-- .../Core/Imagine/AliasGeneratorTest.php | 2 +- .../GenericProviderTest.php | 4 +- .../VariationPurger/IOVariationPurgerTest.php | 8 +-- .../ImageFileVariationPurgerTest.php | 2 +- .../bundle/Core/URLChecker/URLCheckerTest.php | 8 +-- .../Limitation/MemberOfLimitationTest.php | 2 +- .../Core/Limitation/RoleLimitationTest.php | 2 +- .../Core/Repository/BookmarkServiceTest.php | 2 +- .../ContentServiceAuthorizationTest.php | 2 +- .../Core/Repository/ContentServiceTest.php | 8 +-- .../Repository/ContentTypeServiceTest.php | 8 +-- .../Filtering/LocationFilteringTest.php | 4 +- .../LocationLimitationIntegrationTest.php | 2 +- .../Core/Repository/LocationServiceTest.php | 12 ++--- .../Repository/ObjectStateServiceTest.php | 2 +- .../Parallel/BaseParallelTestCase.php | 2 +- .../Parallel/ContentServiceTest.php | 4 +- .../Repository/SearchServiceFulltextTest.php | 4 +- .../Repository/SearchServiceLocationTest.php | 2 +- .../Core/Repository/SearchServiceTest.php | 10 ++-- .../Core/Repository/TrashServiceTest.php | 2 +- .../Core/Repository/URLAliasServiceTest.php | 4 +- .../Core/Repository/UserServiceTest.php | 2 +- tests/lib/Collection/ArrayListTest.php | 4 +- tests/lib/Collection/ArrayMapTest.php | 8 +-- tests/lib/Event/AbstractServiceTestCase.php | 4 +- tests/lib/Event/BookmarkServiceTest.php | 4 +- tests/lib/Event/ContentServiceTest.php | 42 +++++++-------- tests/lib/Event/ContentTypeServiceTest.php | 40 +++++++------- tests/lib/Event/LanguageServiceTest.php | 18 +++---- tests/lib/Event/LocationServiceTest.php | 26 ++++----- tests/lib/Event/ObjectStateServiceTest.php | 24 ++++----- tests/lib/Event/RoleServiceTest.php | 36 ++++++------- tests/lib/Event/SectionServiceTest.php | 14 ++--- tests/lib/Event/SettingServiceTest.php | 10 ++-- tests/lib/Event/TrashServiceTest.php | 18 +++---- tests/lib/Event/URLAliasServiceTest.php | 12 ++--- tests/lib/Event/URLServiceTest.php | 4 +- tests/lib/Event/URLWildcardServiceTest.php | 12 ++--- tests/lib/Event/UserPreferenceServiceTest.php | 2 +- tests/lib/Event/UserServiceTest.php | 34 ++++++------ tests/lib/FieldType/Generic/GenericTest.php | 8 +-- tests/lib/FieldType/RelationListTest.php | 8 ++- tests/lib/FieldType/UserTest.php | 4 +- .../ConfigScopeChangeAwareIOServiceTest.php | 35 +++++++++--- .../LegacyDFSClusterTest.php | 2 +- .../Limitation/MemberOfLimitationTypeTest.php | 14 +++-- .../ParentContentTypeLimitationTypeTest.php | 6 +-- .../ParentDepthLimitationTypeTest.php | 2 +- .../lib/Limitation/RoleLimitationTypeTest.php | 8 +-- .../Limitation/SubtreeLimitationTypeTest.php | 8 +-- .../Content/PreviewControllerTest.php | 2 +- .../ImageAsset/ParameterProviderTest.php | 4 +- .../RelationList/ParameterProviderTest.php | 2 +- .../Symfony/Routing/UrlAliasGeneratorTest.php | 4 +- .../Provider/ChainSiteAccessProviderTest.php | 2 +- .../Twig/Extension/FileSizeExtensionTest.php | 4 +- .../lib/MVC/Symfony/View/ViewManagerTest.php | 10 ++-- .../Pagination/ContentSearchAdapterTest.php | 2 +- .../Pagination/LocationSearchAdapterTest.php | 2 +- .../Cache/AbstractBaseHandlerTestCase.php | 2 +- .../Cache/AbstractCacheHandlerTestCase.php | 12 ++--- .../AbstractInMemoryCacheHandlerTestCase.php | 12 ++--- .../InMemoryClearingProxyAdapterTest.php | 2 +- .../Persistence/Cache/ContentHandlerTest.php | 4 +- .../Cache/ContentTypeHandlerTest.php | 8 ++- .../Cache/InMemory/InMemoryCacheTest.php | 44 +++++++-------- .../Persistence/Cache/TrashHandlerTest.php | 10 ++-- .../lib/Persistence/Cache/URLHandlerTest.php | 4 +- .../lib/Persistence/Cache/UserHandlerTest.php | 4 +- .../Bookmark/Gateway/DoctrineDatabaseTest.php | 2 +- .../Legacy/Content/ContentHandlerTest.php | 4 +- .../Legacy/Content/FieldHandlerTest.php | 20 +++---- .../Language/CachingLanguageHandlerTest.php | 4 +- .../Content/Language/MaskGeneratorTest.php | 2 +- .../Gateway/DoctrineDatabaseTrashTest.php | 4 +- .../Content/Location/TrashHandlerTest.php | 8 +-- .../Legacy/Content/LocationHandlerTest.php | 22 ++++---- .../ResolveVirtualFieldSubscriberTest.php | 4 +- .../Persistence/Legacy/Content/MapperTest.php | 4 +- .../Legacy/Content/TreeHandlerTest.php | 20 +++---- .../Content/Type/ContentTypeHandlerTest.php | 2 +- .../ContentUpdater/Action/AddFieldTest.php | 14 ++--- .../ContentUpdater/Action/RemoveFieldTest.php | 14 ++--- .../Content/Type/ContentUpdaterTest.php | 4 +- .../Type/Gateway/DoctrineDatabaseTest.php | 2 +- .../Legacy/Content/Type/MapperTest.php | 2 +- .../FieldSortClauseParserTest.php | 4 +- .../MapDistanceSortClauseParserTest.php | 4 +- .../DecoratedLocationServiceTest.php | 8 +-- .../CachedPermissionServiceTest.php | 2 +- .../Repository/Service/Mock/BookmarkTest.php | 16 +++--- .../Repository/Service/Mock/ContentTest.php | 54 ++++++++++--------- .../Service/Mock/PermissionTest.php | 14 ++--- .../Repository/Service/Mock/SearchTest.php | 16 +++--- tests/lib/Repository/Service/Mock/UrlTest.php | 10 ++-- .../Service/Mock/UserPreferenceTest.php | 12 ++--- .../SiteAccessAware/SearchServiceTest.php | 2 +- .../SiteAccessAware/UrlAliasServiceTest.php | 2 +- tests/lib/Search/FieldNameResolverTest.php | 4 +- .../Legacy/Content/AbstractTestCase.php | 2 +- .../Legacy/Content/HandlerContentSortTest.php | 16 +++--- .../Legacy/Content/HandlerContentTest.php | 2 +- .../Content/HandlerLocationSortTest.php | 8 +-- .../Legacy/Content/HandlerLocationTest.php | 2 +- 169 files changed, 710 insertions(+), 632 deletions(-) diff --git a/src/bundle/Core/Command/RegenerateUrlAliasesCommand.php b/src/bundle/Core/Command/RegenerateUrlAliasesCommand.php index 9f806cf3b6..b2a5b0d9d4 100644 --- a/src/bundle/Core/Command/RegenerateUrlAliasesCommand.php +++ b/src/bundle/Core/Command/RegenerateUrlAliasesCommand.php @@ -9,6 +9,7 @@ use Exception; use Ibexa\Contracts\Core\Repository\Repository; +use Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo; use Ibexa\Contracts\Core\Repository\Values\Content\Language; use Ibexa\Contracts\Core\Repository\Values\Content\Location; use Psr\Log\LoggerInterface; @@ -186,9 +187,9 @@ protected function getProgressBar($maxSteps, OutputInterface $output) private function processLocations(array $locations, ProgressBar $progressBar): void { $contentList = $this->repository->sudo( - static function (Repository $repository) use ($locations) { + static function (Repository $repository) use ($locations): iterable { $contentInfoList = array_map( - static function (Location $location) { + static function (Location $location): ContentInfo { return $location->contentInfo; }, $locations @@ -211,7 +212,7 @@ static function (Location $location) { } $this->repository->sudo( - static function (Repository $repository) use ($location) { + static function (Repository $repository) use ($location): void { $repository->getURLAliasService()->refreshSystemUrlAliasesForLocation( $location ); @@ -247,7 +248,7 @@ static function (Repository $repository) use ($location) { private function loadAllLocations(int $offset, int $iterationCount): array { return $this->repository->sudo( - static function (Repository $repository) use ($offset, $iterationCount) { + static function (Repository $repository) use ($offset, $iterationCount): array { return $repository->getLocationService()->loadAllLocations($offset, $iterationCount); } ); @@ -267,7 +268,7 @@ private function loadSpecificLocations(array $locationIds, int $offset, int $ite $locationIds = array_slice($locationIds, $offset, $iterationCount); return $this->repository->sudo( - static function (Repository $repository) use ($locationIds) { + static function (Repository $repository) use ($locationIds): iterable { return $repository->getLocationService()->loadLocationList($locationIds); } ); @@ -283,7 +284,7 @@ static function (Repository $repository) use ($locationIds) { private function getFilteredLocationList(array $locationIds): array { $locations = $this->repository->sudo( - static function (Repository $repository) use ($locationIds) { + static function (Repository $repository) use ($locationIds): iterable { $locationService = $repository->getLocationService(); return $locationService->loadLocationList($locationIds); @@ -291,7 +292,7 @@ static function (Repository $repository) use ($locationIds) { ); return array_map( - static function (Location $location) { + static function (Location $location): int { return $location->id; }, $locations diff --git a/src/bundle/Core/DependencyInjection/Configuration.php b/src/bundle/Core/DependencyInjection/Configuration.php index 85d5927278..3425e4de1c 100644 --- a/src/bundle/Core/DependencyInjection/Configuration.php +++ b/src/bundle/Core/DependencyInjection/Configuration.php @@ -89,7 +89,7 @@ public function addRepositoriesSection(ArrayNodeDefinition $rootNode): void ->beforeNormalization() ->always( // Handling deprecated structure by mapping it to new one - static function ($v) { + static function ($v): mixed { if (isset($v['storage'])) { return $v; } @@ -116,7 +116,7 @@ static function ($v) { ->beforeNormalization() ->always( // Setting default values - static function ($v) { + static function ($v): mixed { if ($v === null) { $v = []; } @@ -202,7 +202,7 @@ public function addSiteAccessSection(ArrayNodeDefinition $rootNode): void ->useAttributeAsKey('key') ->beforeNormalization() ->always( - static function ($v) { + static function ($v): mixed { // Value passed to the matcher should always be an array. // If value is not an array, we transform it to a hash, with 'value' as key. if (!is_array($v)) { @@ -230,7 +230,7 @@ static function ($v) { ->end() ->end() ->beforeNormalization() - ->always()->then(function ($v) { + ->always()->then(function ($v): mixed { if (isset($this->siteAccessConfigurationFilters)) { foreach ($this->siteAccessConfigurationFilters as $filter) { $v = $filter->filter($v); diff --git a/src/bundle/Core/DependencyInjection/Configuration/Parser/Image.php b/src/bundle/Core/DependencyInjection/Configuration/Parser/Image.php index 1534899a56..50d64d608d 100644 --- a/src/bundle/Core/DependencyInjection/Configuration/Parser/Image.php +++ b/src/bundle/Core/DependencyInjection/Configuration/Parser/Image.php @@ -80,7 +80,7 @@ static function ($v): bool { } ) ->then( - static function ($v) { + static function ($v): mixed { // If we have the "params" key, just use the value. return $v['params']; } diff --git a/src/bundle/Core/EventListener/ContentDownloadRouteReferenceListener.php b/src/bundle/Core/EventListener/ContentDownloadRouteReferenceListener.php index 16e269c4f1..193b57e6e5 100644 --- a/src/bundle/Core/EventListener/ContentDownloadRouteReferenceListener.php +++ b/src/bundle/Core/EventListener/ContentDownloadRouteReferenceListener.php @@ -94,14 +94,14 @@ protected function configureOptions(OptionsResolver $resolver) $resolver->setDefault( self::OPT_CONTENT_ID, - static function (Options $options) { + static function (Options $options): int { return $options[self::OPT_CONTENT]->id; } ); $resolver->setDefault( self::OPT_DOWNLOAD_NAME, - function (Options $options) { + function (Options $options): mixed { $field = $this->translationHelper->getTranslatedField( $options[self::OPT_CONTENT], $options[self::OPT_FIELD_IDENTIFIER], diff --git a/src/bundle/Core/Features/Context/ContentContext.php b/src/bundle/Core/Features/Context/ContentContext.php index eb1485824b..2de5a88b3d 100644 --- a/src/bundle/Core/Features/Context/ContentContext.php +++ b/src/bundle/Core/Features/Context/ContentContext.php @@ -66,7 +66,7 @@ public function createContentItem($contentTypeIdentifier, array $fields) $draft = $this->createDraft($contentTypeIdentifier, $fields); $this->currentContent = $this->repository->sudo( - function () use ($draft) { + function () use ($draft): \Ibexa\Contracts\Core\Repository\Values\Content\Content { return $this->repository->getContentService()->publishVersion($draft->versionInfo); } ); @@ -79,7 +79,7 @@ function () use ($draft) { public function createDraftForContent(Content $content) { $this->currentDraft = $this->repository->sudo( - function () use ($content) { + function () use ($content): \Ibexa\Contracts\Core\Repository\Values\Content\Content { return $this->repository->getContentService()->createContentDraft($content->contentInfo); } ); @@ -105,7 +105,7 @@ public function updateDraft($fields) $updateStruct->setField($fieldDefIdentifier, $fieldValueUpdate); } - $updatedDraft = $this->repository->sudo(function () use ($updateStruct) { + $updatedDraft = $this->repository->sudo(function () use ($updateStruct): \Ibexa\Contracts\Core\Repository\Values\Content\Content { return $this->repository->getContentService()->updateContent( $this->currentDraft->versionInfo, $updateStruct @@ -140,7 +140,7 @@ public function createDraft($contentTypeIdentifier, array $fields) $locationCreateStruct = $this->repository->getLocationService()->newLocationCreateStruct(2); $this->currentDraft = $this->repository->sudo( - function () use ($createStruct, $locationCreateStruct) { + function () use ($createStruct, $locationCreateStruct): \Ibexa\Contracts\Core\Repository\Values\Content\Content { return $this->repository->getContentService()->createContent( $createStruct, [$locationCreateStruct] diff --git a/src/bundle/RepositoryInstaller/Command/InstallPlatformCommand.php b/src/bundle/RepositoryInstaller/Command/InstallPlatformCommand.php index a3c8897ad9..82de0b8bc9 100644 --- a/src/bundle/RepositoryInstaller/Command/InstallPlatformCommand.php +++ b/src/bundle/RepositoryInstaller/Command/InstallPlatformCommand.php @@ -295,7 +295,7 @@ private function executeCommand(OutputInterface $output, $cmd, $timeout = 300) $timeout ); - $process->run(static function ($type, $buffer) use ($output) { $output->write($buffer, false); }); + $process->run(static function ($type, $buffer) use ($output): void { $output->write($buffer, false); }); $exitCode = $process->getExitCode() ?? 0; if ($exitCode !== self::SUCCESS) { throw new \RuntimeException(sprintf('An error occurred when executing the "%s" command.', escapeshellarg($cmd))); diff --git a/src/contracts/Limitation/Target/Builder/VersionBuilder.php b/src/contracts/Limitation/Target/Builder/VersionBuilder.php index 5b870b5fed..7fc8b68e0c 100644 --- a/src/contracts/Limitation/Target/Builder/VersionBuilder.php +++ b/src/contracts/Limitation/Target/Builder/VersionBuilder.php @@ -115,7 +115,7 @@ public function changeStatusTo(int $status): self public function updateFieldsTo(?string $initialLanguageCode, array $fields): self { $languageCodes = array_map( - static function (Field $field) { + static function (Field $field): mixed { return $field->languageCode; }, $fields diff --git a/src/lib/FieldType/Author/Type.php b/src/lib/FieldType/Author/Type.php index fb54ddf834..91e44e72c9 100644 --- a/src/lib/FieldType/Author/Type.php +++ b/src/lib/FieldType/Author/Type.php @@ -138,7 +138,7 @@ public function fromHash($hash) { return new Value( array_map( - static function ($author) { + static function ($author): \Ibexa\Core\FieldType\Author\Author { return new Author($author); }, $hash @@ -156,7 +156,7 @@ static function ($author) { public function toHash(SPIValue $value): array { return array_map( - static function ($author) { + static function ($author): array { return (array)$author; }, $value->authors->getArrayCopy() diff --git a/src/lib/FieldType/BinaryBase/BinaryBaseStorage/Gateway/DoctrineStorage.php b/src/lib/FieldType/BinaryBase/BinaryBaseStorage/Gateway/DoctrineStorage.php index 21b470b330..c6ac39c81e 100644 --- a/src/lib/FieldType/BinaryBase/BinaryBaseStorage/Gateway/DoctrineStorage.php +++ b/src/lib/FieldType/BinaryBase/BinaryBaseStorage/Gateway/DoctrineStorage.php @@ -409,7 +409,7 @@ public function getReferencedFiles(array $fieldIds, $versionNo) $statement = $selectQuery->executeQuery(); return array_map( - function ($row) { + function ($row): string { return $this->prependMimeToPath($row['filename'], $row['mime_type']); }, $statement->fetchAllAssociative() diff --git a/src/lib/FieldType/User/UserStorage/Gateway/DoctrineStorage.php b/src/lib/FieldType/User/UserStorage/Gateway/DoctrineStorage.php index 14b72cdf78..3d4927ea05 100644 --- a/src/lib/FieldType/User/UserStorage/Gateway/DoctrineStorage.php +++ b/src/lib/FieldType/User/UserStorage/Gateway/DoctrineStorage.php @@ -95,7 +95,7 @@ protected function getPropertyMap(): array ], 'password_updated_at' => [ 'name' => 'passwordUpdatedAt', - 'cast' => static function ($timestamp) { + 'cast' => static function ($timestamp): ?int { return $timestamp ? (int)$timestamp : null; }, ], diff --git a/src/lib/FieldType/Validator/FileExtensionBlackListValidator.php b/src/lib/FieldType/Validator/FileExtensionBlackListValidator.php index 0bee0955ca..ffb7d91db6 100644 --- a/src/lib/FieldType/Validator/FileExtensionBlackListValidator.php +++ b/src/lib/FieldType/Validator/FileExtensionBlackListValidator.php @@ -26,14 +26,11 @@ class FileExtensionBlackListValidator extends Validator ], ]; - /** - * @param \Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface $configResolver - */ + private ConfigResolverInterface $configResolver; + public function __construct(ConfigResolverInterface $configResolver) { - $this->constraints['extensionsBlackList'] = $configResolver->getParameter( - 'io.file_storage.file_type_blacklist' - ); + $this->configResolver = $configResolver; } /** @@ -58,6 +55,10 @@ public function validate(BaseValue $value, ?FieldDefinition $fieldDefinition = n public function validateFileExtension(string $fileName): void { + $this->constraints['extensionsBlackList'] = $this->configResolver->getParameter( + 'io.file_storage.file_type_blacklist' + ); + if ( pathinfo($fileName, PATHINFO_BASENAME) !== $fileName || in_array( diff --git a/src/lib/Helper/ContentInfoLocationLoader/SudoMainLocationLoader.php b/src/lib/Helper/ContentInfoLocationLoader/SudoMainLocationLoader.php index 650abe4b5c..6c19fe4668 100644 --- a/src/lib/Helper/ContentInfoLocationLoader/SudoMainLocationLoader.php +++ b/src/lib/Helper/ContentInfoLocationLoader/SudoMainLocationLoader.php @@ -34,7 +34,7 @@ public function loadLocation(ContentInfo $contentInfo) try { return $this->repository->sudo( - static function (Repository $repository) use ($contentInfo) { + static function (Repository $repository) use ($contentInfo): \Ibexa\Contracts\Core\Repository\Values\Content\Location { return $repository->getLocationService()->loadLocation($contentInfo->mainLocationId); } ); diff --git a/src/lib/IO/ConfigScopeChangeAwareIOService.php b/src/lib/IO/ConfigScopeChangeAwareIOService.php index 0f19e85b12..ad22774d8f 100644 --- a/src/lib/IO/ConfigScopeChangeAwareIOService.php +++ b/src/lib/IO/ConfigScopeChangeAwareIOService.php @@ -25,6 +25,8 @@ class ConfigScopeChangeAwareIOService implements IOServiceInterface, ConfigScope private string $prefixParameterName; + private bool $prefixResolved = false; + public function __construct( ConfigResolverInterface $configResolver, IOServiceInterface $innerIOService, @@ -33,78 +35,89 @@ public function __construct( $this->configResolver = $configResolver; $this->innerIOService = $innerIOService; $this->prefixParameterName = $prefixParameterName; - - // set initial prefix on inner IOService - $this->setPrefix($this->configResolver->getParameter($this->prefixParameterName)); } public function setPrefix(string $prefix): void { $this->innerIOService->setPrefix($prefix); + $this->prefixResolved = true; + } + + /** + * Returns the inner IOService, resolving and setting its prefix lazily on first use so that + * the ConfigResolver is never read in the constructor (its scope may not be final yet then). + */ + private function getInnerIOService(): IOServiceInterface + { + if (!$this->prefixResolved) { + $this->setPrefix($this->configResolver->getParameter($this->prefixParameterName)); + } + + return $this->innerIOService; } public function newBinaryCreateStructFromLocalFile(string $localFile): BinaryFileCreateStruct { - return $this->innerIOService->newBinaryCreateStructFromLocalFile($localFile); + return $this->getInnerIOService()->newBinaryCreateStructFromLocalFile($localFile); } public function exists(string $binaryFileId): bool { - return $this->innerIOService->exists($binaryFileId); + return $this->getInnerIOService()->exists($binaryFileId); } public function loadBinaryFile(string $binaryFileId): BinaryFile { - return $this->innerIOService->loadBinaryFile($binaryFileId); + return $this->getInnerIOService()->loadBinaryFile($binaryFileId); } public function loadBinaryFileByUri(string $binaryFileUri): BinaryFile { - return $this->innerIOService->loadBinaryFileByUri($binaryFileUri); + return $this->getInnerIOService()->loadBinaryFileByUri($binaryFileUri); } public function getFileContents(BinaryFile $binaryFile): string { - return $this->innerIOService->getFileContents($binaryFile); + return $this->getInnerIOService()->getFileContents($binaryFile); } public function createBinaryFile(BinaryFileCreateStruct $binaryFileCreateStruct): BinaryFile { - return $this->innerIOService->createBinaryFile($binaryFileCreateStruct); + return $this->getInnerIOService()->createBinaryFile($binaryFileCreateStruct); } public function getUri(string $binaryFileId): string { - return $this->innerIOService->getUri($binaryFileId); + return $this->getInnerIOService()->getUri($binaryFileId); } public function getMimeType(string $binaryFileId): ?string { - return $this->innerIOService->getMimeType($binaryFileId); + return $this->getInnerIOService()->getMimeType($binaryFileId); } public function getFileInputStream(BinaryFile $binaryFile): mixed { - return $this->innerIOService->getFileInputStream($binaryFile); + return $this->getInnerIOService()->getFileInputStream($binaryFile); } public function deleteBinaryFile(BinaryFile $binaryFile): void { - $this->innerIOService->deleteBinaryFile($binaryFile); + $this->getInnerIOService()->deleteBinaryFile($binaryFile); } public function newBinaryCreateStructFromUploadedFile(array $uploadedFile): BinaryFileCreateStruct { - return $this->innerIOService->newBinaryCreateStructFromUploadedFile($uploadedFile); + return $this->getInnerIOService()->newBinaryCreateStructFromUploadedFile($uploadedFile); } public function deleteDirectory(string $path): void { - $this->innerIOService->deleteDirectory($path); + $this->getInnerIOService()->deleteDirectory($path); } public function onConfigScopeChange(ScopeChangeEvent $event): void { - $this->setPrefix($this->configResolver->getParameter($this->prefixParameterName)); + $this->prefixResolved = false; } } diff --git a/src/lib/Limitation/ObjectStateLimitationType.php b/src/lib/Limitation/ObjectStateLimitationType.php index 9f577c2fcb..4985f273a8 100644 --- a/src/lib/Limitation/ObjectStateLimitationType.php +++ b/src/lib/Limitation/ObjectStateLimitationType.php @@ -254,7 +254,7 @@ private function groupLimitationValues(array $limitationValues) $groupedLimitationValues = []; foreach ($stateGroups as $stateGroup) { $states = $objectStateHandler->loadObjectStates($stateGroup->id); - $stateIds = array_map(static function ($state) { + $stateIds = array_map(static function ($state): mixed { return $state->id; }, $states); $limitationValuesGroup = array_intersect($stateIds, $limitationValues); diff --git a/src/lib/MVC/Symfony/ExpressionLanguage/TwigVariableProviderExtension.php b/src/lib/MVC/Symfony/ExpressionLanguage/TwigVariableProviderExtension.php index 0ca47ef27c..0c6d67cf71 100644 --- a/src/lib/MVC/Symfony/ExpressionLanguage/TwigVariableProviderExtension.php +++ b/src/lib/MVC/Symfony/ExpressionLanguage/TwigVariableProviderExtension.php @@ -30,7 +30,7 @@ public function getFunctions(): array static function (string $identifier): string { return 'Not implemented: Not a Dependency Injection expression'; }, - function (array $variables, string $identifier) { + function (array $variables, string $identifier): object { if (!$this->hasParameterProvider($variables)) { throw new InvalidArgumentException( self::PROVIDER_REGISTRY_PARAMETER, diff --git a/src/lib/MVC/Symfony/FieldType/ImageAsset/ParameterProvider.php b/src/lib/MVC/Symfony/FieldType/ImageAsset/ParameterProvider.php index 6ec28ddfda..ad92597317 100644 --- a/src/lib/MVC/Symfony/FieldType/ImageAsset/ParameterProvider.php +++ b/src/lib/MVC/Symfony/FieldType/ImageAsset/ParameterProvider.php @@ -73,7 +73,7 @@ public function getViewParameters(Field $field): array private function loadContentInfo(int $id): ContentInfo { return $this->repository->sudo( - static function (Repository $repository) use ($id) { + static function (Repository $repository) use ($id): \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo { return $repository->getContentService()->loadContentInfo($id); } ); diff --git a/src/lib/MVC/Symfony/Matcher/ContentBased/Depth.php b/src/lib/MVC/Symfony/Matcher/ContentBased/Depth.php index 4703c40269..dbd08e0b18 100644 --- a/src/lib/MVC/Symfony/Matcher/ContentBased/Depth.php +++ b/src/lib/MVC/Symfony/Matcher/ContentBased/Depth.php @@ -38,7 +38,7 @@ public function matchLocation(Location $location): bool public function matchContentInfo(ContentInfo $contentInfo): bool { $location = $this->repository->sudo( - static function (Repository $repository) use ($contentInfo) { + static function (Repository $repository) use ($contentInfo): \Ibexa\Contracts\Core\Repository\Values\Content\Location { return $repository->getLocationService()->loadLocation($contentInfo->mainLocationId); } ); diff --git a/src/lib/MVC/Symfony/Matcher/ContentBased/Id/ParentContentType.php b/src/lib/MVC/Symfony/Matcher/ContentBased/Id/ParentContentType.php index 1843af3e82..3ba25261cf 100644 --- a/src/lib/MVC/Symfony/Matcher/ContentBased/Id/ParentContentType.php +++ b/src/lib/MVC/Symfony/Matcher/ContentBased/Id/ParentContentType.php @@ -26,7 +26,7 @@ class ParentContentType extends MultipleValued public function matchLocation(APILocation $location): bool { $parent = $this->repository->sudo( - static function (Repository $repository) use ($location) { + static function (Repository $repository) use ($location): \Ibexa\Contracts\Core\Repository\Values\Content\Location { return $repository->getLocationService()->loadLocation($location->parentLocationId); } ); @@ -44,7 +44,7 @@ static function (Repository $repository) use ($location) { public function matchContentInfo(ContentInfo $contentInfo) { $location = $this->repository->sudo( - static function (Repository $repository) use ($contentInfo) { + static function (Repository $repository) use ($contentInfo): \Ibexa\Contracts\Core\Repository\Values\Content\Location { return $repository->getLocationService()->loadLocation($contentInfo->mainLocationId); } ); @@ -70,7 +70,7 @@ public function match(View $view): bool private function loadParentLocation($locationId) { return $this->repository->sudo( - static function (Repository $repository) use ($locationId) { + static function (Repository $repository) use ($locationId): \Ibexa\Contracts\Core\Repository\Values\Content\Location { return $repository->getLocationService()->loadLocation($locationId); } ); diff --git a/src/lib/MVC/Symfony/Matcher/ContentBased/Id/ParentLocation.php b/src/lib/MVC/Symfony/Matcher/ContentBased/Id/ParentLocation.php index ff3ab61ae3..356e62ba20 100644 --- a/src/lib/MVC/Symfony/Matcher/ContentBased/Id/ParentLocation.php +++ b/src/lib/MVC/Symfony/Matcher/ContentBased/Id/ParentLocation.php @@ -38,7 +38,7 @@ public function matchLocation(APILocation $location): bool public function matchContentInfo(ContentInfo $contentInfo): bool { $location = $this->repository->sudo( - static function (Repository $repository) use ($contentInfo) { + static function (Repository $repository) use ($contentInfo): \Ibexa\Contracts\Core\Repository\Values\Content\Location { return $repository->getLocationService()->loadLocation($contentInfo->mainLocationId); } ); diff --git a/src/lib/MVC/Symfony/Matcher/ContentBased/Identifier/ParentContentType.php b/src/lib/MVC/Symfony/Matcher/ContentBased/Identifier/ParentContentType.php index b52ec15ee5..f942a51054 100644 --- a/src/lib/MVC/Symfony/Matcher/ContentBased/Identifier/ParentContentType.php +++ b/src/lib/MVC/Symfony/Matcher/ContentBased/Identifier/ParentContentType.php @@ -27,7 +27,7 @@ class ParentContentType extends MultipleValued public function matchLocation(APILocation $location): bool { $parentContentType = $this->repository->sudo( - static function (Repository $repository) use ($location) { + static function (Repository $repository) use ($location): \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType { $parent = $repository->getLocationService()->loadLocation($location->parentLocationId); return $repository @@ -49,7 +49,7 @@ static function (Repository $repository) use ($location) { public function matchContentInfo(ContentInfo $contentInfo) { $location = $this->repository->sudo( - static function (Repository $repository) use ($contentInfo) { + static function (Repository $repository) use ($contentInfo): \Ibexa\Contracts\Core\Repository\Values\Content\Location { return $repository->getLocationService()->loadLocation($contentInfo->mainLocationId); } ); diff --git a/src/lib/MVC/Symfony/Matcher/ContentBased/Identifier/Section.php b/src/lib/MVC/Symfony/Matcher/ContentBased/Identifier/Section.php index 89f5360ecd..ce4b65b587 100644 --- a/src/lib/MVC/Symfony/Matcher/ContentBased/Identifier/Section.php +++ b/src/lib/MVC/Symfony/Matcher/ContentBased/Identifier/Section.php @@ -26,7 +26,7 @@ class Section extends MultipleValued public function matchLocation(Location $location): bool { $section = $this->repository->sudo( - static function (Repository $repository) use ($location) { + static function (Repository $repository) use ($location): \Ibexa\Contracts\Core\Repository\Values\Content\Section { return $repository->getSectionService()->loadSection( $location->getContentInfo()->getSectionId() ); @@ -46,7 +46,7 @@ static function (Repository $repository) use ($location) { public function matchContentInfo(ContentInfo $contentInfo): bool { $section = $this->repository->sudo( - static function (Repository $repository) use ($contentInfo) { + static function (Repository $repository) use ($contentInfo): \Ibexa\Contracts\Core\Repository\Values\Content\Section { return $repository->getSectionService()->loadSection( $contentInfo->getSectionId() ); @@ -64,7 +64,7 @@ public function match(View $view): bool $contentInfo = $view->getContent()->contentInfo; $section = $this->repository->sudo( - static function (Repository $repository) use ($contentInfo) { + static function (Repository $repository) use ($contentInfo): \Ibexa\Contracts\Core\Repository\Values\Content\Section { return $repository->getSectionService()->loadSection( $contentInfo->getSectionId() ); diff --git a/src/lib/MVC/Symfony/Matcher/ContentBased/UrlAlias.php b/src/lib/MVC/Symfony/Matcher/ContentBased/UrlAlias.php index 906debd877..094358b57d 100644 --- a/src/lib/MVC/Symfony/Matcher/ContentBased/UrlAlias.php +++ b/src/lib/MVC/Symfony/Matcher/ContentBased/UrlAlias.php @@ -62,7 +62,7 @@ public function setMatchingConfig($matchingConfig) array_walk( $matchingConfig, - static function (&$item) { + static function (&$item): void { $item = trim($item, '/ '); } ); diff --git a/src/lib/MVC/Symfony/SiteAccess/Provider/StaticSiteAccessProvider.php b/src/lib/MVC/Symfony/SiteAccess/Provider/StaticSiteAccessProvider.php index 3041e593e0..91a6781bd3 100644 --- a/src/lib/MVC/Symfony/SiteAccess/Provider/StaticSiteAccessProvider.php +++ b/src/lib/MVC/Symfony/SiteAccess/Provider/StaticSiteAccessProvider.php @@ -66,7 +66,7 @@ private function createSiteAccess(string $name): SiteAccess { $siteAccess = new SiteAccess($name, SiteAccess::DEFAULT_MATCHING_TYPE, null, self::class); $siteAccess->groups = array_map( - static function ($groupName) { + static function ($groupName): \Ibexa\Core\MVC\Symfony\SiteAccessGroup { return new SiteAccessGroup($groupName); }, $this->groupsBySiteAccess[$name] ?? [] diff --git a/src/lib/MVC/Symfony/Templating/Twig/Extension/FieldRenderingExtension.php b/src/lib/MVC/Symfony/Templating/Twig/Extension/FieldRenderingExtension.php index 91eab082ed..3b32c3d11b 100644 --- a/src/lib/MVC/Symfony/Templating/Twig/Extension/FieldRenderingExtension.php +++ b/src/lib/MVC/Symfony/Templating/Twig/Extension/FieldRenderingExtension.php @@ -52,7 +52,7 @@ public function __construct( public function getFunctions(): array { - $renderFieldCallable = function (Environment $environment, Content|ContentAwareInterface $data, $fieldIdentifier, array $params = []) { + $renderFieldCallable = function (Environment $environment, Content|ContentAwareInterface $data, $fieldIdentifier, array $params = []): string { $this->fieldBlockRenderer->setTwig($environment); return $this->renderField($this->getContent($data), $fieldIdentifier, $params); @@ -63,7 +63,7 @@ function ( Environment $environment, FieldDefinition $fieldDefinition, array $params = [] - ) { + ): string { $this->fieldBlockRenderer->setTwig($environment); return $this->renderFieldDefinitionSettings($fieldDefinition, $params); diff --git a/src/lib/MVC/Symfony/View/Builder/ContentViewBuilder.php b/src/lib/MVC/Symfony/View/Builder/ContentViewBuilder.php index 8d06cb55ec..32da7c092e 100644 --- a/src/lib/MVC/Symfony/View/Builder/ContentViewBuilder.php +++ b/src/lib/MVC/Symfony/View/Builder/ContentViewBuilder.php @@ -208,7 +208,7 @@ private function loadContent($contentId, ?string $languageCode = null) private function loadEmbeddedContent($contentId, ?Location $location = null, ?string $languageCode = null) { $content = $this->repository->sudo( - static function (Repository $repository) use ($contentId, $languageCode) { + static function (Repository $repository) use ($contentId, $languageCode): \Ibexa\Contracts\Core\Repository\Values\Content\Content { return $repository->getContentService()->loadContent($contentId, $languageCode ? [$languageCode] : null); } ); @@ -242,7 +242,7 @@ static function (Repository $repository) use ($contentId, $languageCode) { private function loadLocation($locationId) { $location = $this->repository->sudo( - static function (Repository $repository) use ($locationId) { + static function (Repository $repository) use ($locationId): \Ibexa\Contracts\Core\Repository\Values\Content\Location { return $repository->getLocationService()->loadLocation($locationId); } ); diff --git a/src/lib/Persistence/Cache/Adapter/TransactionalInMemoryCacheAdapter.php b/src/lib/Persistence/Cache/Adapter/TransactionalInMemoryCacheAdapter.php index c3960ef0ba..4136ec8c7d 100644 --- a/src/lib/Persistence/Cache/Adapter/TransactionalInMemoryCacheAdapter.php +++ b/src/lib/Persistence/Cache/Adapter/TransactionalInMemoryCacheAdapter.php @@ -60,7 +60,7 @@ public function __construct( $this->deferredItemsDeletion = empty($deferredItemsDeletion) ? [] : \array_fill_keys($deferredItemsDeletion, true); // To modify protected $isHit when items are a "miss" based on deferred delete/invalidation during transactions $this->setCacheItemAsMiss = \Closure::bind( - static function (CacheItem $item) { + static function (CacheItem $item): void { // ... Might not work for anything but new items $item->isHit = false; }, diff --git a/src/lib/Persistence/Cache/BookmarkHandler.php b/src/lib/Persistence/Cache/BookmarkHandler.php index 46e8ee9988..02ab4bebb4 100644 --- a/src/lib/Persistence/Cache/BookmarkHandler.php +++ b/src/lib/Persistence/Cache/BookmarkHandler.php @@ -56,7 +56,7 @@ public function loadByUserIdAndLocationId(int $userId, array $locationIds): arra return $this->getMultipleCacheItems( $locationIds, $this->cacheIdentifierGenerator->generateKey(self::BOOKMARK_IDENTIFIER, [$userId], true) . '-', - function (array $missingIds) use ($userId) { + function (array $missingIds) use ($userId): array { $this->logger->logCall(__CLASS__ . '::loadByUserIdAndLocationId', [ 'userId' => $userId, 'locationIds' => $missingIds, @@ -64,7 +64,7 @@ function (array $missingIds) use ($userId) { return $this->persistenceHandler->bookmarkHandler()->loadByUserIdAndLocationId($userId, $missingIds); }, - function (Bookmark $bookmark) { + function (Bookmark $bookmark): array { $tags = [ $this->cacheIdentifierGenerator->generateTag(self::BOOKMARK_IDENTIFIER, [$bookmark->id]), $this->cacheIdentifierGenerator->generateTag(self::LOCATION_IDENTIFIER, [$bookmark->locationId]), diff --git a/src/lib/Persistence/Cache/ContentHandler.php b/src/lib/Persistence/Cache/ContentHandler.php index 32d88d3b05..1d1c335708 100644 --- a/src/lib/Persistence/Cache/ContentHandler.php +++ b/src/lib/Persistence/Cache/ContentHandler.php @@ -53,7 +53,7 @@ class ContentHandler extends AbstractInMemoryPersistenceHandler implements Conte protected function init(): void { - $this->getContentInfoTags = function (ContentInfo $info, array $tags = []) { + $this->getContentInfoTags = function (ContentInfo $info, array $tags = []): array { $tags[] = $this->cacheIdentifierGenerator->generateTag(self::CONTENT_IDENTIFIER, [$info->id]); if ($info->mainLocationId) { @@ -69,7 +69,7 @@ protected function init(): void return $tags; }; - $this->getContentInfoKeys = function (ContentInfo $info) { + $this->getContentInfoKeys = function (ContentInfo $info): array { return [ $this->cacheIdentifierGenerator->generateKey(self::CONTENT_INFO_IDENTIFIER, [$info->id], true), $this->cacheIdentifierGenerator->generateKey( @@ -80,7 +80,7 @@ protected function init(): void ]; }; - $this->getContentTags = function (Content $content) { + $this->getContentTags = function (Content $content): array { $versionInfo = $content->versionInfo; $tags = [ $this->cacheIdentifierGenerator->generateTag( @@ -154,11 +154,11 @@ public function load($contentId, $versionNo = null, ?array $translations = null) return $this->getCacheValue( (int) $contentId, $this->cacheIdentifierGenerator->generateKey(self::CONTENT_IDENTIFIER, [], true) . '-', - function ($id) use ($versionNo, $translations) { + function ($id) use ($versionNo, $translations): \Ibexa\Contracts\Core\Persistence\Content { return $this->persistenceHandler->contentHandler()->load($id, $versionNo, $translations); }, $this->getContentTags, - function (Content $content) use ($keySuffix) { + function (Content $content) use ($keySuffix): array { // Version number & translations is part of keySuffix here and depends on what user asked for return [ $this->cacheIdentifierGenerator->generateKey( @@ -180,11 +180,11 @@ public function loadContentList(array $contentIds, ?array $translations = null): return $this->getMultipleCacheValues( $contentIds, $this->cacheIdentifierGenerator->generateKey(self::CONTENT_IDENTIFIER, [], true) . '-', - function (array $cacheMissIds) use ($translations) { + function (array $cacheMissIds) use ($translations): iterable { return $this->persistenceHandler->contentHandler()->loadContentList($cacheMissIds, $translations); }, $this->getContentTags, - function (Content $content) use ($keySuffix) { + function (Content $content) use ($keySuffix): array { // Translations is part of keySuffix here and depends on what user asked for return [ $this->cacheIdentifierGenerator->generateKey( @@ -207,7 +207,7 @@ public function loadContentInfo($contentId) return $this->getCacheValue( $contentId, $this->cacheIdentifierGenerator->generateKey(self::CONTENT_INFO_IDENTIFIER, [], true) . '-', - function ($contentId) { + function ($contentId): \Ibexa\Contracts\Core\Persistence\Content\ContentInfo { return $this->persistenceHandler->contentHandler()->loadContentInfo($contentId); }, $this->getContentInfoTags, @@ -222,7 +222,7 @@ public function loadContentInfoList(array $contentIds) return $this->getMultipleCacheValues( $contentIds, $this->cacheIdentifierGenerator->generateKey(self::CONTENT_INFO_IDENTIFIER, [], true) . '-', - function (array $cacheMissIds) { + function (array $cacheMissIds): array { return $this->persistenceHandler->contentHandler()->loadContentInfoList($cacheMissIds); }, $this->getContentInfoTags, @@ -240,7 +240,7 @@ public function loadContentInfoByRemoteId($remoteId) return $this->getCacheValue( $this->cacheIdentifierSanitizer->escapeForCacheKey($remoteId), $this->cacheIdentifierGenerator->generateKey(self::CONTENT_INFO_BY_REMOTE_ID_IDENTIFIER, [], true) . '-', - function () use ($remoteId) { + function () use ($remoteId): \Ibexa\Contracts\Core\Persistence\Content\ContentInfo { return $this->persistenceHandler->contentHandler()->loadContentInfoByRemoteId($remoteId); }, $this->getContentInfoTags, @@ -383,7 +383,7 @@ public function deleteContent($contentId) if (!empty($reverseRelations)) { $tags = \array_map( - function ($relation) { + function ($relation): string { // only the full content object *with* fields is affected by this return $this->cacheIdentifierGenerator->generateTag(self::CONTENT_IDENTIFIER, [$relation->sourceContentId]); }, @@ -776,7 +776,7 @@ function (array $cacheMissIds): array { function (VersionInfo $versionInfo): array { return $this->getCacheTagsForVersion($versionInfo); }, - function (VersionInfo $versionInfo) { + function (VersionInfo $versionInfo): array { return [ $this->cacheIdentifierGenerator->generateKey( self::CONTENT_VERSION_INFO_IDENTIFIER, diff --git a/src/lib/Persistence/Cache/ContentLanguageHandler.php b/src/lib/Persistence/Cache/ContentLanguageHandler.php index 94f90c2fa5..5b4e541adb 100644 --- a/src/lib/Persistence/Cache/ContentLanguageHandler.php +++ b/src/lib/Persistence/Cache/ContentLanguageHandler.php @@ -28,12 +28,12 @@ class ContentLanguageHandler extends AbstractInMemoryPersistenceHandler implemen */ protected function init(): void { - $this->getTags = function (Language $language) { + $this->getTags = function (Language $language): array { return [ $this->cacheIdentifierGenerator->generateTag(self::LANGUAGE_IDENTIFIER, [$language->id]), ]; }; - $this->getKeys = function (Language $language) { + $this->getKeys = function (Language $language): array { return [ $this->cacheIdentifierGenerator->generateKey(self::LANGUAGE_IDENTIFIER, [$language->id], true), $this->cacheIdentifierGenerator->generateKey( @@ -87,7 +87,7 @@ public function load($id) return $this->getCacheValue( $id, $this->cacheIdentifierGenerator->generateKey(self::LANGUAGE_IDENTIFIER, [], true) . '-', - function ($id) { + function ($id): \Ibexa\Contracts\Core\Persistence\Content\Language { return $this->persistenceHandler->contentLanguageHandler()->load($id); }, $this->getTags, @@ -103,7 +103,7 @@ public function loadList(array $ids): iterable return $this->getMultipleCacheValues( $ids, $this->cacheIdentifierGenerator->generateKey(self::LANGUAGE_IDENTIFIER, [], true) . '-', - function (array $ids) { + function (array $ids): iterable { return $this->persistenceHandler->contentLanguageHandler()->loadList($ids); }, $this->getTags, @@ -119,7 +119,7 @@ public function loadByLanguageCode($languageCode) return $this->getCacheValue( $this->cacheIdentifierSanitizer->escapeForCacheKey($languageCode), $this->cacheIdentifierGenerator->generateKey(self::LANGUAGE_CODE_IDENTIFIER, [], true) . '-', - function () use ($languageCode) { + function () use ($languageCode): \Ibexa\Contracts\Core\Persistence\Content\Language { return $this->persistenceHandler->contentLanguageHandler()->loadByLanguageCode($languageCode); }, $this->getTags, @@ -135,7 +135,7 @@ public function loadListByLanguageCodes(array $languageCodes): iterable return $this->getMultipleCacheValues( array_map([$this->cacheIdentifierSanitizer, 'escapeForCacheKey'], $languageCodes), $this->cacheIdentifierGenerator->generateKey(self::LANGUAGE_CODE_IDENTIFIER, [], true) . '-', - function () use ($languageCodes) { + function () use ($languageCodes): iterable { return $this->persistenceHandler->contentLanguageHandler()->loadListByLanguageCodes($languageCodes); }, $this->getTags, @@ -150,7 +150,7 @@ public function loadAll() { return $this->getListCacheValue( $this->cacheIdentifierGenerator->generateKey(self::LANGUAGE_LIST_IDENTIFIER, [], true), - function () { + function (): array { return $this->persistenceHandler->contentLanguageHandler()->loadAll(); }, $this->getTags, diff --git a/src/lib/Persistence/Cache/ContentTypeHandler.php b/src/lib/Persistence/Cache/ContentTypeHandler.php index 5564eec010..72fe803394 100644 --- a/src/lib/Persistence/Cache/ContentTypeHandler.php +++ b/src/lib/Persistence/Cache/ContentTypeHandler.php @@ -52,13 +52,13 @@ class ContentTypeHandler extends AbstractInMemoryPersistenceHandler implements C */ protected function init(): void { - $this->getGroupTags = function (Type\Group $group) { + $this->getGroupTags = function (Type\Group $group): array { return [ $this->cacheIdentifierGenerator->generateTag(self::TYPE_GROUP_IDENTIFIER, [$group->id]), ]; }; - $this->getGroupKeys = function (Type\Group $group) { + $this->getGroupKeys = function (Type\Group $group): array { return [ $this->cacheIdentifierGenerator->generateKey(self::CONTENT_TYPE_GROUP_IDENTIFIER, [$group->id]), $this->cacheIdentifierGenerator->generateKey( @@ -69,13 +69,13 @@ protected function init(): void ]; }; - $this->getTypeTags = function (Type $type) { + $this->getTypeTags = function (Type $type): array { return [ $this->cacheIdentifierGenerator->generateTag(self::TYPE_IDENTIFIER), // For use by deleteByUserAndStatus() as it currently lacks return value for affected type ids $this->cacheIdentifierGenerator->generateTag(self::TYPE_IDENTIFIER, [$type->id]), ]; }; - $this->getTypeKeys = function (Type $type, int $status = Type::STATUS_DEFINED) { + $this->getTypeKeys = function (Type $type, int $status = Type::STATUS_DEFINED): array { return [ $this->cacheIdentifierGenerator->generateKey(self::CONTENT_TYPE_IDENTIFIER, [$type->id], true), $this->cacheIdentifierGenerator->generateKey(self::CONTENT_TYPE_IDENTIFIER, [$type->id], true) . '-' . $status, @@ -150,7 +150,7 @@ public function loadGroup($groupId) return $this->getCacheValue( $groupId, $this->cacheIdentifierGenerator->generateKey(self::CONTENT_TYPE_GROUP_IDENTIFIER, [], true) . '-', - function ($groupId) { + function ($groupId): \Ibexa\Contracts\Core\Persistence\Content\Type\Group { return $this->persistenceHandler->contentTypeHandler()->loadGroup($groupId); }, $this->getGroupTags, @@ -166,7 +166,7 @@ public function loadGroups(array $groupIds) return $this->getMultipleCacheValues( $groupIds, $this->cacheIdentifierGenerator->generateKey(self::CONTENT_TYPE_GROUP_IDENTIFIER, [], true) . '-', - function (array $groupIds) { + function (array $groupIds): array { return $this->persistenceHandler->contentTypeHandler()->loadGroups($groupIds); }, $this->getGroupTags, @@ -182,7 +182,7 @@ public function loadGroupByIdentifier($identifier) return $this->getCacheValue( $this->cacheIdentifierSanitizer->escapeForCacheKey($identifier), $this->cacheIdentifierGenerator->generateKey(self::CONTENT_TYPE_GROUP_IDENTIFIER, [], true) . '-', - function () use ($identifier) { + function () use ($identifier): \Ibexa\Contracts\Core\Persistence\Content\Type\Group { return $this->persistenceHandler->contentTypeHandler()->loadGroupByIdentifier($identifier); }, $this->getGroupTags, @@ -198,7 +198,7 @@ public function loadAllGroups() { return $this->getListCacheValue( $this->cacheIdentifierGenerator->generateKey(self::CONTENT_TYPE_GROUP_LIST_IDENTIFIER, [], true), - function () { + function (): array { return $this->persistenceHandler->contentTypeHandler()->loadAllGroups(); }, $this->getGroupTags, @@ -219,13 +219,13 @@ public function loadContentTypes($groupId, $status = Type::STATUS_DEFINED) return $this->getListCacheValue( $this->cacheIdentifierGenerator->generateKey(self::CONTENT_TYPE_LIST_BY_GROUP_IDENTIFIER, [$groupId], true), - function () use ($groupId, $status) { + function () use ($groupId, $status): array { return $this->persistenceHandler->contentTypeHandler()->loadContentTypes($groupId, $status); }, $this->getTypeTags, $this->getTypeKeys, // Add tag in case of empty list - function () use ($groupId) { + function () use ($groupId): array { return [ $this->cacheIdentifierGenerator->generateTag(self::TYPE_GROUP_IDENTIFIER, [$groupId]), ]; @@ -248,7 +248,7 @@ public function loadContentTypeList(array $contentTypeIds): array return $this->getMultipleCacheValues( $contentTypeIds, $this->cacheIdentifierGenerator->generateKey(self::CONTENT_TYPE_IDENTIFIER, [], true) . '-', - function (array $contentTypeIds) { + function (array $contentTypeIds): array { return $this->persistenceHandler->contentTypeHandler()->loadContentTypeList($contentTypeIds); }, $this->getTypeTags, @@ -272,11 +272,11 @@ public function load($typeId, $status = Type::STATUS_DEFINED) return $this->getCacheValue( $typeId, $this->cacheIdentifierGenerator->generateKey(self::CONTENT_TYPE_IDENTIFIER, [], true) . '-', - function ($typeId) use ($status) { + function ($typeId) use ($status): \Ibexa\Contracts\Core\Persistence\Content\Type { return $this->persistenceHandler->contentTypeHandler()->load($typeId, $status); }, $this->getTypeTags, - static function (Type $type) use ($status, $getTypeKeysFn) { + static function (Type $type) use ($status, $getTypeKeysFn): array { return $getTypeKeysFn($type, $status); } ); @@ -290,7 +290,7 @@ public function loadByIdentifier($identifier) return $this->getCacheValue( $this->cacheIdentifierSanitizer->escapeForCacheKey($identifier), $this->cacheIdentifierGenerator->generateKey(self::CONTENT_TYPE_IDENTIFIER, [], true) . '-', - function () use ($identifier) { + function () use ($identifier): \Ibexa\Contracts\Core\Persistence\Content\Type { return $this->persistenceHandler->contentTypeHandler()->loadByIdentifier($identifier); }, $this->getTypeTags, @@ -307,7 +307,7 @@ public function loadByRemoteId($remoteId) return $this->getCacheValue( $this->cacheIdentifierSanitizer->escapeForCacheKey($remoteId), $this->cacheIdentifierGenerator->generateKey(self::CONTENT_TYPE_IDENTIFIER, [], true) . '-', - function () use ($remoteId) { + function () use ($remoteId): \Ibexa\Contracts\Core\Persistence\Content\Type { return $this->persistenceHandler->contentTypeHandler()->loadByRemoteId($remoteId); }, $this->getTypeTags, @@ -341,7 +341,7 @@ public function create(CreateStruct $struct) // Clear loadContentTypes() cache as we effetely add an item to it's collection here. $this->cache->deleteItems(array_map( - function ($groupId) { + function ($groupId): string { return $this->cacheIdentifierGenerator->generateKey( self::CONTENT_TYPE_LIST_BY_GROUP_IDENTIFIER, [$groupId], @@ -412,7 +412,7 @@ public function copy($userId, $typeId, $status) // Clear loadContentTypes() cache as we effetely add an item to it's collection here. $this->cache->deleteItems(array_map( - function ($groupId) { + function ($groupId): string { return $this->cacheIdentifierGenerator->generateKey(self::CONTENT_TYPE_LIST_BY_GROUP_IDENTIFIER, [$groupId], true); }, $copy->groupIds @@ -575,7 +575,7 @@ public function publish($typeId) $contentType = $this->load($typeId); $this->cache->deleteItems( array_map( - function ($groupId) { + function ($groupId): string { return $this->cacheIdentifierGenerator->generateKey( self::CONTENT_TYPE_LIST_BY_GROUP_IDENTIFIER, [$groupId], @@ -594,12 +594,12 @@ public function getSearchableFieldMap() { return $this->getListCacheValue( $this->cacheIdentifierGenerator->generateKey(self::CONTENT_TYPE_FIELD_MAP_IDENTIFIER, [], true), - function () { + function (): array { return $this->persistenceHandler->contentTypeHandler()->getSearchableFieldMap(); }, - static function () {return [];}, - static function () {return [];}, - function () { + static function (): array {return [];}, + static function (): array {return [];}, + function (): array { return [ $this->cacheIdentifierGenerator->generateTag(self::TYPE_MAP_IDENTIFIER), ]; diff --git a/src/lib/Persistence/Cache/LocationHandler.php b/src/lib/Persistence/Cache/LocationHandler.php index da55c46387..5f4554e09b 100644 --- a/src/lib/Persistence/Cache/LocationHandler.php +++ b/src/lib/Persistence/Cache/LocationHandler.php @@ -32,7 +32,7 @@ class LocationHandler extends AbstractInMemoryPersistenceHandler implements Loca protected function init(): void { - $this->getLocationTags = function (Location $location) { + $this->getLocationTags = function (Location $location): array { $tags = [ $this->cacheIdentifierGenerator->generateTag(self::CONTENT_IDENTIFIER, [$location->contentId]), $this->cacheIdentifierGenerator->generateTag(self::LOCATION_IDENTIFIER, [$location->id]), @@ -46,7 +46,7 @@ protected function init(): void return $tags; }; - $this->getLocationKeys = function (Location $location, $keySuffix = '-1') { + $this->getLocationKeys = function (Location $location, $keySuffix = '-1'): array { return [ $this->cacheIdentifierGenerator->generateKey(self::LOCATION_IDENTIFIER, [$location->id], true) . $keySuffix, $this->cacheIdentifierGenerator->generateKey( @@ -69,11 +69,11 @@ public function load($locationId, ?array $translations = null, bool $useAlwaysAv return $this->getCacheValue( (int) $locationId, $this->cacheIdentifierGenerator->generateKey(self::LOCATION_IDENTIFIER, [], true) . '-', - function ($id) use ($translations, $useAlwaysAvailable) { + function ($id) use ($translations, $useAlwaysAvailable): \Ibexa\Contracts\Core\Persistence\Content\Location { return $this->persistenceHandler->locationHandler()->load($id, $translations, $useAlwaysAvailable); }, $this->getLocationTags, - static function (Location $location) use ($keySuffix, $getLocationKeysFn) { + static function (Location $location) use ($keySuffix, $getLocationKeysFn): array { return $getLocationKeysFn($location, $keySuffix); }, $keySuffix, @@ -89,11 +89,11 @@ public function loadList(array $locationIds, ?array $translations = null, bool $ return $this->getMultipleCacheValues( $locationIds, $this->cacheIdentifierGenerator->generateKey(self::LOCATION_IDENTIFIER, [], true) . '-', - function (array $ids) use ($translations, $useAlwaysAvailable) { + function (array $ids) use ($translations, $useAlwaysAvailable): iterable { return $this->persistenceHandler->locationHandler()->loadList($ids, $translations, $useAlwaysAvailable); }, $this->getLocationTags, - static function (Location $location) use ($keySuffix, $getLocationKeysFn) { + static function (Location $location) use ($keySuffix, $getLocationKeysFn): array { return $getLocationKeysFn($location, $keySuffix); }, $keySuffix, @@ -231,11 +231,11 @@ public function loadByRemoteId($remoteId, ?array $translations = null, bool $use return $this->getCacheValue( $this->cacheIdentifierSanitizer->escapeForCacheKey($remoteId), $this->cacheIdentifierGenerator->generateKey(self::LOCATION_REMOTE_ID_IDENTIFIER, [], true) . '-', - function () use ($remoteId, $translations, $useAlwaysAvailable) { + function () use ($remoteId, $translations, $useAlwaysAvailable): \Ibexa\Contracts\Core\Persistence\Content\Location { return $this->persistenceHandler->locationHandler()->loadByRemoteId($remoteId, $translations, $useAlwaysAvailable); }, $this->getLocationTags, - static function (Location $location) use ($keySuffix, $getLocationKeysFn) { + static function (Location $location) use ($keySuffix, $getLocationKeysFn): array { return $getLocationKeysFn($location, $keySuffix); }, $keySuffix, diff --git a/src/lib/Persistence/Cache/ObjectStateHandler.php b/src/lib/Persistence/Cache/ObjectStateHandler.php index a1dd875ecb..b4027cbe4c 100644 --- a/src/lib/Persistence/Cache/ObjectStateHandler.php +++ b/src/lib/Persistence/Cache/ObjectStateHandler.php @@ -61,7 +61,7 @@ function () use ($groupId): array { $this->cacheIdentifierGenerator->generateTag(self::STATE_GROUP_IDENTIFIER, [(int) $groupId]), ]; }, - function () use ($groupId) { + function () use ($groupId): array { return [ $this->cacheIdentifierGenerator->generateKey(self::STATE_GROUP_IDENTIFIER, [(int) $groupId], true), ]; diff --git a/src/lib/Persistence/Cache/TrashHandler.php b/src/lib/Persistence/Cache/TrashHandler.php index 25a1c939ec..6127bc942a 100644 --- a/src/lib/Persistence/Cache/TrashHandler.php +++ b/src/lib/Persistence/Cache/TrashHandler.php @@ -50,7 +50,7 @@ public function trashSubtree($locationId) $relationTags = []; if (!empty($reverseRelations)) { - $relationTags = array_map(function (Relation $relation) { + $relationTags = array_map(function (Relation $relation): string { return $this->cacheIdentifierGenerator->generateTag( self::CONTENT_IDENTIFIER, [$relation->destinationContentId] @@ -101,7 +101,7 @@ public function recover($trashedId, $newParentId) $relationTags = []; if (!empty($reverseRelations)) { - $relationTags = array_map(function (Relation $relation) { + $relationTags = array_map(function (Relation $relation): string { return $this->cacheIdentifierGenerator->generateTag(self::CONTENT_IDENTIFIER, [$relation->destinationContentId]); }, $reverseRelations); } @@ -185,7 +185,7 @@ public function deleteTrashItem($trashedId) $reverseRelations = $this->persistenceHandler->contentHandler()->loadReverseRelations($trashed->contentId); - $relationTags = array_map(function (Relation $relation) { + $relationTags = array_map(function (Relation $relation): string { return $this->cacheIdentifierGenerator->generateTag(self::CONTENT_IDENTIFIER, [$relation->sourceContentId]); }, $reverseRelations); diff --git a/src/lib/Persistence/Cache/URLHandler.php b/src/lib/Persistence/Cache/URLHandler.php index b06b007be8..2eaa108340 100644 --- a/src/lib/Persistence/Cache/URLHandler.php +++ b/src/lib/Persistence/Cache/URLHandler.php @@ -33,7 +33,7 @@ public function updateUrl($id, URLUpdateStruct $struct) ]); if ($struct->url !== null) { - $this->cache->invalidateTags(array_map(function ($id) { + $this->cache->invalidateTags(array_map(function ($id): string { return $this->cacheIdentifierGenerator->generateTag(self::CONTENT_IDENTIFIER, [$id]); }, $this->persistenceHandler->urlHandler()->findUsages($id))); } diff --git a/src/lib/Persistence/Cache/UrlAliasHandler.php b/src/lib/Persistence/Cache/UrlAliasHandler.php index 89b2d4a025..550e044f8c 100644 --- a/src/lib/Persistence/Cache/UrlAliasHandler.php +++ b/src/lib/Persistence/Cache/UrlAliasHandler.php @@ -156,10 +156,10 @@ public function listURLAliasesForLocation($locationId, $custom = false) ($custom) ? $this->cacheIdentifierGenerator->generateKey(self::URL_ALIAS_LOCATION_LIST_CUSTOM_IDENTIFIER, [$locationId], true) : $this->cacheIdentifierGenerator->generateKey(self::URL_ALIAS_LOCATION_LIST_IDENTIFIER, [$locationId], true), - function () use ($locationId, $custom) { + function () use ($locationId, $custom): array { return $this->persistenceHandler->urlAliasHandler()->listURLAliasesForLocation($locationId, $custom); }, - function (UrlAlias $alias) { + function (UrlAlias $alias): array { $tags = [ $this->cacheIdentifierGenerator->generateTag(self::URL_ALIAS_IDENTIFIER, [$alias->id]), ]; @@ -176,8 +176,8 @@ function (UrlAlias $alias) { return $tags; }, - static function () { return []; }, - function () use ($locationId) { + static function (): array { return []; }, + function () use ($locationId): array { return [ $this->cacheIdentifierGenerator->generateTag(self::URL_ALIAS_LOCATION_IDENTIFIER, [$locationId]), ]; diff --git a/src/lib/Persistence/Cache/UserHandler.php b/src/lib/Persistence/Cache/UserHandler.php index efd4371955..9c1350875a 100644 --- a/src/lib/Persistence/Cache/UserHandler.php +++ b/src/lib/Persistence/Cache/UserHandler.php @@ -68,13 +68,13 @@ class UserHandler extends AbstractInMemoryPersistenceHandler implements UserHand */ public function init(): void { - $this->getUserTags = function (User $user) { + $this->getUserTags = function (User $user): array { return [ $this->cacheIdentifierGenerator->generateTag(self::CONTENT_IDENTIFIER, [$user->id]), $this->cacheIdentifierGenerator->generateTag(self::USER_IDENTIFIER, [$user->id]), ]; }; - $this->getUserKeys = function (User $user) { + $this->getUserKeys = function (User $user): array { return [ $this->cacheIdentifierGenerator->generateKey(self::USER_IDENTIFIER, [$user->id], true), $this->cacheIdentifierGenerator->generateKey( @@ -89,12 +89,12 @@ public function init(): void ), ]; }; - $this->getRoleTags = function (Role $role) { + $this->getRoleTags = function (Role $role): array { return [ $this->cacheIdentifierGenerator->generateTag(self::ROLE_IDENTIFIER, [$role->id]), ]; }; - $this->getRoleKeys = function (Role $role) { + $this->getRoleKeys = function (Role $role): array { return [ $this->cacheIdentifierGenerator->generateKey(self::ROLE_IDENTIFIER, [$role->id], true), $this->cacheIdentifierGenerator->generateKey( @@ -104,14 +104,14 @@ public function init(): void ), ]; }; - $this->getRoleAssignmentTags = function (RoleAssignment $roleAssignment) { + $this->getRoleAssignmentTags = function (RoleAssignment $roleAssignment): array { return [ $this->cacheIdentifierGenerator->generateTag(self::ROLE_ASSIGNMENT_IDENTIFIER, [$roleAssignment->id]), $this->cacheIdentifierGenerator->generateTag(self::ROLE_ASSIGNMENT_GROUP_LIST_IDENTIFIER, [$roleAssignment->contentId]), $this->cacheIdentifierGenerator->generateTag(self::ROLE_ASSIGNMENT_ROLE_LIST_IDENTIFIER, [$roleAssignment->roleId]), ]; }; - $this->getRoleAssignmentKeys = function (RoleAssignment $roleAssignment) { + $this->getRoleAssignmentKeys = function (RoleAssignment $roleAssignment): array { return [ $this->cacheIdentifierGenerator->generateKey(self::ROLE_ASSIGNMENT_IDENTIFIER, [$roleAssignment->id], true), ]; @@ -160,7 +160,7 @@ public function load($userId) return $this->getCacheValue( $userId, $this->cacheIdentifierGenerator->generateKey(self::USER_IDENTIFIER, [], true) . '-', - function ($userId) { + function ($userId): \Ibexa\Contracts\Core\Persistence\User { return $this->persistenceHandler->userHandler()->load($userId); }, $this->getUserTags, @@ -176,7 +176,7 @@ public function loadByLogin($login) return $this->getCacheValue( $this->cacheIdentifierSanitizer->escapeForCacheKey($login), $this->cacheIdentifierGenerator->generateKey(self::USER_IDENTIFIER, [], true) . '-', - function () use ($login) { + function () use ($login): \Ibexa\Contracts\Core\Persistence\User { return $this->persistenceHandler->userHandler()->loadByLogin($login); }, $this->getUserTags, @@ -194,7 +194,7 @@ public function loadByEmail(string $email): User $cachedValue = $this->getCacheValue( $this->cacheIdentifierSanitizer->escapeForCacheKey($email), $this->cacheIdentifierGenerator->generateKey(self::USER_IDENTIFIER, [], true) . '-', - function () use ($email) { + function () use ($email): \Ibexa\Contracts\Core\Persistence\User { return $this->persistenceHandler->userHandler()->loadByEmail($email); }, $this->getUserTags, @@ -217,7 +217,7 @@ public function loadUsersByEmail(string $email): array [$this->cacheIdentifierSanitizer->escapeForCacheKey($email)], true ), - function () use ($email) { + function () use ($email): array { return $this->persistenceHandler->userHandler()->loadUsersByEmail($email); }, $this->getUserTags, @@ -236,17 +236,17 @@ public function loadUserByToken($hash) return $this->getCacheValue( $hash, $this->cacheIdentifierGenerator->generateKey(self::USER_IDENTIFIER, [], true) . '-', - function ($hash) { + function ($hash): \Ibexa\Contracts\Core\Persistence\User { return $this->persistenceHandler->userHandler()->loadUserByToken($hash); }, - function (User $user) use ($getUserTagsFn) { + function (User $user) use ($getUserTagsFn): array { $tags = $getUserTagsFn($user); // See updateUserToken() $tags[] = $this->cacheIdentifierGenerator->generateTag(self::USER_WITH_ACCOUNT_KEY_SUFFIX_IDENTIFIER, [$user->id]); return $tags; }, - function (User $user) use ($hash, $getUserKeysFn) { + function (User $user) use ($hash, $getUserKeysFn): array { $keys = $getUserKeysFn($user); $keys[] = $this->cacheIdentifierGenerator->generateKey(self::USER_WITH_BY_ACCOUNT_KEY_SUFFIX_IDENTIFIER, [$hash], true); @@ -407,7 +407,7 @@ public function loadRole($roleId, $status = Role::STATUS_DEFINED) return $this->getCacheValue( $roleId, $this->cacheIdentifierGenerator->generateKey(self::ROLE_IDENTIFIER, [], true) . '-', - function ($roleId) { + function ($roleId): \Ibexa\Contracts\Core\Persistence\User\Role { return $this->persistenceHandler->userHandler()->loadRole($roleId); }, $this->getRoleTags, @@ -429,7 +429,7 @@ public function loadRoleByIdentifier($identifier, $status = Role::STATUS_DEFINED return $this->getCacheValue( $this->cacheIdentifierSanitizer->escapeForCacheKey($identifier), $this->cacheIdentifierGenerator->generateKey(self::ROLE_IDENTIFIER, [], true) . '-', - function () use ($identifier) { + function () use ($identifier): \Ibexa\Contracts\Core\Persistence\User\Role { return $this->persistenceHandler->userHandler()->loadRoleByIdentifier($identifier); }, $this->getRoleTags, @@ -466,7 +466,7 @@ public function loadRoleAssignment($roleAssignmentId) return $this->getCacheValue( $roleAssignmentId, $this->cacheIdentifierGenerator->generateKey(self::ROLE_ASSIGNMENT_IDENTIFIER, [], true) . '-', - function ($roleAssignmentId) { + function ($roleAssignmentId): \Ibexa\Contracts\Core\Persistence\User\RoleAssignment { return $this->persistenceHandler->userHandler()->loadRoleAssignment($roleAssignmentId); }, $this->getRoleAssignmentTags, @@ -481,13 +481,13 @@ public function loadRoleAssignmentsByRoleId($roleId) { return $this->getListCacheValue( $this->cacheIdentifierGenerator->generateKey(self::ROLE_ASSIGNMENT_WITH_BY_ROLE_SUFFIX_IDENTIFIER, [$roleId], true), - function () use ($roleId) { + function () use ($roleId): array { return $this->persistenceHandler->userHandler()->loadRoleAssignmentsByRoleId($roleId); }, $this->getRoleAssignmentTags, $this->getRoleAssignmentKeys, /* Role update (policies) changes role assignment id, also need list tag in case of empty result */ - function () use ($roleId) { + function () use ($roleId): array { return [ $this->cacheIdentifierGenerator->generateTag(self::ROLE_ASSIGNMENT_ROLE_LIST_IDENTIFIER, [$roleId]), $this->cacheIdentifierGenerator->generateTag(self::ROLE_IDENTIFIER, [$roleId]), @@ -556,12 +556,12 @@ public function loadRoleAssignmentsByGroupId($groupId, $inherit = false) return $this->getListCacheValue( $key, - function () use ($groupId, $inherit) { + function () use ($groupId, $inherit): array { return $this->persistenceHandler->userHandler()->loadRoleAssignmentsByGroupId($groupId, $inherit); }, $this->getRoleAssignmentTags, $this->getRoleAssignmentKeys, - function () use ($groupId, $innerHandler) { + function () use ($groupId, $innerHandler): array { // Tag needed for empty results, if not empty will alse be added by getRoleAssignmentTags(). $cacheTags = [ $this->cacheIdentifierGenerator->generateTag(self::ROLE_ASSIGNMENT_GROUP_LIST_IDENTIFIER, [$groupId]), diff --git a/src/lib/Persistence/Cache/UserPreferenceHandler.php b/src/lib/Persistence/Cache/UserPreferenceHandler.php index d1ad67fb07..f648006f98 100644 --- a/src/lib/Persistence/Cache/UserPreferenceHandler.php +++ b/src/lib/Persistence/Cache/UserPreferenceHandler.php @@ -66,7 +66,7 @@ public function getUserPreferenceByUserIdAndName(int $userId, string $name): Use $userPreference = $this->getCacheValue( $userId, $this->cacheIdentifierGenerator->generateKey(self::USER_PREFERENCE_IDENTIFIER, [], true) . '-', - function ($userId) use ($name) { + function ($userId) use ($name): string|UserPreference { try { return $this->persistenceHandler->userPreferenceHandler()->getUserPreferenceByUserIdAndName( $userId, @@ -76,10 +76,10 @@ function ($userId) use ($name) { return self::NOT_FOUND; } }, - static function () { + static function (): array { return []; }, - function () use ($userId, $name) { + function () use ($userId, $name): array { return [ $this->cacheIdentifierGenerator->generateKey( self::USER_PREFERENCE_WITH_SUFFIX_IDENTIFIER, diff --git a/src/lib/Persistence/Legacy/Content/Handler.php b/src/lib/Persistence/Legacy/Content/Handler.php index c5f05a36ba..771d020c6a 100644 --- a/src/lib/Persistence/Legacy/Content/Handler.php +++ b/src/lib/Persistence/Legacy/Content/Handler.php @@ -530,7 +530,7 @@ public function loadDraftsForUser($userId) } $idVersionPairs = array_map( - static function ($row) { + static function ($row): array { return [ 'id' => $row['content_version_contentobject_id'], 'version' => $row['content_version_version'], diff --git a/src/lib/Persistence/Legacy/Content/Language/CachingHandler.php b/src/lib/Persistence/Legacy/Content/Language/CachingHandler.php index 5c692fbc8b..d18e7863e9 100644 --- a/src/lib/Persistence/Legacy/Content/Language/CachingHandler.php +++ b/src/lib/Persistence/Legacy/Content/Language/CachingHandler.php @@ -243,7 +243,7 @@ protected function storeCache(array $languages, ?string $listIndex = null): void $this->cache->setMulti( $languages, - static function (Language $language) use ($generator) { + static function (Language $language) use ($generator): array { return [ $generator->generateKey(self::LANGUAGE_IDENTIFIER, [$language->id], true), $generator->generateKey(self::LANGUAGE_CODE_IDENTIFIER, [$language->languageCode], true), diff --git a/src/lib/Persistence/Legacy/Content/TreeHandler.php b/src/lib/Persistence/Legacy/Content/TreeHandler.php index 8a74bb1396..51a7ad2158 100644 --- a/src/lib/Persistence/Legacy/Content/TreeHandler.php +++ b/src/lib/Persistence/Legacy/Content/TreeHandler.php @@ -136,7 +136,7 @@ public function listVersions($contentId, $status = null, $limit = -1) } $idVersionPairs = array_map( - static function ($row) use ($contentId) { + static function ($row) use ($contentId): array { return [ 'id' => $contentId, 'version' => $row['content_version_version'], diff --git a/src/lib/Persistence/Legacy/Content/Type/ContentUpdater/Action/AddField.php b/src/lib/Persistence/Legacy/Content/Type/ContentUpdater/Action/AddField.php index 4cda931523..409525f1d1 100644 --- a/src/lib/Persistence/Legacy/Content/Type/ContentUpdater/Action/AddField.php +++ b/src/lib/Persistence/Legacy/Content/Type/ContentUpdater/Action/AddField.php @@ -81,7 +81,7 @@ public function apply($contentId) $nameRows = $this->contentGateway->loadVersionedNameData( array_map( - static function ($versionNo) use ($contentId) { + static function ($versionNo) use ($contentId): array { return ['id' => $contentId, 'version' => $versionNo]; }, $versionNumbers diff --git a/src/lib/Persistence/Legacy/Content/Type/ContentUpdater/Action/RemoveField.php b/src/lib/Persistence/Legacy/Content/Type/ContentUpdater/Action/RemoveField.php index 47e7390d03..60324b826b 100644 --- a/src/lib/Persistence/Legacy/Content/Type/ContentUpdater/Action/RemoveField.php +++ b/src/lib/Persistence/Legacy/Content/Type/ContentUpdater/Action/RemoveField.php @@ -67,7 +67,7 @@ public function apply($contentId) $nameRows = $this->contentGateway->loadVersionedNameData( array_map( - static function ($versionNo) use ($contentId) { + static function ($versionNo) use ($contentId): array { return ['id' => $contentId, 'version' => $versionNo]; }, $versionNumbers diff --git a/src/lib/Persistence/Legacy/Content/Type/Mapper.php b/src/lib/Persistence/Legacy/Content/Type/Mapper.php index 1aa365a799..202846b5d8 100644 --- a/src/lib/Persistence/Legacy/Content/Type/Mapper.php +++ b/src/lib/Persistence/Legacy/Content/Type/Mapper.php @@ -168,7 +168,7 @@ public function extractTypesFromRows(array $rows, bool $keepTypeIdAsKey = false) public function extractMultilingualData(array $fieldDefinitionRows): array { - return array_map(static function (array $fieldData) { + return array_map(static function (array $fieldData): array { return [ 'content_type_field_definition_multilingual_name' => $fieldData['content_type_field_definition_multilingual_name'] ?? null, 'content_type_field_definition_multilingual_description' => $fieldData['content_type_field_definition_multilingual_description'] ?? null, diff --git a/src/lib/Persistence/Legacy/Content/UrlAlias/Handler.php b/src/lib/Persistence/Legacy/Content/UrlAlias/Handler.php index fcdebfa7ce..8edd697e01 100644 --- a/src/lib/Persistence/Legacy/Content/UrlAlias/Handler.php +++ b/src/lib/Persistence/Legacy/Content/UrlAlias/Handler.php @@ -1121,7 +1121,7 @@ public function archiveUrlAliasesForDeletedTranslations($locationId, $parentLoca // map languageCodes to their IDs $languageIds = array_map( - function ($languageCode) { + function ($languageCode): int { return $this->languageHandler->loadByLanguageCode($languageCode)->id; }, $removedLanguages diff --git a/src/lib/Persistence/Legacy/Filter/Gateway/Content/Mapper/DoctrineGatewayDataMapper.php b/src/lib/Persistence/Legacy/Filter/Gateway/Content/Mapper/DoctrineGatewayDataMapper.php index 2b300710dd..dca3515a2b 100644 --- a/src/lib/Persistence/Legacy/Filter/Gateway/Content/Mapper/DoctrineGatewayDataMapper.php +++ b/src/lib/Persistence/Legacy/Filter/Gateway/Content/Mapper/DoctrineGatewayDataMapper.php @@ -126,7 +126,7 @@ private function mapFieldDataToPersistenceFieldList( int $versionNo ): array { return array_map( - function (array $row) use ($versionNo) { + function (array $row) use ($versionNo): Field { $field = new Field(); $field->id = (int)$row['field_id']; $field->fieldDefinitionId = (int)$row['field_definition_id']; diff --git a/src/lib/Persistence/Legacy/Token/AbstractGateway.php b/src/lib/Persistence/Legacy/Token/AbstractGateway.php index 4d8b8f9752..db7a0470bb 100644 --- a/src/lib/Persistence/Legacy/Token/AbstractGateway.php +++ b/src/lib/Persistence/Legacy/Token/AbstractGateway.php @@ -18,7 +18,7 @@ protected function getAliasedColumns( array $columns ): array { return array_map( - fn (string $column) => $this->getAliasedColumn($column, $alias), + fn (string $column): string => $this->getAliasedColumn($column, $alias), $columns ); } diff --git a/src/lib/Persistence/Legacy/User/Mapper.php b/src/lib/Persistence/Legacy/User/Mapper.php index 22b03cc25b..e900f5a7f2 100644 --- a/src/lib/Persistence/Legacy/User/Mapper.php +++ b/src/lib/Persistence/Legacy/User/Mapper.php @@ -195,7 +195,7 @@ public function mapRoleAssignments(array $data) $roleAssignments = []; array_walk_recursive( $roleAssignmentData, - static function ($roleAssignment) use (&$roleAssignments) { + static function ($roleAssignment) use (&$roleAssignments): void { $roleAssignments[] = $roleAssignment; } ); diff --git a/src/lib/Persistence/TransformationProcessor/PcreCompiler.php b/src/lib/Persistence/TransformationProcessor/PcreCompiler.php index d10d865f6e..be870ea705 100644 --- a/src/lib/Persistence/TransformationProcessor/PcreCompiler.php +++ b/src/lib/Persistence/TransformationProcessor/PcreCompiler.php @@ -223,7 +223,7 @@ protected function compileTargetCharacter($char) }; case $char === 'keep': - return static function ($matches) { + return static function ($matches): string { return $matches[0]; }; @@ -234,14 +234,14 @@ protected function compileTargetCharacter($char) substr($char, 1, -1) ); - return static function ($matches) use ($string) { + return static function ($matches) use ($string): string { return $string; }; default: $char = $this->compileCharacter($char); - return static function ($matches) use ($char) { + return static function ($matches) use ($char): string { return $char; }; } diff --git a/src/lib/QueryType/BuiltIn/AbstractQueryType.php b/src/lib/QueryType/BuiltIn/AbstractQueryType.php index 2bed8e63fb..4800212d47 100644 --- a/src/lib/QueryType/BuiltIn/AbstractQueryType.php +++ b/src/lib/QueryType/BuiltIn/AbstractQueryType.php @@ -64,7 +64,7 @@ protected function configureOptions(OptionsResolver $resolver): void 'sort' => [], ]); - $resolver->setNormalizer('sort', function (Options $options, $value) { + $resolver->setNormalizer('sort', function (Options $options, $value): array { if (is_string($value)) { $value = $this->sortClausesFactory->createFromSpecification($value); } diff --git a/src/lib/QueryType/BuiltIn/GeoLocationQueryType.php b/src/lib/QueryType/BuiltIn/GeoLocationQueryType.php index 796f234819..fd95bf98d5 100644 --- a/src/lib/QueryType/BuiltIn/GeoLocationQueryType.php +++ b/src/lib/QueryType/BuiltIn/GeoLocationQueryType.php @@ -28,7 +28,7 @@ protected function configureOptions(OptionsResolver $resolver): void $resolver->setRequired('field'); $resolver->setAllowedTypes('field', ['string', Field::class]); - $resolver->setNormalizer('field', static function (Options $options, $value) { + $resolver->setNormalizer('field', static function (Options $options, $value): string { if ($value instanceof Field) { $value = $value->fieldDefIdentifier; } diff --git a/src/lib/QueryType/BuiltIn/RelatedToContentQueryType.php b/src/lib/QueryType/BuiltIn/RelatedToContentQueryType.php index 47e481dffa..10206428f9 100644 --- a/src/lib/QueryType/BuiltIn/RelatedToContentQueryType.php +++ b/src/lib/QueryType/BuiltIn/RelatedToContentQueryType.php @@ -30,7 +30,7 @@ protected function configureOptions(OptionsResolver $resolver): void $resolver->setRequired(['content']); $resolver->setAllowedTypes('content', [Content::class, ContentInfo::class, 'int']); - $resolver->setNormalizer('content', static function (Options $options, $value) { + $resolver->setNormalizer('content', static function (Options $options, $value): int { if ($value instanceof Content || $value instanceof ContentInfo) { $value = $value->id; } @@ -40,7 +40,7 @@ protected function configureOptions(OptionsResolver $resolver): void $resolver->setRequired(['field']); $resolver->setAllowedTypes('field', ['string', Field::class]); - $resolver->setNormalizer('field', static function (Options $options, $value) { + $resolver->setNormalizer('field', static function (Options $options, $value): string { if ($value instanceof Field) { $value = $value->fieldDefIdentifier; } diff --git a/src/lib/Repository/ContentService.php b/src/lib/Repository/ContentService.php index d6ea029f42..463d3dc55b 100644 --- a/src/lib/Repository/ContentService.php +++ b/src/lib/Repository/ContentService.php @@ -2398,7 +2398,7 @@ public function deleteTranslation(ContentInfo $contentInfo, string $languageCode $languageCode ); $locationIds = array_map( - static function (Location $location) { + static function (Location $location): int { return $location->id; }, $this->repository->getLocationService()->loadLocations($contentInfo) diff --git a/src/lib/Repository/ContentTypeService.php b/src/lib/Repository/ContentTypeService.php index 1909e7d441..dcf8797584 100644 --- a/src/lib/Repository/ContentTypeService.php +++ b/src/lib/Repository/ContentTypeService.php @@ -637,7 +637,7 @@ public function createContentType(APIContentTypeCreateStruct $contentTypeCreateS } $groupIds = array_map( - static function (APIContentTypeGroup $contentTypeGroup) { + static function (APIContentTypeGroup $contentTypeGroup): int { return $contentTypeGroup->id; }, $contentTypeGroups diff --git a/src/lib/Repository/LocationService.php b/src/lib/Repository/LocationService.php index 24dbfad2ce..bcdb47ad9d 100644 --- a/src/lib/Repository/LocationService.php +++ b/src/lib/Repository/LocationService.php @@ -849,7 +849,7 @@ public function loadAllLocations(int $offset = 0, int $limit = 25): array ); $contentIds = array_unique( array_map( - static function (SPILocation $spiLocation) { + static function (SPILocation $spiLocation): int { return $spiLocation->contentId; }, $spiLocations diff --git a/src/lib/Repository/NotificationService.php b/src/lib/Repository/NotificationService.php index 2158b468de..32cc35cc90 100644 --- a/src/lib/Repository/NotificationService.php +++ b/src/lib/Repository/NotificationService.php @@ -39,7 +39,7 @@ public function loadNotifications(int $offset = 0, int $limit = 25): Notificatio $list->totalCount = $this->persistenceHandler->countNotifications($currentUserId); if ($list->totalCount > 0) { - $list->items = array_map(function (Notification $spiNotification) { + $list->items = array_map(function (Notification $spiNotification): \Ibexa\Contracts\Core\Repository\Values\Notification\Notification { return $this->buildDomainObject($spiNotification); }, $this->persistenceHandler->loadUserNotifications($currentUserId, $offset, $limit)); } @@ -55,7 +55,7 @@ public function findNotifications(?NotificationQuery $query = null): Notificatio $list->totalCount = $this->persistenceHandler->countNotifications($currentUserId, $query); if ($list->totalCount > 0) { - $list->items = array_map(function (Notification $spiNotification) { + $list->items = array_map(function (Notification $spiNotification): \Ibexa\Contracts\Core\Repository\Values\Notification\Notification { return $this->buildDomainObject($spiNotification); }, $this->persistenceHandler->findUserNotifications($currentUserId, $query)); } diff --git a/src/lib/Repository/ProxyFactory/ProxyGenerator.php b/src/lib/Repository/ProxyFactory/ProxyGenerator.php index 06f6911f00..191b61436e 100644 --- a/src/lib/Repository/ProxyFactory/ProxyGenerator.php +++ b/src/lib/Repository/ProxyFactory/ProxyGenerator.php @@ -47,7 +47,7 @@ public function createProxy( public function warmUp(iterable $classes): void { foreach ($classes as $class) { - $this->createProxy($class, static function () {}); + $this->createProxy($class, static function (): void {}); } } diff --git a/src/lib/Repository/RoleService.php b/src/lib/Repository/RoleService.php index 78456c2da5..916eb6c900 100644 --- a/src/lib/Repository/RoleService.php +++ b/src/lib/Repository/RoleService.php @@ -642,7 +642,7 @@ public function loadRoleByIdentifier(string $identifier): APIRole public function loadRoles(): iterable { $roles = array_map( - function ($spiRole) { + function ($spiRole): \Ibexa\Contracts\Core\Repository\Values\User\Role { return $this->roleDomainMapper->buildDomainRoleObject($spiRole); }, $this->userHandler->loadRoles() @@ -651,7 +651,7 @@ function ($spiRole) { return array_values( array_filter( $roles, - function ($role) { + function ($role): bool { return $this->permissionResolver->canUser('role', 'read', $role); } ) diff --git a/src/lib/Repository/SectionService.php b/src/lib/Repository/SectionService.php index f49095a2a6..1a74d44a4b 100644 --- a/src/lib/Repository/SectionService.php +++ b/src/lib/Repository/SectionService.php @@ -210,11 +210,11 @@ public function loadSection(int $sectionId): Section */ public function loadSections(): iterable { - $sections = array_map(function ($spiSection) { + $sections = array_map(function ($spiSection): \Ibexa\Contracts\Core\Repository\Values\Content\Section { return $this->buildDomainSectionObject($spiSection); }, $this->sectionHandler->loadAll()); - return array_values(array_filter($sections, function ($section) { + return array_values(array_filter($sections, function ($section): bool { return $this->permissionResolver->canUser('section', 'view', $section); })); } diff --git a/src/lib/Repository/UserPreferenceService.php b/src/lib/Repository/UserPreferenceService.php index e7af68563f..dd490421b8 100644 --- a/src/lib/Repository/UserPreferenceService.php +++ b/src/lib/Repository/UserPreferenceService.php @@ -47,7 +47,7 @@ public function loadUserPreferences(int $offset = 0, int $limit = 25): UserPrefe $list->totalCount = $this->userPreferenceHandler->countUserPreferences($currentUserId); if ($list->totalCount > 0) { - $list->items = array_map(function (UserPreference $spiUserPreference) { + $list->items = array_map(function (UserPreference $spiUserPreference): \Ibexa\Contracts\Core\Repository\Values\UserPreference\UserPreference { return $this->buildDomainObject($spiUserPreference); }, $this->userPreferenceHandler->loadUserPreferences($currentUserId, $offset, $limit)); } diff --git a/src/lib/Search/Common/EventSubscriber/LocationEventSubscriber.php b/src/lib/Search/Common/EventSubscriber/LocationEventSubscriber.php index 37ba9c7e45..2751eeaae1 100644 --- a/src/lib/Search/Common/EventSubscriber/LocationEventSubscriber.php +++ b/src/lib/Search/Common/EventSubscriber/LocationEventSubscriber.php @@ -86,7 +86,7 @@ public function onSwapLocation(SwapLocationEvent $event) $event->getLocation2(), ]; - array_walk($locations, function (Location $location) { + array_walk($locations, function (Location $location): void { $contentInfo = $this->persistenceHandler->contentHandler()->loadContentInfo($location->contentId); $this->searchHandler->indexContent( diff --git a/tests/bundle/Core/Command/Indexer/ContentIdList/ContentTypeInputGeneratorStrategyTest.php b/tests/bundle/Core/Command/Indexer/ContentIdList/ContentTypeInputGeneratorStrategyTest.php index 59b02f676d..137a27bee7 100644 --- a/tests/bundle/Core/Command/Indexer/ContentIdList/ContentTypeInputGeneratorStrategyTest.php +++ b/tests/bundle/Core/Command/Indexer/ContentIdList/ContentTypeInputGeneratorStrategyTest.php @@ -36,7 +36,7 @@ public function testGetGenerator(ContentList $contentList, int $batchSize, array $repositoryMock ->method('sudo') ->willReturnCallback( - static fn (callable $callback) => $callback() + static fn (callable $callback): mixed => $callback() ); $inputMock = $this->createMock(InputInterface::class); diff --git a/tests/bundle/Core/DependencyInjection/Configuration/SiteAccessAware/ConfigurationProcessorTest.php b/tests/bundle/Core/DependencyInjection/Configuration/SiteAccessAware/ConfigurationProcessorTest.php index 7e5fc8f2d2..0bd8b64613 100644 --- a/tests/bundle/Core/DependencyInjection/Configuration/SiteAccessAware/ConfigurationProcessorTest.php +++ b/tests/bundle/Core/DependencyInjection/Configuration/SiteAccessAware/ConfigurationProcessorTest.php @@ -90,7 +90,7 @@ public function testMapConfigClosure(): void ], ]; - $mapperClosure = static function (array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer) use ($config, $availableSAs, $saNodeName, $expectedContextualizer) { + $mapperClosure = static function (array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer) use ($config, $availableSAs, $saNodeName, $expectedContextualizer): void { self::assertTrue(isset($availableSAs[$currentScope])); self::assertSame($config[$saNodeName][$currentScope], $scopeSettings); self::assertSame($expectedContextualizer, $contextualizer); diff --git a/tests/bundle/Core/EventListener/ViewControllerListenerTest.php b/tests/bundle/Core/EventListener/ViewControllerListenerTest.php index e34b6ef4c9..45d176e025 100644 --- a/tests/bundle/Core/EventListener/ViewControllerListenerTest.php +++ b/tests/bundle/Core/EventListener/ViewControllerListenerTest.php @@ -98,7 +98,7 @@ public function testGetControllerNoBuilder(): void public function testGetControllerWithClosure(): void { - $initialController = static function () {}; + $initialController = static function (): void {}; $this->request->attributes->set('_controller', $initialController); $this->viewBuilderRegistry @@ -144,7 +144,7 @@ public function testGetControllerMatchedView(): void $this->controllerResolver ->expects(self::once()) ->method('getController') - ->will(self::returnValue(static function () {})); + ->will(self::returnValue(static function (): void {})); $this->controllerListener->getController($this->event); self::assertEquals($customController, $this->request->attributes->get('_controller')); @@ -174,7 +174,7 @@ public function testGetControllerEmitsProperEvents(): void $this->eventDispatcher ->expects($matcher) - ->method('dispatch')->willReturnCallback(static function (...$parameters) use ($matcher) { + ->method('dispatch')->willReturnCallback(static function (...$parameters) use ($matcher): mixed { if ($matcher->numberOfInvocations() === 1) { self::assertInstanceOf(FilterViewBuilderParametersEvent::class, $parameters[0]); self::assertSame(ViewEvents::FILTER_BUILDER_PARAMETERS, $parameters[1]); @@ -197,7 +197,7 @@ protected function createEvent() { return new ControllerEvent( self::createStub(HttpKernelInterface::class), - static function () {}, + static function (): void {}, $this->request, HttpKernelInterface::MAIN_REQUEST ); diff --git a/tests/bundle/Core/Fragment/DirectFragmentRendererTest.php b/tests/bundle/Core/Fragment/DirectFragmentRendererTest.php index 5ea5bfd578..31b87a0b1d 100644 --- a/tests/bundle/Core/Fragment/DirectFragmentRendererTest.php +++ b/tests/bundle/Core/Fragment/DirectFragmentRendererTest.php @@ -59,7 +59,7 @@ public function testSubRequestBuilding(): void $controllerResolver ->method('getController') - ->willReturn(static function () { + ->willReturn(static function (): \Symfony\Component\HttpFoundation\Response { return new Response('response_body'); }); @@ -75,7 +75,7 @@ public function testControllerResponse(): void $controllerResolver ->method('getController') - ->willReturn(static function () { + ->willReturn(static function (): \Symfony\Component\HttpFoundation\Response { return new Response('response_body'); }); @@ -93,7 +93,7 @@ public function testControllerViewResponse(): void $controllerResolverMock = $this->getControllerResolverInterfaceMock(); $controllerResolverMock ->method('getController') - ->willReturn(static function (...$args) use ($contentView) { + ->willReturn(static function (...$args) use ($contentView): ContentView { $contentView->setParameters($args); return $contentView; @@ -137,7 +137,7 @@ public function testControllerUnhandledStringResponse(): void $controllerResolver ->method('getController') - ->willReturn(static function (...$args) { + ->willReturn(static function (...$args): array { return ['some_array' => $args]; }); diff --git a/tests/bundle/Core/Imagine/AliasGeneratorTest.php b/tests/bundle/Core/Imagine/AliasGeneratorTest.php index 9c7df06e4b..4d63508e85 100644 --- a/tests/bundle/Core/Imagine/AliasGeneratorTest.php +++ b/tests/bundle/Core/Imagine/AliasGeneratorTest.php @@ -346,7 +346,7 @@ public function testGetVariationNotStoredHavingReferences(): void $this->filterManager ->expects($matcher) ->method('applyFilter') - ->willReturnCallback(static function (...$parameters) use ($matcher, $expectedApplyFilterCalls, $binary) { + ->willReturnCallback(static function (...$parameters) use ($matcher, $expectedApplyFilterCalls, $binary): BinaryInterface { self::assertSame($expectedApplyFilterCalls[$matcher->numberOfInvocations() - 1], $parameters); return $binary; diff --git a/tests/bundle/Core/Imagine/PlaceholderProvider/GenericProviderTest.php b/tests/bundle/Core/Imagine/PlaceholderProvider/GenericProviderTest.php index 3cacbf41d3..bb7c636948 100644 --- a/tests/bundle/Core/Imagine/PlaceholderProvider/GenericProviderTest.php +++ b/tests/bundle/Core/Imagine/PlaceholderProvider/GenericProviderTest.php @@ -29,7 +29,7 @@ public function testGetPlaceholder(ImageValue $value, $expectedText, array $opti $imagine ->expects(self::atLeastOnce()) ->method('font') - ->willReturnCallback(function ($fontpath, $fontsize, ColorInterface $foreground) use ($options, $font) { + ->willReturnCallback(function ($fontpath, $fontsize, ColorInterface $foreground) use ($options, $font): AbstractFont { self::assertEquals($options['fontpath'], $fontpath); self::assertEquals($options['fontsize'], $fontsize); $this->assertColorEquals($options['foreground'], $foreground); @@ -47,7 +47,7 @@ public function testGetPlaceholder(ImageValue $value, $expectedText, array $opti $imagine ->expects(self::atLeastOnce()) ->method('create') - ->willReturnCallback(function (BoxInterface $size, ColorInterface $background) use ($value, $options, $image) { + ->willReturnCallback(function (BoxInterface $size, ColorInterface $background) use ($value, $options, $image): ImageInterface { $this->assertSizeEquals([$value->width, $value->height], $size); $this->assertColorEquals($options['background'], $background); diff --git a/tests/bundle/Core/Imagine/VariationPurger/IOVariationPurgerTest.php b/tests/bundle/Core/Imagine/VariationPurger/IOVariationPurgerTest.php index 80bfa985c8..fbb07a7dac 100644 --- a/tests/bundle/Core/Imagine/VariationPurger/IOVariationPurgerTest.php +++ b/tests/bundle/Core/Imagine/VariationPurger/IOVariationPurgerTest.php @@ -33,7 +33,7 @@ public function testPurgesAliasList(): void $matcher = self::exactly(2); $ioService ->expects($matcher) - ->method('deleteDirectory')->willReturnCallback(static function (...$parameters) use ($matcher) { + ->method('deleteDirectory')->willReturnCallback(static function (...$parameters) use ($matcher): void { if ($matcher->numberOfInvocations() === 1) { self::assertSame('_aliases/medium', $parameters[0]); } @@ -44,7 +44,7 @@ public function testPurgesAliasList(): void $matcher = self::exactly(2); $cacheIdentifierGenerator ->expects($matcher) - ->method('generateTag')->willReturnCallback(static function (...$parameters) use ($matcher) { + ->method('generateTag')->willReturnCallback(static function (...$parameters) use ($matcher): ?string { if ($matcher->numberOfInvocations() === 1) { self::assertSame('image_variation_name', $parameters[0]); self::assertSame(['medium'], $parameters[1]); @@ -57,11 +57,13 @@ public function testPurgesAliasList(): void return 'ign-large'; } + + return null; }); $matcher = self::exactly(2); $tagAwareAdapter ->expects($matcher) - ->method('invalidateTags')->willReturnCallback(static function (...$parameters) use ($matcher) { + ->method('invalidateTags')->willReturnCallback(static function (...$parameters) use ($matcher): bool { if ($matcher->numberOfInvocations() === 1) { self::assertSame(['ign-medium'], $parameters[0]); } diff --git a/tests/bundle/Core/Imagine/VariationPurger/ImageFileVariationPurgerTest.php b/tests/bundle/Core/Imagine/VariationPurger/ImageFileVariationPurgerTest.php index 348ab153bc..b2472e2974 100644 --- a/tests/bundle/Core/Imagine/VariationPurger/ImageFileVariationPurgerTest.php +++ b/tests/bundle/Core/Imagine/VariationPurger/ImageFileVariationPurgerTest.php @@ -45,7 +45,7 @@ public function testIteratesOverItems(): void $this->pathGeneratorMock ->expects($matcher) - ->method('getVariationPath')->willReturnCallback(static function (...$parameters) use ($matcher) { + ->method('getVariationPath')->willReturnCallback(static function (...$parameters) use ($matcher): string { if ($matcher->numberOfInvocations() === 1) { self::assertSame('path/to/1st/image.jpg', $parameters[0]); self::assertSame('large', $parameters[1]); diff --git a/tests/bundle/Core/URLChecker/URLCheckerTest.php b/tests/bundle/Core/URLChecker/URLCheckerTest.php index cc5c7fe637..d71e5bb4d6 100644 --- a/tests/bundle/Core/URLChecker/URLCheckerTest.php +++ b/tests/bundle/Core/URLChecker/URLCheckerTest.php @@ -35,7 +35,7 @@ protected function setUp(): void $this->urlService ->expects(self::any()) ->method('createUpdateStruct') - ->willReturnCallback(static function () { + ->willReturnCallback(static function (): \Ibexa\Contracts\Core\Repository\Values\URL\URLUpdateStruct { return new URLUpdateStruct(); }); @@ -63,7 +63,7 @@ public function testCheck(): void $handler ->expects(self::once()) ->method('validate') - ->willReturnCallback(static function (array $urls) use ($scheme, $groups) { + ->willReturnCallback(static function (array $urls) use ($scheme, $groups): void { self::assertEqualsCanonicalizing($groups[$scheme], $urls); }); } @@ -98,7 +98,7 @@ public function testCheckUnsupported(): void $handler ->expects(self::once()) ->method('validate') - ->willReturnCallback(static function (array $urls) use ($scheme, $groups) { + ->willReturnCallback(static function (array $urls) use ($scheme, $groups): void { self::assertEqualsCanonicalizing($groups[$scheme], $urls); }); } @@ -119,7 +119,7 @@ private function configureUrlHandlerRegistry(array $schemes) $this->handlerRegistry ->method('getHandler') - ->willReturnCallback(static function ($scheme) use ($schemes) { + ->willReturnCallback(static function ($scheme) use ($schemes): URLHandlerInterface { return $schemes[$scheme]; }); } diff --git a/tests/integration/Core/Limitation/MemberOfLimitationTest.php b/tests/integration/Core/Limitation/MemberOfLimitationTest.php index d4d82529ae..38b9caf714 100644 --- a/tests/integration/Core/Limitation/MemberOfLimitationTest.php +++ b/tests/integration/Core/Limitation/MemberOfLimitationTest.php @@ -62,7 +62,7 @@ public function testCanUserAssignRoleToUser(array $limitations, bool $expectedRe 'assign', $limitations, $repository->sudo( - static function (Repository $repository) { + static function (Repository $repository): \Ibexa\Contracts\Core\Repository\Values\User\UserGroup { return $repository->getUserService()->loadUserGroup(self::USERS_GROUP_ID); }, $repository diff --git a/tests/integration/Core/Limitation/RoleLimitationTest.php b/tests/integration/Core/Limitation/RoleLimitationTest.php index 8a60c19500..4aa19d30dd 100644 --- a/tests/integration/Core/Limitation/RoleLimitationTest.php +++ b/tests/integration/Core/Limitation/RoleLimitationTest.php @@ -57,7 +57,7 @@ public function testCanUserAssignRole(array $limitations, bool $expectedResult): 'assign', $limitations, $repository->sudo( - static function (Repository $repository) { + static function (Repository $repository): \Ibexa\Contracts\Core\Repository\Values\User\UserGroup { return $repository->getUserService()->loadUserGroup(self::USERS_GROUP_ID); }, $repository diff --git a/tests/integration/Core/Repository/BookmarkServiceTest.php b/tests/integration/Core/Repository/BookmarkServiceTest.php index 450720074e..0b6bcb403c 100644 --- a/tests/integration/Core/Repository/BookmarkServiceTest.php +++ b/tests/integration/Core/Repository/BookmarkServiceTest.php @@ -133,7 +133,7 @@ public function testLoadBookmarks(): void self::assertEquals(5, $bookmarks->totalCount); // Assert bookmarks order: recently added should be first - self::assertEquals([15, 13, 12], array_map(static function ($location) { + self::assertEquals([15, 13, 12], array_map(static function ($location): int { return $location->id; }, $bookmarks->items)); } diff --git a/tests/integration/Core/Repository/ContentServiceAuthorizationTest.php b/tests/integration/Core/Repository/ContentServiceAuthorizationTest.php index c50dfb5249..5b163539e4 100644 --- a/tests/integration/Core/Repository/ContentServiceAuthorizationTest.php +++ b/tests/integration/Core/Repository/ContentServiceAuthorizationTest.php @@ -129,7 +129,7 @@ public function testSudo(): void $contentId = $this->generateId('object', 10); $this->setRestrictedEditorUser(); - $contentInfo = $repository->sudo(static function (Repository $repository) use ($contentId) { + $contentInfo = $repository->sudo(static function (Repository $repository) use ($contentId): \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo { return $repository->getContentService()->loadContentInfo($contentId); }); diff --git a/tests/integration/Core/Repository/ContentServiceTest.php b/tests/integration/Core/Repository/ContentServiceTest.php index f6e75a0b23..8c908662c5 100644 --- a/tests/integration/Core/Repository/ContentServiceTest.php +++ b/tests/integration/Core/Repository/ContentServiceTest.php @@ -5550,7 +5550,7 @@ public function testLoadContentListByContentInfo(): void { $allLocationsCount = $this->locationService->getAllLocationsCount(); $contentInfoList = array_map( - static function (Location $location) { + static function (Location $location): ContentInfo { return $location->contentInfo; }, $this->locationService->loadAllLocations(0, $allLocationsCount) @@ -5876,7 +5876,7 @@ public function testHideContent(): void $contentTypeService = $this->getRepository()->getContentTypeService(); $locationCreateStructs = array_map( - function (Location $parentLocation) { + function (Location $parentLocation): \Ibexa\Contracts\Core\Repository\Values\Content\LocationCreateStruct { return $this->locationService->newLocationCreateStruct($parentLocation->id); }, $this->createParentLocationsForHideReveal(2) @@ -5916,7 +5916,7 @@ public function testRevealContent(): void $contentTypeService = $this->getRepository()->getContentTypeService(); $locationCreateStructs = array_map( - function (Location $parentLocation) { + function (Location $parentLocation): \Ibexa\Contracts\Core\Repository\Values\Content\LocationCreateStruct { return $this->locationService->newLocationCreateStruct($parentLocation->id); }, $this->createParentLocationsForHideReveal(2) @@ -6515,7 +6515,7 @@ private function filterHiddenLocations(array $locations): array return array_values( array_filter( $locations, - static function (Location $location) { + static function (Location $location): bool { return $location->hidden; } ) diff --git a/tests/integration/Core/Repository/ContentTypeServiceTest.php b/tests/integration/Core/Repository/ContentTypeServiceTest.php index 3db769f4fd..68efcc2334 100644 --- a/tests/integration/Core/Repository/ContentTypeServiceTest.php +++ b/tests/integration/Core/Repository/ContentTypeServiceTest.php @@ -2460,7 +2460,7 @@ public function testPublishContentTypeDraftRefreshesContentTypesList(): void self::assertNotContains( $contentTypeDraft->id, array_map( - static function (ContentType $contentType) { + static function (ContentType $contentType): int { return $contentType->id; }, $contentTypes @@ -2481,7 +2481,7 @@ static function (ContentType $contentType) { self::assertContains( $contentTypeDraft->id, array_map( - static function (ContentType $contentType) { + static function (ContentType $contentType): int { return $contentType->id; }, $contentTypes @@ -2743,7 +2743,7 @@ public function testLoadContentTypeFieldDefinitions(APIFieldDefinitionCollection implode( ',', array_map( - static function ($fieldDefinition) { + static function ($fieldDefinition): string { return $fieldDefinition->identifier; }, $fieldDefinitions @@ -3150,7 +3150,7 @@ public function testCopyContentType() $copiedType = $contentTypeService->copyContentType($commentType); $contentTypes = $contentTypeService->loadContentTypes($contentTypeGroup); - $contentTypeIdentifiers = array_map(static function (ContentType $contentType) { + $contentTypeIdentifiers = array_map(static function (ContentType $contentType): string { return $contentType->identifier; }, $contentTypes); /* END: Use Case */ diff --git a/tests/integration/Core/Repository/Filtering/LocationFilteringTest.php b/tests/integration/Core/Repository/Filtering/LocationFilteringTest.php index 04d58ba247..b043294578 100644 --- a/tests/integration/Core/Repository/Filtering/LocationFilteringTest.php +++ b/tests/integration/Core/Repository/Filtering/LocationFilteringTest.php @@ -133,7 +133,7 @@ public function testLogicalOrOfBookmarkedAndNotBookmarkedMatchesEveryLocationOnc self::assertSame($totalCount, $locationService->count($orFilter)); $locationIds = array_map( - static function ($location) { + static function ($location): int { return $location->getId(); }, iterator_to_array($locationService->find($orFilter)) @@ -174,7 +174,7 @@ private function findUsingLocationSearch(LocationQuery $query): LocationList [ 'totalCount' => $searchResults->totalCount, 'locations' => array_map( - static function (SearchHit $searchHit) { + static function (SearchHit $searchHit): mixed { return $searchHit->valueObject; }, $searchResults->searchHits diff --git a/tests/integration/Core/Repository/Limitation/PermissionResolver/LocationLimitationIntegrationTest.php b/tests/integration/Core/Repository/Limitation/PermissionResolver/LocationLimitationIntegrationTest.php index 5a24209361..40fef0b2e6 100644 --- a/tests/integration/Core/Repository/Limitation/PermissionResolver/LocationLimitationIntegrationTest.php +++ b/tests/integration/Core/Repository/Limitation/PermissionResolver/LocationLimitationIntegrationTest.php @@ -80,7 +80,7 @@ public function testCanUserReadTrashedContent(array $limitations, bool $expected $this->loginAsEditorUserWithLimitations('content', 'read', $limitations); $trashItem = $repository->sudo( - static function (Repository $repository) use ($location) { + static function (Repository $repository) use ($location): ?\Ibexa\Contracts\Core\Repository\Values\Content\TrashItem { return $repository->getTrashService()->trash($location); } ); diff --git a/tests/integration/Core/Repository/LocationServiceTest.php b/tests/integration/Core/Repository/LocationServiceTest.php index 067acbccb8..98108ba0b5 100644 --- a/tests/integration/Core/Repository/LocationServiceTest.php +++ b/tests/integration/Core/Repository/LocationServiceTest.php @@ -831,7 +831,7 @@ static function ($a, $b): int { self::assertEquals( [$this->generateId('location', 5)], array_map( - static function (Location $location) { + static function (Location $location): int { return $location->id; }, $locations @@ -1105,7 +1105,7 @@ public function testLoadLocationChildrenData(LocationList $locations): void $this->generateId('location', 61), ], array_map( - static function (Location $location) { + static function (Location $location): int { return $location->id; }, $locations->locations @@ -1316,7 +1316,7 @@ public function testLoadLocationChildrenRespectsParentSortingClauses( ); $childrenNames = array_map( - static function (Location $location) { + static function (Location $location): string { return $location->getContentInfo()->name; }, iterator_to_array($locationService->loadLocationChildren($location)) @@ -1723,7 +1723,7 @@ static function (Location $location): int { ); $actualLocationsIds = array_map( - static function (Location $location) { + static function (Location $location): int { return $location->id; }, $locationService->loadLocations($content->contentInfo) @@ -1757,7 +1757,7 @@ public function testSwapLocationDoesNotCorruptSearchResults(array $contentItems) $this->refreshSearch($repository); $contentIds = array_map( - static function (Content $content) { + static function (Content $content): int { return $content->id; }, $contentItems @@ -1775,7 +1775,7 @@ static function (Content $content) { 'Total count of search result hits does not match the actual number of found results' ); $foundContentIds = array_map( - static function (SearchHit $searchHit) { + static function (SearchHit $searchHit): mixed { return $searchHit->valueObject->id; }, $searchResult->searchHits diff --git a/tests/integration/Core/Repository/ObjectStateServiceTest.php b/tests/integration/Core/Repository/ObjectStateServiceTest.php index 0c2d011f05..93e9439791 100644 --- a/tests/integration/Core/Repository/ObjectStateServiceTest.php +++ b/tests/integration/Core/Repository/ObjectStateServiceTest.php @@ -539,7 +539,7 @@ public function testLoadObjectStateGroupsWithOffset(): void protected function getGroupIdentifierMap(array $groups): array { $existingGroupIdentifiers = array_map( - static function ($group) { + static function ($group): string { return $group->identifier; }, $groups diff --git a/tests/integration/Core/Repository/Parallel/BaseParallelTestCase.php b/tests/integration/Core/Repository/Parallel/BaseParallelTestCase.php index 85ff1fe6a0..7d2026905d 100644 --- a/tests/integration/Core/Repository/Parallel/BaseParallelTestCase.php +++ b/tests/integration/Core/Repository/Parallel/BaseParallelTestCase.php @@ -32,7 +32,7 @@ protected function addParallelProcess(ParallelProcessList $list, callable $callb { $connection = $this->getRawDatabaseConnection(); - $process = new Process(static function () use ($callback, $connection) { + $process = new Process(static function () use ($callback, $connection): void { $connection->executeQuery('SELECT 1'); $callback(); $connection->close(); diff --git a/tests/integration/Core/Repository/Parallel/ContentServiceTest.php b/tests/integration/Core/Repository/Parallel/ContentServiceTest.php index 0adfb8a436..fa8fba6c58 100644 --- a/tests/integration/Core/Repository/Parallel/ContentServiceTest.php +++ b/tests/integration/Core/Repository/Parallel/ContentServiceTest.php @@ -29,14 +29,14 @@ public function testPublishMultipleVersions(): void $version2 = $contentService->createContentDraft($content->contentInfo, $content->versionInfo); $processList = new ParallelProcessList(); - $this->addParallelProcess($processList, static function () use ($version1, $contentService) { + $this->addParallelProcess($processList, static function () use ($version1, $contentService): void { try { $contentService->publishVersion($version1->versionInfo); } catch (BadStateException $e) { } }); - $this->addParallelProcess($processList, static function () use ($version2, $contentService) { + $this->addParallelProcess($processList, static function () use ($version2, $contentService): void { try { $contentService->publishVersion($version2->versionInfo); } catch (BadStateException $e) { diff --git a/tests/integration/Core/Repository/SearchServiceFulltextTest.php b/tests/integration/Core/Repository/SearchServiceFulltextTest.php index c6188dae45..13e21c8e04 100644 --- a/tests/integration/Core/Repository/SearchServiceFulltextTest.php +++ b/tests/integration/Core/Repository/SearchServiceFulltextTest.php @@ -246,7 +246,7 @@ public function assertFulltextSearch(SearchResult $searchResult, array $expected self::assertEquals( array_reduce( $expectedKeys, - static function ($carry, $item) { + static function ($carry, $item): int { $carry += count((array)$item); return $carry; @@ -320,7 +320,7 @@ private function mapSearchResultToIds(SearchResult $searchResult): array } return array_map( - static function (array $idGroup) { + static function (array $idGroup): array|int { if (count($idGroup) === 1) { return reset($idGroup); } diff --git a/tests/integration/Core/Repository/SearchServiceLocationTest.php b/tests/integration/Core/Repository/SearchServiceLocationTest.php index f902d62e79..2889c917b0 100644 --- a/tests/integration/Core/Repository/SearchServiceLocationTest.php +++ b/tests/integration/Core/Repository/SearchServiceLocationTest.php @@ -433,7 +433,7 @@ public function testFindLocationsWithNonSearchableField(): void protected function mapResultLocationIds(SearchResult $result): array { return array_map( - static function (SearchHit $searchHit) { + static function (SearchHit $searchHit): mixed { return $searchHit->valueObject->id; }, $result->searchHits diff --git a/tests/integration/Core/Repository/SearchServiceTest.php b/tests/integration/Core/Repository/SearchServiceTest.php index 3495b37fa6..6d051d51fd 100644 --- a/tests/integration/Core/Repository/SearchServiceTest.php +++ b/tests/integration/Core/Repository/SearchServiceTest.php @@ -453,7 +453,7 @@ public static function getFilterContentSearches(): array ], $fixtureDir . 'Status.php', // Result having the same sort level should be sorted between them to be system independent - static function (&$data) { + static function (&$data): void { usort( $data->searchHits, static function ($a, $b): int { @@ -1872,7 +1872,7 @@ public static function getSortedLocationSearches(): array ], $fixtureDir . 'SortLocationDepth.php', // Result having the same sort level should be sorted between them to be system independent - static function (&$data) { + static function (&$data): void { // Result with ids: // 4 has depth = 1 // 11, 12, 13, 42, 59 have depth = 2 @@ -2749,7 +2749,7 @@ protected function assertMultilingualFieldFilter( protected function mapResultContentIds(SearchResult $result): array { return array_map( - static function (SearchHit $searchHit) { + static function (SearchHit $searchHit): mixed { if ($searchHit->valueObject instanceof Location) { return $searchHit->valueObject->contentInfo->id; } @@ -4778,7 +4778,7 @@ protected static function getFixtureDir(): string private function getContentInfoFixtureClosure($closure = null) { /** @var $data \Ibexa\Contracts\Core\Repository\Values\Content\Search\SearchResult */ - return static function (&$data) use ($closure) { + return static function (&$data) use ($closure): void { foreach ($data->searchHits as $searchHit) { if ($searchHit->valueObject instanceof Content) { $searchHit->valueObject = $searchHit->valueObject->getVersionInfo()->getContentInfo(); @@ -5136,7 +5136,7 @@ public function testSortingByNumericFieldsWithValuesOfDifferentLength( self::assertEquals(count($expectedOrderedIds), $result->totalCount); $actualIds = array_map( - static function (SearchHit $searchHit) { + static function (SearchHit $searchHit): int { /** @var \Ibexa\Contracts\Core\Repository\Values\Content\Location $location */ $location = $searchHit->valueObject; diff --git a/tests/integration/Core/Repository/TrashServiceTest.php b/tests/integration/Core/Repository/TrashServiceTest.php index d17ba89f04..ba8d3be687 100644 --- a/tests/integration/Core/Repository/TrashServiceTest.php +++ b/tests/integration/Core/Repository/TrashServiceTest.php @@ -960,7 +960,7 @@ public function testDeleteTrashItem(): void /* END: Use Case */ $foundIds = array_map( - static function ($trashItem) { + static function ($trashItem): int { return $trashItem->id; }, $searchResult->items diff --git a/tests/integration/Core/Repository/URLAliasServiceTest.php b/tests/integration/Core/Repository/URLAliasServiceTest.php index 0e22122942..5ce4501bca 100644 --- a/tests/integration/Core/Repository/URLAliasServiceTest.php +++ b/tests/integration/Core/Repository/URLAliasServiceTest.php @@ -1279,7 +1279,7 @@ public function testRefreshSystemUrlAliasesForMissingUrlWithHistory(): void // corrupt database by removing original entry, keeping its history $this->performRawDatabaseOperation( - static function (Connection $connection) use ($folderLocation) { + static function (Connection $connection) use ($folderLocation): int|string { $queryBuilder = $connection->createQueryBuilder(); $expr = $queryBuilder->expr(); $queryBuilder @@ -1361,7 +1361,7 @@ public function testRefreshSystemUrlAliasesForMovedLocation(): void // corrupt database by breaking link to the original URL alias $this->performRawDatabaseOperation( - static function (Connection $connection) use ($nestedFolderLocation) { + static function (Connection $connection) use ($nestedFolderLocation): int|string { $queryBuilder = $connection->createQueryBuilder(); $expr = $queryBuilder->expr(); $queryBuilder diff --git a/tests/integration/Core/Repository/UserServiceTest.php b/tests/integration/Core/Repository/UserServiceTest.php index f70973f974..f1718d545e 100644 --- a/tests/integration/Core/Repository/UserServiceTest.php +++ b/tests/integration/Core/Repository/UserServiceTest.php @@ -559,7 +559,7 @@ public function testMoveUserGroup(): void /* END: Use Case */ $subUserGroupIds = array_map( - static function ($content) { + static function ($content): int { return $content->id; }, $subUserGroups diff --git a/tests/lib/Collection/ArrayListTest.php b/tests/lib/Collection/ArrayListTest.php index 198ed7e5e9..ead610219f 100644 --- a/tests/lib/Collection/ArrayListTest.php +++ b/tests/lib/Collection/ArrayListTest.php @@ -62,7 +62,7 @@ public function testMap(): void self::assertEquals( $this->createCollection(['A', 'B', 'C']), - $list->map(static fn (string $value) => strtoupper($value)) + $list->map(static fn (string $value): string => strtoupper($value)) ); } @@ -72,7 +72,7 @@ public function testFilter(): void self::assertEquals( $this->createCollection(['7', '9', '10']), - $list->filter(static fn (string $item) => ctype_digit($item)) + $list->filter(static fn (string $item): bool => ctype_digit($item)) ); } diff --git a/tests/lib/Collection/ArrayMapTest.php b/tests/lib/Collection/ArrayMapTest.php index fa47569c65..ff76e8ea0e 100644 --- a/tests/lib/Collection/ArrayMapTest.php +++ b/tests/lib/Collection/ArrayMapTest.php @@ -82,16 +82,16 @@ public function testExists(): void { $map = $this->createCollection(self::EXAMPLE_DATA); - self::assertTrue($map->exists(static fn ($value, $key) => $value === 'foo')); - self::assertFalse($map->exists(static fn ($value, $key) => $value === 'non-existing')); + self::assertTrue($map->exists(static fn ($value, $key): bool => $value === 'foo')); + self::assertFalse($map->exists(static fn ($value, $key): bool => $value === 'non-existing')); } public function testForAll(): void { $map = $this->createCollection(self::EXAMPLE_DATA); - self::assertTrue($map->forAll(static fn ($value, $key) => strlen($value) > 2)); - self::assertFalse($map->forAll(static fn ($value, $key) => $value === 'foo')); + self::assertTrue($map->forAll(static fn ($value, $key): bool => strlen($value) > 2)); + self::assertFalse($map->forAll(static fn ($value, $key): bool => $value === 'foo')); } protected function getExampleData(): array diff --git a/tests/lib/Event/AbstractServiceTestCase.php b/tests/lib/Event/AbstractServiceTestCase.php index 022421eda7..9ee2f33e08 100644 --- a/tests/lib/Event/AbstractServiceTestCase.php +++ b/tests/lib/Event/AbstractServiceTestCase.php @@ -19,8 +19,8 @@ abstract class AbstractServiceTestCase extends TestCase public function getEventDispatcher(string $beforeEventName, string $eventName): TraceableEventDispatcher { $eventDispatcher = new EventDispatcher(); - $eventDispatcher->addListener($beforeEventName, static function (BeforeEvent $event) {}); - $eventDispatcher->addListener($eventName, static function (AfterEvent $event) {}); + $eventDispatcher->addListener($beforeEventName, static function (BeforeEvent $event): void {}); + $eventDispatcher->addListener($eventName, static function (AfterEvent $event): void {}); return new TraceableEventDispatcher( $eventDispatcher, diff --git a/tests/lib/Event/BookmarkServiceTest.php b/tests/lib/Event/BookmarkServiceTest.php index 42f11a7b84..7f552c8e1d 100644 --- a/tests/lib/Event/BookmarkServiceTest.php +++ b/tests/lib/Event/BookmarkServiceTest.php @@ -55,7 +55,7 @@ public function testCreateBookmarkStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(BookmarkServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeCreateBookmarkEvent::class, static function (BeforeCreateBookmarkEvent $event) { + $traceableEventDispatcher->addListener(BeforeCreateBookmarkEvent::class, static function (BeforeCreateBookmarkEvent $event): void { $event->stopPropagation(); }, 10); @@ -112,7 +112,7 @@ public function testDeleteBookmarkStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(BookmarkServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeDeleteBookmarkEvent::class, static function (BeforeDeleteBookmarkEvent $event) { + $traceableEventDispatcher->addListener(BeforeDeleteBookmarkEvent::class, static function (BeforeDeleteBookmarkEvent $event): void { $event->stopPropagation(); }, 10); diff --git a/tests/lib/Event/ContentServiceTest.php b/tests/lib/Event/ContentServiceTest.php index d7086dad6c..28ee5af398 100644 --- a/tests/lib/Event/ContentServiceTest.php +++ b/tests/lib/Event/ContentServiceTest.php @@ -91,7 +91,7 @@ public function testReturnDeleteContentResultInBeforeEvents(): void $innerServiceMock = $this->createMock(ContentServiceInterface::class); $innerServiceMock->method('deleteContent')->willReturn($locations); - $traceableEventDispatcher->addListener(BeforeDeleteContentEvent::class, static function (BeforeDeleteContentEvent $event) use ($eventLocations) { + $traceableEventDispatcher->addListener(BeforeDeleteContentEvent::class, static function (BeforeDeleteContentEvent $event) use ($eventLocations): void { $event->setLocations($eventLocations); }, 10); @@ -125,7 +125,7 @@ public function testDeleteContentStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(ContentServiceInterface::class); $innerServiceMock->method('deleteContent')->willReturn($locations); - $traceableEventDispatcher->addListener(BeforeDeleteContentEvent::class, static function (BeforeDeleteContentEvent $event) use ($eventLocations) { + $traceableEventDispatcher->addListener(BeforeDeleteContentEvent::class, static function (BeforeDeleteContentEvent $event) use ($eventLocations): void { $event->setLocations($eventLocations); $event->stopPropagation(); }, 10); @@ -194,7 +194,7 @@ public function testReturnCopyContentResultInBeforeEvents(): void $innerServiceMock = $this->createMock(ContentServiceInterface::class); $innerServiceMock->method('copyContent')->willReturn($content); - $traceableEventDispatcher->addListener(BeforeCopyContentEvent::class, static function (BeforeCopyContentEvent $event) use ($eventContent) { + $traceableEventDispatcher->addListener(BeforeCopyContentEvent::class, static function (BeforeCopyContentEvent $event) use ($eventContent): void { $event->setContent($eventContent); }, 10); @@ -230,7 +230,7 @@ public function testCopyContentStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(ContentServiceInterface::class); $innerServiceMock->method('copyContent')->willReturn($content); - $traceableEventDispatcher->addListener(BeforeCopyContentEvent::class, static function (BeforeCopyContentEvent $event) use ($eventContent) { + $traceableEventDispatcher->addListener(BeforeCopyContentEvent::class, static function (BeforeCopyContentEvent $event) use ($eventContent): void { $event->setContent($eventContent); $event->stopPropagation(); }, 10); @@ -297,7 +297,7 @@ public function testReturnUpdateContentResultInBeforeEvents(): void $innerServiceMock = $this->createMock(ContentServiceInterface::class); $innerServiceMock->method('updateContent')->willReturn($content); - $traceableEventDispatcher->addListener(BeforeUpdateContentEvent::class, static function (BeforeUpdateContentEvent $event) use ($eventContent) { + $traceableEventDispatcher->addListener(BeforeUpdateContentEvent::class, static function (BeforeUpdateContentEvent $event) use ($eventContent): void { $event->setContent($eventContent); }, 10); @@ -332,7 +332,7 @@ public function testUpdateContentStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(ContentServiceInterface::class); $innerServiceMock->method('updateContent')->willReturn($content); - $traceableEventDispatcher->addListener(BeforeUpdateContentEvent::class, static function (BeforeUpdateContentEvent $event) use ($eventContent) { + $traceableEventDispatcher->addListener(BeforeUpdateContentEvent::class, static function (BeforeUpdateContentEvent $event) use ($eventContent): void { $event->setContent($eventContent); $event->stopPropagation(); }, 10); @@ -393,7 +393,7 @@ public function testDeleteRelationStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(ContentServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeDeleteRelationEvent::class, static function (BeforeDeleteRelationEvent $event) { + $traceableEventDispatcher->addListener(BeforeDeleteRelationEvent::class, static function (BeforeDeleteRelationEvent $event): void { $event->stopPropagation(); }, 10); @@ -458,7 +458,7 @@ public function testReturnCreateContentResultInBeforeEvents(): void $innerServiceMock = $this->createMock(ContentServiceInterface::class); $innerServiceMock->method('createContent')->willReturn($content); - $traceableEventDispatcher->addListener(BeforeCreateContentEvent::class, static function (BeforeCreateContentEvent $event) use ($eventContent) { + $traceableEventDispatcher->addListener(BeforeCreateContentEvent::class, static function (BeforeCreateContentEvent $event) use ($eventContent): void { $event->setContent($eventContent); }, 10); @@ -493,7 +493,7 @@ public function testCreateContentStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(ContentServiceInterface::class); $innerServiceMock->method('createContent')->willReturn($content); - $traceableEventDispatcher->addListener(BeforeCreateContentEvent::class, static function (BeforeCreateContentEvent $event) use ($eventContent) { + $traceableEventDispatcher->addListener(BeforeCreateContentEvent::class, static function (BeforeCreateContentEvent $event) use ($eventContent): void { $event->setContent($eventContent); $event->stopPropagation(); }, 10); @@ -552,7 +552,7 @@ public function testHideContentStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(ContentServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeHideContentEvent::class, static function (BeforeHideContentEvent $event) { + $traceableEventDispatcher->addListener(BeforeHideContentEvent::class, static function (BeforeHideContentEvent $event): void { $event->stopPropagation(); }, 10); @@ -609,7 +609,7 @@ public function testDeleteVersionStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(ContentServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeDeleteVersionEvent::class, static function (BeforeDeleteVersionEvent $event) { + $traceableEventDispatcher->addListener(BeforeDeleteVersionEvent::class, static function (BeforeDeleteVersionEvent $event): void { $event->stopPropagation(); }, 10); @@ -674,7 +674,7 @@ public function testReturnAddRelationResultInBeforeEvents(): void $innerServiceMock = $this->createMock(ContentServiceInterface::class); $innerServiceMock->method('addRelation')->willReturn($relation); - $traceableEventDispatcher->addListener(BeforeAddRelationEvent::class, static function (BeforeAddRelationEvent $event) use ($eventRelation) { + $traceableEventDispatcher->addListener(BeforeAddRelationEvent::class, static function (BeforeAddRelationEvent $event) use ($eventRelation): void { $event->setRelation($eventRelation); }, 10); @@ -709,7 +709,7 @@ public function testAddRelationStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(ContentServiceInterface::class); $innerServiceMock->method('addRelation')->willReturn($relation); - $traceableEventDispatcher->addListener(BeforeAddRelationEvent::class, static function (BeforeAddRelationEvent $event) use ($eventRelation) { + $traceableEventDispatcher->addListener(BeforeAddRelationEvent::class, static function (BeforeAddRelationEvent $event) use ($eventRelation): void { $event->setRelation($eventRelation); $event->stopPropagation(); }, 10); @@ -776,7 +776,7 @@ public function testReturnUpdateContentMetadataResultInBeforeEvents(): void $innerServiceMock = $this->createMock(ContentServiceInterface::class); $innerServiceMock->method('updateContentMetadata')->willReturn($content); - $traceableEventDispatcher->addListener(BeforeUpdateContentMetadataEvent::class, static function (BeforeUpdateContentMetadataEvent $event) use ($eventContent) { + $traceableEventDispatcher->addListener(BeforeUpdateContentMetadataEvent::class, static function (BeforeUpdateContentMetadataEvent $event) use ($eventContent): void { $event->setContent($eventContent); }, 10); @@ -811,7 +811,7 @@ public function testUpdateContentMetadataStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(ContentServiceInterface::class); $innerServiceMock->method('updateContentMetadata')->willReturn($content); - $traceableEventDispatcher->addListener(BeforeUpdateContentMetadataEvent::class, static function (BeforeUpdateContentMetadataEvent $event) use ($eventContent) { + $traceableEventDispatcher->addListener(BeforeUpdateContentMetadataEvent::class, static function (BeforeUpdateContentMetadataEvent $event) use ($eventContent): void { $event->setContent($eventContent); $event->stopPropagation(); }, 10); @@ -872,7 +872,7 @@ public function testDeleteTranslationStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(ContentServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeDeleteTranslationEvent::class, static function (BeforeDeleteTranslationEvent $event) { + $traceableEventDispatcher->addListener(BeforeDeleteTranslationEvent::class, static function (BeforeDeleteTranslationEvent $event): void { $event->stopPropagation(); }, 10); @@ -937,7 +937,7 @@ public function testReturnPublishVersionResultInBeforeEvents(): void $innerServiceMock = $this->createMock(ContentServiceInterface::class); $innerServiceMock->method('publishVersion')->willReturn($content); - $traceableEventDispatcher->addListener(BeforePublishVersionEvent::class, static function (BeforePublishVersionEvent $event) use ($eventContent) { + $traceableEventDispatcher->addListener(BeforePublishVersionEvent::class, static function (BeforePublishVersionEvent $event) use ($eventContent): void { $event->setContent($eventContent); }, 10); @@ -972,7 +972,7 @@ public function testPublishVersionStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(ContentServiceInterface::class); $innerServiceMock->method('publishVersion')->willReturn($content); - $traceableEventDispatcher->addListener(BeforePublishVersionEvent::class, static function (BeforePublishVersionEvent $event) use ($eventContent) { + $traceableEventDispatcher->addListener(BeforePublishVersionEvent::class, static function (BeforePublishVersionEvent $event) use ($eventContent): void { $event->setContent($eventContent); $event->stopPropagation(); }, 10); @@ -1041,7 +1041,7 @@ public function testReturnCreateContentDraftResultInBeforeEvents(): void $innerServiceMock = $this->createMock(ContentServiceInterface::class); $innerServiceMock->method('createContentDraft')->willReturn($contentDraft); - $traceableEventDispatcher->addListener(BeforeCreateContentDraftEvent::class, static function (BeforeCreateContentDraftEvent $event) use ($eventContentDraft) { + $traceableEventDispatcher->addListener(BeforeCreateContentDraftEvent::class, static function (BeforeCreateContentDraftEvent $event) use ($eventContentDraft): void { $event->setContentDraft($eventContentDraft); }, 10); @@ -1077,7 +1077,7 @@ public function testCreateContentDraftStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(ContentServiceInterface::class); $innerServiceMock->method('createContentDraft')->willReturn($contentDraft); - $traceableEventDispatcher->addListener(BeforeCreateContentDraftEvent::class, static function (BeforeCreateContentDraftEvent $event) use ($eventContentDraft) { + $traceableEventDispatcher->addListener(BeforeCreateContentDraftEvent::class, static function (BeforeCreateContentDraftEvent $event) use ($eventContentDraft): void { $event->setContentDraft($eventContentDraft); $event->stopPropagation(); }, 10); @@ -1136,7 +1136,7 @@ public function testRevealContentStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(ContentServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeRevealContentEvent::class, static function (BeforeRevealContentEvent $event) { + $traceableEventDispatcher->addListener(BeforeRevealContentEvent::class, static function (BeforeRevealContentEvent $event): void { $event->stopPropagation(); }, 10); diff --git a/tests/lib/Event/ContentTypeServiceTest.php b/tests/lib/Event/ContentTypeServiceTest.php index 3f4594b4e7..e9ba3fab51 100644 --- a/tests/lib/Event/ContentTypeServiceTest.php +++ b/tests/lib/Event/ContentTypeServiceTest.php @@ -93,7 +93,7 @@ public function testAddFieldDefinitionStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(ContentTypeServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeAddFieldDefinitionEvent::class, static function (BeforeAddFieldDefinitionEvent $event) { + $traceableEventDispatcher->addListener(BeforeAddFieldDefinitionEvent::class, static function (BeforeAddFieldDefinitionEvent $event): void { $event->stopPropagation(); }, 10); @@ -150,7 +150,7 @@ public function testDeleteContentTypeGroupStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(ContentTypeServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeDeleteContentTypeGroupEvent::class, static function (BeforeDeleteContentTypeGroupEvent $event) { + $traceableEventDispatcher->addListener(BeforeDeleteContentTypeGroupEvent::class, static function (BeforeDeleteContentTypeGroupEvent $event): void { $event->stopPropagation(); }, 10); @@ -213,7 +213,7 @@ public function testReturnCreateContentTypeDraftResultInBeforeEvents(): void $innerServiceMock = $this->createMock(ContentTypeServiceInterface::class); $innerServiceMock->method('createContentTypeDraft')->willReturn($contentTypeDraft); - $traceableEventDispatcher->addListener(BeforeCreateContentTypeDraftEvent::class, static function (BeforeCreateContentTypeDraftEvent $event) use ($eventContentTypeDraft) { + $traceableEventDispatcher->addListener(BeforeCreateContentTypeDraftEvent::class, static function (BeforeCreateContentTypeDraftEvent $event) use ($eventContentTypeDraft): void { $event->setContentTypeDraft($eventContentTypeDraft); }, 10); @@ -247,7 +247,7 @@ public function testCreateContentTypeDraftStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(ContentTypeServiceInterface::class); $innerServiceMock->method('createContentTypeDraft')->willReturn($contentTypeDraft); - $traceableEventDispatcher->addListener(BeforeCreateContentTypeDraftEvent::class, static function (BeforeCreateContentTypeDraftEvent $event) use ($eventContentTypeDraft) { + $traceableEventDispatcher->addListener(BeforeCreateContentTypeDraftEvent::class, static function (BeforeCreateContentTypeDraftEvent $event) use ($eventContentTypeDraft): void { $event->setContentTypeDraft($eventContentTypeDraft); $event->stopPropagation(); }, 10); @@ -312,7 +312,7 @@ public function testReturnCreateContentTypeGroupResultInBeforeEvents(): void $innerServiceMock = $this->createMock(ContentTypeServiceInterface::class); $innerServiceMock->method('createContentTypeGroup')->willReturn($contentTypeGroup); - $traceableEventDispatcher->addListener(BeforeCreateContentTypeGroupEvent::class, static function (BeforeCreateContentTypeGroupEvent $event) use ($eventContentTypeGroup) { + $traceableEventDispatcher->addListener(BeforeCreateContentTypeGroupEvent::class, static function (BeforeCreateContentTypeGroupEvent $event) use ($eventContentTypeGroup): void { $event->setContentTypeGroup($eventContentTypeGroup); }, 10); @@ -346,7 +346,7 @@ public function testCreateContentTypeGroupStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(ContentTypeServiceInterface::class); $innerServiceMock->method('createContentTypeGroup')->willReturn($contentTypeGroup); - $traceableEventDispatcher->addListener(BeforeCreateContentTypeGroupEvent::class, static function (BeforeCreateContentTypeGroupEvent $event) use ($eventContentTypeGroup) { + $traceableEventDispatcher->addListener(BeforeCreateContentTypeGroupEvent::class, static function (BeforeCreateContentTypeGroupEvent $event) use ($eventContentTypeGroup): void { $event->setContentTypeGroup($eventContentTypeGroup); $event->stopPropagation(); }, 10); @@ -407,7 +407,7 @@ public function testUpdateContentTypeGroupStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(ContentTypeServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeUpdateContentTypeGroupEvent::class, static function (BeforeUpdateContentTypeGroupEvent $event) { + $traceableEventDispatcher->addListener(BeforeUpdateContentTypeGroupEvent::class, static function (BeforeUpdateContentTypeGroupEvent $event): void { $event->stopPropagation(); }, 10); @@ -472,7 +472,7 @@ public function testReturnCreateContentTypeResultInBeforeEvents(): void $innerServiceMock = $this->createMock(ContentTypeServiceInterface::class); $innerServiceMock->method('createContentType')->willReturn($contentTypeDraft); - $traceableEventDispatcher->addListener(BeforeCreateContentTypeEvent::class, static function (BeforeCreateContentTypeEvent $event) use ($eventContentTypeDraft) { + $traceableEventDispatcher->addListener(BeforeCreateContentTypeEvent::class, static function (BeforeCreateContentTypeEvent $event) use ($eventContentTypeDraft): void { $event->setContentTypeDraft($eventContentTypeDraft); }, 10); @@ -507,7 +507,7 @@ public function testCreateContentTypeStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(ContentTypeServiceInterface::class); $innerServiceMock->method('createContentType')->willReturn($contentTypeDraft); - $traceableEventDispatcher->addListener(BeforeCreateContentTypeEvent::class, static function (BeforeCreateContentTypeEvent $event) use ($eventContentTypeDraft) { + $traceableEventDispatcher->addListener(BeforeCreateContentTypeEvent::class, static function (BeforeCreateContentTypeEvent $event) use ($eventContentTypeDraft): void { $event->setContentTypeDraft($eventContentTypeDraft); $event->stopPropagation(); }, 10); @@ -574,7 +574,7 @@ public function testReturnRemoveContentTypeTranslationResultInBeforeEvents(): vo $innerServiceMock = $this->createMock(ContentTypeServiceInterface::class); $innerServiceMock->method('removeContentTypeTranslation')->willReturn($newContentTypeDraft); - $traceableEventDispatcher->addListener(BeforeRemoveContentTypeTranslationEvent::class, static function (BeforeRemoveContentTypeTranslationEvent $event) use ($eventNewContentTypeDraft) { + $traceableEventDispatcher->addListener(BeforeRemoveContentTypeTranslationEvent::class, static function (BeforeRemoveContentTypeTranslationEvent $event) use ($eventNewContentTypeDraft): void { $event->setNewContentTypeDraft($eventNewContentTypeDraft); }, 10); @@ -609,7 +609,7 @@ public function testRemoveContentTypeTranslationStopPropagationInBeforeEvents(): $innerServiceMock = $this->createMock(ContentTypeServiceInterface::class); $innerServiceMock->method('removeContentTypeTranslation')->willReturn($newContentTypeDraft); - $traceableEventDispatcher->addListener(BeforeRemoveContentTypeTranslationEvent::class, static function (BeforeRemoveContentTypeTranslationEvent $event) use ($eventNewContentTypeDraft) { + $traceableEventDispatcher->addListener(BeforeRemoveContentTypeTranslationEvent::class, static function (BeforeRemoveContentTypeTranslationEvent $event) use ($eventNewContentTypeDraft): void { $event->setNewContentTypeDraft($eventNewContentTypeDraft); $event->stopPropagation(); }, 10); @@ -670,7 +670,7 @@ public function testUnassignContentTypeGroupStopPropagationInBeforeEvents(): voi $innerServiceMock = self::createStub(ContentTypeServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeUnassignContentTypeGroupEvent::class, static function (BeforeUnassignContentTypeGroupEvent $event) { + $traceableEventDispatcher->addListener(BeforeUnassignContentTypeGroupEvent::class, static function (BeforeUnassignContentTypeGroupEvent $event): void { $event->stopPropagation(); }, 10); @@ -727,7 +727,7 @@ public function testPublishContentTypeDraftStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(ContentTypeServiceInterface::class); - $traceableEventDispatcher->addListener(BeforePublishContentTypeDraftEvent::class, static function (BeforePublishContentTypeDraftEvent $event) { + $traceableEventDispatcher->addListener(BeforePublishContentTypeDraftEvent::class, static function (BeforePublishContentTypeDraftEvent $event): void { $event->stopPropagation(); }, 10); @@ -788,7 +788,7 @@ public function testUpdateFieldDefinitionStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(ContentTypeServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeUpdateFieldDefinitionEvent::class, static function (BeforeUpdateFieldDefinitionEvent $event) { + $traceableEventDispatcher->addListener(BeforeUpdateFieldDefinitionEvent::class, static function (BeforeUpdateFieldDefinitionEvent $event): void { $event->stopPropagation(); }, 10); @@ -847,7 +847,7 @@ public function testRemoveFieldDefinitionStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(ContentTypeServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeRemoveFieldDefinitionEvent::class, static function (BeforeRemoveFieldDefinitionEvent $event) { + $traceableEventDispatcher->addListener(BeforeRemoveFieldDefinitionEvent::class, static function (BeforeRemoveFieldDefinitionEvent $event): void { $event->stopPropagation(); }, 10); @@ -906,7 +906,7 @@ public function testAssignContentTypeGroupStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(ContentTypeServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeAssignContentTypeGroupEvent::class, static function (BeforeAssignContentTypeGroupEvent $event) { + $traceableEventDispatcher->addListener(BeforeAssignContentTypeGroupEvent::class, static function (BeforeAssignContentTypeGroupEvent $event): void { $event->stopPropagation(); }, 10); @@ -965,7 +965,7 @@ public function testUpdateContentTypeDraftStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(ContentTypeServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeUpdateContentTypeDraftEvent::class, static function (BeforeUpdateContentTypeDraftEvent $event) { + $traceableEventDispatcher->addListener(BeforeUpdateContentTypeDraftEvent::class, static function (BeforeUpdateContentTypeDraftEvent $event): void { $event->stopPropagation(); }, 10); @@ -1022,7 +1022,7 @@ public function testDeleteContentTypeStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(ContentTypeServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeDeleteContentTypeEvent::class, static function (BeforeDeleteContentTypeEvent $event) { + $traceableEventDispatcher->addListener(BeforeDeleteContentTypeEvent::class, static function (BeforeDeleteContentTypeEvent $event): void { $event->stopPropagation(); }, 10); @@ -1087,7 +1087,7 @@ public function testReturnCopyContentTypeResultInBeforeEvents(): void $innerServiceMock = $this->createMock(ContentTypeServiceInterface::class); $innerServiceMock->method('copyContentType')->willReturn($contentTypeCopy); - $traceableEventDispatcher->addListener(BeforeCopyContentTypeEvent::class, static function (BeforeCopyContentTypeEvent $event) use ($eventContentTypeCopy) { + $traceableEventDispatcher->addListener(BeforeCopyContentTypeEvent::class, static function (BeforeCopyContentTypeEvent $event) use ($eventContentTypeCopy): void { $event->setContentTypeCopy($eventContentTypeCopy); }, 10); @@ -1122,7 +1122,7 @@ public function testCopyContentTypeStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(ContentTypeServiceInterface::class); $innerServiceMock->method('copyContentType')->willReturn($contentTypeCopy); - $traceableEventDispatcher->addListener(BeforeCopyContentTypeEvent::class, static function (BeforeCopyContentTypeEvent $event) use ($eventContentTypeCopy) { + $traceableEventDispatcher->addListener(BeforeCopyContentTypeEvent::class, static function (BeforeCopyContentTypeEvent $event) use ($eventContentTypeCopy): void { $event->setContentTypeCopy($eventContentTypeCopy); $event->stopPropagation(); }, 10); diff --git a/tests/lib/Event/LanguageServiceTest.php b/tests/lib/Event/LanguageServiceTest.php index c09012bbe2..aac55845b5 100644 --- a/tests/lib/Event/LanguageServiceTest.php +++ b/tests/lib/Event/LanguageServiceTest.php @@ -62,7 +62,7 @@ public function testDeleteLanguageStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(LanguageServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeDeleteLanguageEvent::class, static function (BeforeDeleteLanguageEvent $event) { + $traceableEventDispatcher->addListener(BeforeDeleteLanguageEvent::class, static function (BeforeDeleteLanguageEvent $event): void { $event->stopPropagation(); }, 10); @@ -125,7 +125,7 @@ public function testReturnCreateLanguageResultInBeforeEvents(): void $innerServiceMock = $this->createMock(LanguageServiceInterface::class); $innerServiceMock->method('createLanguage')->willReturn($language); - $traceableEventDispatcher->addListener(BeforeCreateLanguageEvent::class, static function (BeforeCreateLanguageEvent $event) use ($eventLanguage) { + $traceableEventDispatcher->addListener(BeforeCreateLanguageEvent::class, static function (BeforeCreateLanguageEvent $event) use ($eventLanguage): void { $event->setLanguage($eventLanguage); }, 10); @@ -159,7 +159,7 @@ public function testCreateLanguageStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(LanguageServiceInterface::class); $innerServiceMock->method('createLanguage')->willReturn($language); - $traceableEventDispatcher->addListener(BeforeCreateLanguageEvent::class, static function (BeforeCreateLanguageEvent $event) use ($eventLanguage) { + $traceableEventDispatcher->addListener(BeforeCreateLanguageEvent::class, static function (BeforeCreateLanguageEvent $event) use ($eventLanguage): void { $event->setLanguage($eventLanguage); $event->stopPropagation(); }, 10); @@ -226,7 +226,7 @@ public function testReturnUpdateLanguageNameResultInBeforeEvents(): void $innerServiceMock = $this->createMock(LanguageServiceInterface::class); $innerServiceMock->method('updateLanguageName')->willReturn($updatedLanguage); - $traceableEventDispatcher->addListener(BeforeUpdateLanguageNameEvent::class, static function (BeforeUpdateLanguageNameEvent $event) use ($eventUpdatedLanguage) { + $traceableEventDispatcher->addListener(BeforeUpdateLanguageNameEvent::class, static function (BeforeUpdateLanguageNameEvent $event) use ($eventUpdatedLanguage): void { $event->setUpdatedLanguage($eventUpdatedLanguage); }, 10); @@ -261,7 +261,7 @@ public function testUpdateLanguageNameStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(LanguageServiceInterface::class); $innerServiceMock->method('updateLanguageName')->willReturn($updatedLanguage); - $traceableEventDispatcher->addListener(BeforeUpdateLanguageNameEvent::class, static function (BeforeUpdateLanguageNameEvent $event) use ($eventUpdatedLanguage) { + $traceableEventDispatcher->addListener(BeforeUpdateLanguageNameEvent::class, static function (BeforeUpdateLanguageNameEvent $event) use ($eventUpdatedLanguage): void { $event->setUpdatedLanguage($eventUpdatedLanguage); $event->stopPropagation(); }, 10); @@ -326,7 +326,7 @@ public function testReturnDisableLanguageResultInBeforeEvents(): void $innerServiceMock = $this->createMock(LanguageServiceInterface::class); $innerServiceMock->method('disableLanguage')->willReturn($disabledLanguage); - $traceableEventDispatcher->addListener(BeforeDisableLanguageEvent::class, static function (BeforeDisableLanguageEvent $event) use ($eventDisabledLanguage) { + $traceableEventDispatcher->addListener(BeforeDisableLanguageEvent::class, static function (BeforeDisableLanguageEvent $event) use ($eventDisabledLanguage): void { $event->setDisabledLanguage($eventDisabledLanguage); }, 10); @@ -360,7 +360,7 @@ public function testDisableLanguageStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(LanguageServiceInterface::class); $innerServiceMock->method('disableLanguage')->willReturn($disabledLanguage); - $traceableEventDispatcher->addListener(BeforeDisableLanguageEvent::class, static function (BeforeDisableLanguageEvent $event) use ($eventDisabledLanguage) { + $traceableEventDispatcher->addListener(BeforeDisableLanguageEvent::class, static function (BeforeDisableLanguageEvent $event) use ($eventDisabledLanguage): void { $event->setDisabledLanguage($eventDisabledLanguage); $event->stopPropagation(); }, 10); @@ -425,7 +425,7 @@ public function testReturnEnableLanguageResultInBeforeEvents(): void $innerServiceMock = $this->createMock(LanguageServiceInterface::class); $innerServiceMock->method('enableLanguage')->willReturn($enabledLanguage); - $traceableEventDispatcher->addListener(BeforeEnableLanguageEvent::class, static function (BeforeEnableLanguageEvent $event) use ($eventEnabledLanguage) { + $traceableEventDispatcher->addListener(BeforeEnableLanguageEvent::class, static function (BeforeEnableLanguageEvent $event) use ($eventEnabledLanguage): void { $event->setEnabledLanguage($eventEnabledLanguage); }, 10); @@ -459,7 +459,7 @@ public function testEnableLanguageStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(LanguageServiceInterface::class); $innerServiceMock->method('enableLanguage')->willReturn($enabledLanguage); - $traceableEventDispatcher->addListener(BeforeEnableLanguageEvent::class, static function (BeforeEnableLanguageEvent $event) use ($eventEnabledLanguage) { + $traceableEventDispatcher->addListener(BeforeEnableLanguageEvent::class, static function (BeforeEnableLanguageEvent $event) use ($eventEnabledLanguage): void { $event->setEnabledLanguage($eventEnabledLanguage); $event->stopPropagation(); }, 10); diff --git a/tests/lib/Event/LocationServiceTest.php b/tests/lib/Event/LocationServiceTest.php index 0d86219665..b7f3d27f0e 100644 --- a/tests/lib/Event/LocationServiceTest.php +++ b/tests/lib/Event/LocationServiceTest.php @@ -78,7 +78,7 @@ public function testReturnCopySubtreeResultInBeforeEvents(): void $innerServiceMock = $this->createMock(LocationServiceInterface::class); $innerServiceMock->method('copySubtree')->willReturn($location); - $traceableEventDispatcher->addListener(BeforeCopySubtreeEvent::class, static function (BeforeCopySubtreeEvent $event) use ($eventLocation) { + $traceableEventDispatcher->addListener(BeforeCopySubtreeEvent::class, static function (BeforeCopySubtreeEvent $event) use ($eventLocation): void { $event->setLocation($eventLocation); }, 10); @@ -113,7 +113,7 @@ public function testCopySubtreeStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(LocationServiceInterface::class); $innerServiceMock->method('copySubtree')->willReturn($location); - $traceableEventDispatcher->addListener(BeforeCopySubtreeEvent::class, static function (BeforeCopySubtreeEvent $event) use ($eventLocation) { + $traceableEventDispatcher->addListener(BeforeCopySubtreeEvent::class, static function (BeforeCopySubtreeEvent $event) use ($eventLocation): void { $event->setLocation($eventLocation); $event->stopPropagation(); }, 10); @@ -172,7 +172,7 @@ public function testDeleteLocationStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(LocationServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeDeleteLocationEvent::class, static function (BeforeDeleteLocationEvent $event) { + $traceableEventDispatcher->addListener(BeforeDeleteLocationEvent::class, static function (BeforeDeleteLocationEvent $event): void { $event->stopPropagation(); }, 10); @@ -235,7 +235,7 @@ public function testReturnUnhideLocationResultInBeforeEvents(): void $innerServiceMock = $this->createMock(LocationServiceInterface::class); $innerServiceMock->method('unhideLocation')->willReturn($revealedLocation); - $traceableEventDispatcher->addListener(BeforeUnhideLocationEvent::class, static function (BeforeUnhideLocationEvent $event) use ($eventRevealedLocation) { + $traceableEventDispatcher->addListener(BeforeUnhideLocationEvent::class, static function (BeforeUnhideLocationEvent $event) use ($eventRevealedLocation): void { $event->setRevealedLocation($eventRevealedLocation); }, 10); @@ -269,7 +269,7 @@ public function testUnhideLocationStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(LocationServiceInterface::class); $innerServiceMock->method('unhideLocation')->willReturn($revealedLocation); - $traceableEventDispatcher->addListener(BeforeUnhideLocationEvent::class, static function (BeforeUnhideLocationEvent $event) use ($eventRevealedLocation) { + $traceableEventDispatcher->addListener(BeforeUnhideLocationEvent::class, static function (BeforeUnhideLocationEvent $event) use ($eventRevealedLocation): void { $event->setRevealedLocation($eventRevealedLocation); $event->stopPropagation(); }, 10); @@ -334,7 +334,7 @@ public function testReturnHideLocationResultInBeforeEvents(): void $innerServiceMock = $this->createMock(LocationServiceInterface::class); $innerServiceMock->method('hideLocation')->willReturn($hiddenLocation); - $traceableEventDispatcher->addListener(BeforeHideLocationEvent::class, static function (BeforeHideLocationEvent $event) use ($eventHiddenLocation) { + $traceableEventDispatcher->addListener(BeforeHideLocationEvent::class, static function (BeforeHideLocationEvent $event) use ($eventHiddenLocation): void { $event->setHiddenLocation($eventHiddenLocation); }, 10); @@ -368,7 +368,7 @@ public function testHideLocationStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(LocationServiceInterface::class); $innerServiceMock->method('hideLocation')->willReturn($hiddenLocation); - $traceableEventDispatcher->addListener(BeforeHideLocationEvent::class, static function (BeforeHideLocationEvent $event) use ($eventHiddenLocation) { + $traceableEventDispatcher->addListener(BeforeHideLocationEvent::class, static function (BeforeHideLocationEvent $event) use ($eventHiddenLocation): void { $event->setHiddenLocation($eventHiddenLocation); $event->stopPropagation(); }, 10); @@ -429,7 +429,7 @@ public function testSwapLocationStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(LocationServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeSwapLocationEvent::class, static function (BeforeSwapLocationEvent $event) { + $traceableEventDispatcher->addListener(BeforeSwapLocationEvent::class, static function (BeforeSwapLocationEvent $event): void { $event->stopPropagation(); }, 10); @@ -488,7 +488,7 @@ public function testMoveSubtreeStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(LocationServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeMoveSubtreeEvent::class, static function (BeforeMoveSubtreeEvent $event) { + $traceableEventDispatcher->addListener(BeforeMoveSubtreeEvent::class, static function (BeforeMoveSubtreeEvent $event): void { $event->stopPropagation(); }, 10); @@ -553,7 +553,7 @@ public function testReturnUpdateLocationResultInBeforeEvents(): void $innerServiceMock = $this->createMock(LocationServiceInterface::class); $innerServiceMock->method('updateLocation')->willReturn($updatedLocation); - $traceableEventDispatcher->addListener(BeforeUpdateLocationEvent::class, static function (BeforeUpdateLocationEvent $event) use ($eventUpdatedLocation) { + $traceableEventDispatcher->addListener(BeforeUpdateLocationEvent::class, static function (BeforeUpdateLocationEvent $event) use ($eventUpdatedLocation): void { $event->setUpdatedLocation($eventUpdatedLocation); }, 10); @@ -588,7 +588,7 @@ public function testUpdateLocationStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(LocationServiceInterface::class); $innerServiceMock->method('updateLocation')->willReturn($updatedLocation); - $traceableEventDispatcher->addListener(BeforeUpdateLocationEvent::class, static function (BeforeUpdateLocationEvent $event) use ($eventUpdatedLocation) { + $traceableEventDispatcher->addListener(BeforeUpdateLocationEvent::class, static function (BeforeUpdateLocationEvent $event) use ($eventUpdatedLocation): void { $event->setUpdatedLocation($eventUpdatedLocation); $event->stopPropagation(); }, 10); @@ -655,7 +655,7 @@ public function testReturnCreateLocationResultInBeforeEvents(): void $innerServiceMock = $this->createMock(LocationServiceInterface::class); $innerServiceMock->method('createLocation')->willReturn($location); - $traceableEventDispatcher->addListener(BeforeCreateLocationEvent::class, static function (BeforeCreateLocationEvent $event) use ($eventLocation) { + $traceableEventDispatcher->addListener(BeforeCreateLocationEvent::class, static function (BeforeCreateLocationEvent $event) use ($eventLocation): void { $event->setLocation($eventLocation); }, 10); @@ -690,7 +690,7 @@ public function testCreateLocationStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(LocationServiceInterface::class); $innerServiceMock->method('createLocation')->willReturn($location); - $traceableEventDispatcher->addListener(BeforeCreateLocationEvent::class, static function (BeforeCreateLocationEvent $event) use ($eventLocation) { + $traceableEventDispatcher->addListener(BeforeCreateLocationEvent::class, static function (BeforeCreateLocationEvent $event) use ($eventLocation): void { $event->setLocation($eventLocation); $event->stopPropagation(); }, 10); diff --git a/tests/lib/Event/ObjectStateServiceTest.php b/tests/lib/Event/ObjectStateServiceTest.php index ed7981a517..d6213b2eb8 100644 --- a/tests/lib/Event/ObjectStateServiceTest.php +++ b/tests/lib/Event/ObjectStateServiceTest.php @@ -77,7 +77,7 @@ public function testSetContentStateStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(ObjectStateServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeSetContentStateEvent::class, static function (BeforeSetContentStateEvent $event) { + $traceableEventDispatcher->addListener(BeforeSetContentStateEvent::class, static function (BeforeSetContentStateEvent $event): void { $event->stopPropagation(); }, 10); @@ -140,7 +140,7 @@ public function testReturnCreateObjectStateGroupResultInBeforeEvents(): void $innerServiceMock = $this->createMock(ObjectStateServiceInterface::class); $innerServiceMock->method('createObjectStateGroup')->willReturn($objectStateGroup); - $traceableEventDispatcher->addListener(BeforeCreateObjectStateGroupEvent::class, static function (BeforeCreateObjectStateGroupEvent $event) use ($eventObjectStateGroup) { + $traceableEventDispatcher->addListener(BeforeCreateObjectStateGroupEvent::class, static function (BeforeCreateObjectStateGroupEvent $event) use ($eventObjectStateGroup): void { $event->setObjectStateGroup($eventObjectStateGroup); }, 10); @@ -174,7 +174,7 @@ public function testCreateObjectStateGroupStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(ObjectStateServiceInterface::class); $innerServiceMock->method('createObjectStateGroup')->willReturn($objectStateGroup); - $traceableEventDispatcher->addListener(BeforeCreateObjectStateGroupEvent::class, static function (BeforeCreateObjectStateGroupEvent $event) use ($eventObjectStateGroup) { + $traceableEventDispatcher->addListener(BeforeCreateObjectStateGroupEvent::class, static function (BeforeCreateObjectStateGroupEvent $event) use ($eventObjectStateGroup): void { $event->setObjectStateGroup($eventObjectStateGroup); $event->stopPropagation(); }, 10); @@ -241,7 +241,7 @@ public function testReturnUpdateObjectStateResultInBeforeEvents(): void $innerServiceMock = $this->createMock(ObjectStateServiceInterface::class); $innerServiceMock->method('updateObjectState')->willReturn($updatedObjectState); - $traceableEventDispatcher->addListener(BeforeUpdateObjectStateEvent::class, static function (BeforeUpdateObjectStateEvent $event) use ($eventUpdatedObjectState) { + $traceableEventDispatcher->addListener(BeforeUpdateObjectStateEvent::class, static function (BeforeUpdateObjectStateEvent $event) use ($eventUpdatedObjectState): void { $event->setUpdatedObjectState($eventUpdatedObjectState); }, 10); @@ -276,7 +276,7 @@ public function testUpdateObjectStateStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(ObjectStateServiceInterface::class); $innerServiceMock->method('updateObjectState')->willReturn($updatedObjectState); - $traceableEventDispatcher->addListener(BeforeUpdateObjectStateEvent::class, static function (BeforeUpdateObjectStateEvent $event) use ($eventUpdatedObjectState) { + $traceableEventDispatcher->addListener(BeforeUpdateObjectStateEvent::class, static function (BeforeUpdateObjectStateEvent $event) use ($eventUpdatedObjectState): void { $event->setUpdatedObjectState($eventUpdatedObjectState); $event->stopPropagation(); }, 10); @@ -343,7 +343,7 @@ public function testReturnCreateObjectStateResultInBeforeEvents(): void $innerServiceMock = $this->createMock(ObjectStateServiceInterface::class); $innerServiceMock->method('createObjectState')->willReturn($objectState); - $traceableEventDispatcher->addListener(BeforeCreateObjectStateEvent::class, static function (BeforeCreateObjectStateEvent $event) use ($eventObjectState) { + $traceableEventDispatcher->addListener(BeforeCreateObjectStateEvent::class, static function (BeforeCreateObjectStateEvent $event) use ($eventObjectState): void { $event->setObjectState($eventObjectState); }, 10); @@ -378,7 +378,7 @@ public function testCreateObjectStateStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(ObjectStateServiceInterface::class); $innerServiceMock->method('createObjectState')->willReturn($objectState); - $traceableEventDispatcher->addListener(BeforeCreateObjectStateEvent::class, static function (BeforeCreateObjectStateEvent $event) use ($eventObjectState) { + $traceableEventDispatcher->addListener(BeforeCreateObjectStateEvent::class, static function (BeforeCreateObjectStateEvent $event) use ($eventObjectState): void { $event->setObjectState($eventObjectState); $event->stopPropagation(); }, 10); @@ -445,7 +445,7 @@ public function testReturnUpdateObjectStateGroupResultInBeforeEvents(): void $innerServiceMock = $this->createMock(ObjectStateServiceInterface::class); $innerServiceMock->method('updateObjectStateGroup')->willReturn($updatedObjectStateGroup); - $traceableEventDispatcher->addListener(BeforeUpdateObjectStateGroupEvent::class, static function (BeforeUpdateObjectStateGroupEvent $event) use ($eventUpdatedObjectStateGroup) { + $traceableEventDispatcher->addListener(BeforeUpdateObjectStateGroupEvent::class, static function (BeforeUpdateObjectStateGroupEvent $event) use ($eventUpdatedObjectStateGroup): void { $event->setUpdatedObjectStateGroup($eventUpdatedObjectStateGroup); }, 10); @@ -480,7 +480,7 @@ public function testUpdateObjectStateGroupStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(ObjectStateServiceInterface::class); $innerServiceMock->method('updateObjectStateGroup')->willReturn($updatedObjectStateGroup); - $traceableEventDispatcher->addListener(BeforeUpdateObjectStateGroupEvent::class, static function (BeforeUpdateObjectStateGroupEvent $event) use ($eventUpdatedObjectStateGroup) { + $traceableEventDispatcher->addListener(BeforeUpdateObjectStateGroupEvent::class, static function (BeforeUpdateObjectStateGroupEvent $event) use ($eventUpdatedObjectStateGroup): void { $event->setUpdatedObjectStateGroup($eventUpdatedObjectStateGroup); $event->stopPropagation(); }, 10); @@ -541,7 +541,7 @@ public function testSetPriorityOfObjectStateStopPropagationInBeforeEvents(): voi $innerServiceMock = self::createStub(ObjectStateServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeSetPriorityOfObjectStateEvent::class, static function (BeforeSetPriorityOfObjectStateEvent $event) { + $traceableEventDispatcher->addListener(BeforeSetPriorityOfObjectStateEvent::class, static function (BeforeSetPriorityOfObjectStateEvent $event): void { $event->stopPropagation(); }, 10); @@ -598,7 +598,7 @@ public function testDeleteObjectStateGroupStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(ObjectStateServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeDeleteObjectStateGroupEvent::class, static function (BeforeDeleteObjectStateGroupEvent $event) { + $traceableEventDispatcher->addListener(BeforeDeleteObjectStateGroupEvent::class, static function (BeforeDeleteObjectStateGroupEvent $event): void { $event->stopPropagation(); }, 10); @@ -655,7 +655,7 @@ public function testDeleteObjectStateStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(ObjectStateServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeDeleteObjectStateEvent::class, static function (BeforeDeleteObjectStateEvent $event) { + $traceableEventDispatcher->addListener(BeforeDeleteObjectStateEvent::class, static function (BeforeDeleteObjectStateEvent $event): void { $event->stopPropagation(); }, 10); diff --git a/tests/lib/Event/RoleServiceTest.php b/tests/lib/Event/RoleServiceTest.php index c73293fd88..f9baeaf9f5 100644 --- a/tests/lib/Event/RoleServiceTest.php +++ b/tests/lib/Event/RoleServiceTest.php @@ -85,7 +85,7 @@ public function testPublishRoleDraftStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(RoleServiceInterface::class); - $traceableEventDispatcher->addListener(BeforePublishRoleDraftEvent::class, static function (BeforePublishRoleDraftEvent $event) { + $traceableEventDispatcher->addListener(BeforePublishRoleDraftEvent::class, static function (BeforePublishRoleDraftEvent $event): void { $event->stopPropagation(); }, 10); @@ -146,7 +146,7 @@ public function testAssignRoleToUserStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(RoleServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeAssignRoleToUserEvent::class, static function (BeforeAssignRoleToUserEvent $event) { + $traceableEventDispatcher->addListener(BeforeAssignRoleToUserEvent::class, static function (BeforeAssignRoleToUserEvent $event): void { $event->stopPropagation(); }, 10); @@ -211,7 +211,7 @@ public function testReturnUpdateRoleDraftResultInBeforeEvents(): void $innerServiceMock = $this->createMock(RoleServiceInterface::class); $innerServiceMock->method('updateRoleDraft')->willReturn($updatedRoleDraft); - $traceableEventDispatcher->addListener(BeforeUpdateRoleDraftEvent::class, static function (BeforeUpdateRoleDraftEvent $event) use ($eventUpdatedRoleDraft) { + $traceableEventDispatcher->addListener(BeforeUpdateRoleDraftEvent::class, static function (BeforeUpdateRoleDraftEvent $event) use ($eventUpdatedRoleDraft): void { $event->setUpdatedRoleDraft($eventUpdatedRoleDraft); }, 10); @@ -246,7 +246,7 @@ public function testUpdateRoleDraftStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(RoleServiceInterface::class); $innerServiceMock->method('updateRoleDraft')->willReturn($updatedRoleDraft); - $traceableEventDispatcher->addListener(BeforeUpdateRoleDraftEvent::class, static function (BeforeUpdateRoleDraftEvent $event) use ($eventUpdatedRoleDraft) { + $traceableEventDispatcher->addListener(BeforeUpdateRoleDraftEvent::class, static function (BeforeUpdateRoleDraftEvent $event) use ($eventUpdatedRoleDraft): void { $event->setUpdatedRoleDraft($eventUpdatedRoleDraft); $event->stopPropagation(); }, 10); @@ -309,7 +309,7 @@ public function testAssignRoleToUserGroupStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(RoleServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeAssignRoleToUserGroupEvent::class, static function (BeforeAssignRoleToUserGroupEvent $event) { + $traceableEventDispatcher->addListener(BeforeAssignRoleToUserGroupEvent::class, static function (BeforeAssignRoleToUserGroupEvent $event): void { $event->stopPropagation(); }, 10); @@ -376,7 +376,7 @@ public function testReturnUpdatePolicyByRoleDraftResultInBeforeEvents(): void $innerServiceMock = $this->createMock(RoleServiceInterface::class); $innerServiceMock->method('updatePolicyByRoleDraft')->willReturn($updatedPolicyDraft); - $traceableEventDispatcher->addListener(BeforeUpdatePolicyByRoleDraftEvent::class, static function (BeforeUpdatePolicyByRoleDraftEvent $event) use ($eventUpdatedPolicyDraft) { + $traceableEventDispatcher->addListener(BeforeUpdatePolicyByRoleDraftEvent::class, static function (BeforeUpdatePolicyByRoleDraftEvent $event) use ($eventUpdatedPolicyDraft): void { $event->setUpdatedPolicyDraft($eventUpdatedPolicyDraft); }, 10); @@ -412,7 +412,7 @@ public function testUpdatePolicyByRoleDraftStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(RoleServiceInterface::class); $innerServiceMock->method('updatePolicyByRoleDraft')->willReturn($updatedPolicyDraft); - $traceableEventDispatcher->addListener(BeforeUpdatePolicyByRoleDraftEvent::class, static function (BeforeUpdatePolicyByRoleDraftEvent $event) use ($eventUpdatedPolicyDraft) { + $traceableEventDispatcher->addListener(BeforeUpdatePolicyByRoleDraftEvent::class, static function (BeforeUpdatePolicyByRoleDraftEvent $event) use ($eventUpdatedPolicyDraft): void { $event->setUpdatedPolicyDraft($eventUpdatedPolicyDraft); $event->stopPropagation(); }, 10); @@ -477,7 +477,7 @@ public function testReturnCreateRoleResultInBeforeEvents(): void $innerServiceMock = $this->createMock(RoleServiceInterface::class); $innerServiceMock->method('createRole')->willReturn($roleDraft); - $traceableEventDispatcher->addListener(BeforeCreateRoleEvent::class, static function (BeforeCreateRoleEvent $event) use ($eventRoleDraft) { + $traceableEventDispatcher->addListener(BeforeCreateRoleEvent::class, static function (BeforeCreateRoleEvent $event) use ($eventRoleDraft): void { $event->setRoleDraft($eventRoleDraft); }, 10); @@ -511,7 +511,7 @@ public function testCreateRoleStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(RoleServiceInterface::class); $innerServiceMock->method('createRole')->willReturn($roleDraft); - $traceableEventDispatcher->addListener(BeforeCreateRoleEvent::class, static function (BeforeCreateRoleEvent $event) use ($eventRoleDraft) { + $traceableEventDispatcher->addListener(BeforeCreateRoleEvent::class, static function (BeforeCreateRoleEvent $event) use ($eventRoleDraft): void { $event->setRoleDraft($eventRoleDraft); $event->stopPropagation(); }, 10); @@ -578,7 +578,7 @@ public function testReturnRemovePolicyByRoleDraftResultInBeforeEvents(): void $innerServiceMock = $this->createMock(RoleServiceInterface::class); $innerServiceMock->method('removePolicyByRoleDraft')->willReturn($updatedRoleDraft); - $traceableEventDispatcher->addListener(BeforeRemovePolicyByRoleDraftEvent::class, static function (BeforeRemovePolicyByRoleDraftEvent $event) use ($eventUpdatedRoleDraft) { + $traceableEventDispatcher->addListener(BeforeRemovePolicyByRoleDraftEvent::class, static function (BeforeRemovePolicyByRoleDraftEvent $event) use ($eventUpdatedRoleDraft): void { $event->setUpdatedRoleDraft($eventUpdatedRoleDraft); }, 10); @@ -613,7 +613,7 @@ public function testRemovePolicyByRoleDraftStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(RoleServiceInterface::class); $innerServiceMock->method('removePolicyByRoleDraft')->willReturn($updatedRoleDraft); - $traceableEventDispatcher->addListener(BeforeRemovePolicyByRoleDraftEvent::class, static function (BeforeRemovePolicyByRoleDraftEvent $event) use ($eventUpdatedRoleDraft) { + $traceableEventDispatcher->addListener(BeforeRemovePolicyByRoleDraftEvent::class, static function (BeforeRemovePolicyByRoleDraftEvent $event) use ($eventUpdatedRoleDraft): void { $event->setUpdatedRoleDraft($eventUpdatedRoleDraft); $event->stopPropagation(); }, 10); @@ -680,7 +680,7 @@ public function testReturnAddPolicyByRoleDraftResultInBeforeEvents(): void $innerServiceMock = $this->createMock(RoleServiceInterface::class); $innerServiceMock->method('addPolicyByRoleDraft')->willReturn($updatedRoleDraft); - $traceableEventDispatcher->addListener(BeforeAddPolicyByRoleDraftEvent::class, static function (BeforeAddPolicyByRoleDraftEvent $event) use ($eventUpdatedRoleDraft) { + $traceableEventDispatcher->addListener(BeforeAddPolicyByRoleDraftEvent::class, static function (BeforeAddPolicyByRoleDraftEvent $event) use ($eventUpdatedRoleDraft): void { $event->setUpdatedRoleDraft($eventUpdatedRoleDraft); }, 10); @@ -715,7 +715,7 @@ public function testAddPolicyByRoleDraftStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(RoleServiceInterface::class); $innerServiceMock->method('addPolicyByRoleDraft')->willReturn($updatedRoleDraft); - $traceableEventDispatcher->addListener(BeforeAddPolicyByRoleDraftEvent::class, static function (BeforeAddPolicyByRoleDraftEvent $event) use ($eventUpdatedRoleDraft) { + $traceableEventDispatcher->addListener(BeforeAddPolicyByRoleDraftEvent::class, static function (BeforeAddPolicyByRoleDraftEvent $event) use ($eventUpdatedRoleDraft): void { $event->setUpdatedRoleDraft($eventUpdatedRoleDraft); $event->stopPropagation(); }, 10); @@ -774,7 +774,7 @@ public function testDeleteRoleStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(RoleServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeDeleteRoleEvent::class, static function (BeforeDeleteRoleEvent $event) { + $traceableEventDispatcher->addListener(BeforeDeleteRoleEvent::class, static function (BeforeDeleteRoleEvent $event): void { $event->stopPropagation(); }, 10); @@ -831,7 +831,7 @@ public function testDeleteRoleDraftStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(RoleServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeDeleteRoleDraftEvent::class, static function (BeforeDeleteRoleDraftEvent $event) { + $traceableEventDispatcher->addListener(BeforeDeleteRoleDraftEvent::class, static function (BeforeDeleteRoleDraftEvent $event): void { $event->stopPropagation(); }, 10); @@ -888,7 +888,7 @@ public function testRemoveRoleAssignmentStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(RoleServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeRemoveRoleAssignmentEvent::class, static function (BeforeRemoveRoleAssignmentEvent $event) { + $traceableEventDispatcher->addListener(BeforeRemoveRoleAssignmentEvent::class, static function (BeforeRemoveRoleAssignmentEvent $event): void { $event->stopPropagation(); }, 10); @@ -951,7 +951,7 @@ public function testReturnCreateRoleDraftResultInBeforeEvents(): void $innerServiceMock = $this->createMock(RoleServiceInterface::class); $innerServiceMock->method('createRoleDraft')->willReturn($roleDraft); - $traceableEventDispatcher->addListener(BeforeCreateRoleDraftEvent::class, static function (BeforeCreateRoleDraftEvent $event) use ($eventRoleDraft) { + $traceableEventDispatcher->addListener(BeforeCreateRoleDraftEvent::class, static function (BeforeCreateRoleDraftEvent $event) use ($eventRoleDraft): void { $event->setRoleDraft($eventRoleDraft); }, 10); @@ -985,7 +985,7 @@ public function testCreateRoleDraftStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(RoleServiceInterface::class); $innerServiceMock->method('createRoleDraft')->willReturn($roleDraft); - $traceableEventDispatcher->addListener(BeforeCreateRoleDraftEvent::class, static function (BeforeCreateRoleDraftEvent $event) use ($eventRoleDraft) { + $traceableEventDispatcher->addListener(BeforeCreateRoleDraftEvent::class, static function (BeforeCreateRoleDraftEvent $event) use ($eventRoleDraft): void { $event->setRoleDraft($eventRoleDraft); $event->stopPropagation(); }, 10); diff --git a/tests/lib/Event/SectionServiceTest.php b/tests/lib/Event/SectionServiceTest.php index 92b29d8027..e967b2c8ee 100644 --- a/tests/lib/Event/SectionServiceTest.php +++ b/tests/lib/Event/SectionServiceTest.php @@ -67,7 +67,7 @@ public function testAssignSectionStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(SectionServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeAssignSectionEvent::class, static function (BeforeAssignSectionEvent $event) { + $traceableEventDispatcher->addListener(BeforeAssignSectionEvent::class, static function (BeforeAssignSectionEvent $event): void { $event->stopPropagation(); }, 10); @@ -132,7 +132,7 @@ public function testReturnUpdateSectionResultInBeforeEvents(): void $innerServiceMock = $this->createMock(SectionServiceInterface::class); $innerServiceMock->method('updateSection')->willReturn($updatedSection); - $traceableEventDispatcher->addListener(BeforeUpdateSectionEvent::class, static function (BeforeUpdateSectionEvent $event) use ($eventUpdatedSection) { + $traceableEventDispatcher->addListener(BeforeUpdateSectionEvent::class, static function (BeforeUpdateSectionEvent $event) use ($eventUpdatedSection): void { $event->setUpdatedSection($eventUpdatedSection); }, 10); @@ -167,7 +167,7 @@ public function testUpdateSectionStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(SectionServiceInterface::class); $innerServiceMock->method('updateSection')->willReturn($updatedSection); - $traceableEventDispatcher->addListener(BeforeUpdateSectionEvent::class, static function (BeforeUpdateSectionEvent $event) use ($eventUpdatedSection) { + $traceableEventDispatcher->addListener(BeforeUpdateSectionEvent::class, static function (BeforeUpdateSectionEvent $event) use ($eventUpdatedSection): void { $event->setUpdatedSection($eventUpdatedSection); $event->stopPropagation(); }, 10); @@ -228,7 +228,7 @@ public function testAssignSectionToSubtreeStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(SectionServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeAssignSectionToSubtreeEvent::class, static function (BeforeAssignSectionToSubtreeEvent $event) { + $traceableEventDispatcher->addListener(BeforeAssignSectionToSubtreeEvent::class, static function (BeforeAssignSectionToSubtreeEvent $event): void { $event->stopPropagation(); }, 10); @@ -285,7 +285,7 @@ public function testDeleteSectionStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(SectionServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeDeleteSectionEvent::class, static function (BeforeDeleteSectionEvent $event) { + $traceableEventDispatcher->addListener(BeforeDeleteSectionEvent::class, static function (BeforeDeleteSectionEvent $event): void { $event->stopPropagation(); }, 10); @@ -348,7 +348,7 @@ public function testReturnCreateSectionResultInBeforeEvents(): void $innerServiceMock = $this->createMock(SectionServiceInterface::class); $innerServiceMock->method('createSection')->willReturn($section); - $traceableEventDispatcher->addListener(BeforeCreateSectionEvent::class, static function (BeforeCreateSectionEvent $event) use ($eventSection) { + $traceableEventDispatcher->addListener(BeforeCreateSectionEvent::class, static function (BeforeCreateSectionEvent $event) use ($eventSection): void { $event->setSection($eventSection); }, 10); @@ -382,7 +382,7 @@ public function testCreateSectionStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(SectionServiceInterface::class); $innerServiceMock->method('createSection')->willReturn($section); - $traceableEventDispatcher->addListener(BeforeCreateSectionEvent::class, static function (BeforeCreateSectionEvent $event) use ($eventSection) { + $traceableEventDispatcher->addListener(BeforeCreateSectionEvent::class, static function (BeforeCreateSectionEvent $event) use ($eventSection): void { $event->setSection($eventSection); $event->stopPropagation(); }, 10); diff --git a/tests/lib/Event/SettingServiceTest.php b/tests/lib/Event/SettingServiceTest.php index 200804afac..0053f9f360 100644 --- a/tests/lib/Event/SettingServiceTest.php +++ b/tests/lib/Event/SettingServiceTest.php @@ -57,7 +57,7 @@ public function testReturnUpdateSettingResultInBeforeEvents(): void $traceableEventDispatcher->addListener( BeforeUpdateSettingEvent::class, - static function (BeforeUpdateSettingEvent $event) use ($eventUpdatedSetting) { + static function (BeforeUpdateSettingEvent $event) use ($eventUpdatedSetting): void { $event->setUpdatedSetting($eventUpdatedSetting); }, 10 @@ -91,7 +91,7 @@ public function testUpdateSettingStopPropagationInBeforeEvents(): void $eventUpdatedSetting = self::createStub(Setting::class); $traceableEventDispatcher->addListener( BeforeUpdateSettingEvent::class, - static function (BeforeUpdateSettingEvent $event) use ($eventUpdatedSetting) { + static function (BeforeUpdateSettingEvent $event) use ($eventUpdatedSetting): void { $event->setUpdatedSetting($eventUpdatedSetting); $event->stopPropagation(); }, @@ -169,7 +169,7 @@ public function testDeleteSettingStopPropagationInBeforeEvents(): void $traceableEventDispatcher->addListener( BeforeDeleteSettingEvent::class, - static function (BeforeDeleteSettingEvent $event) { + static function (BeforeDeleteSettingEvent $event): void { $event->stopPropagation(); }, 10 @@ -235,7 +235,7 @@ public function testReturnCreateSettingResultInBeforeEvents(): void $setting = self::createStub(Setting::class); $traceableEventDispatcher->addListener( BeforeCreateSettingEvent::class, - static function (BeforeCreateSettingEvent $event) use ($eventSetting) { + static function (BeforeCreateSettingEvent $event) use ($eventSetting): void { $event->setSetting($eventSetting); }, 10 @@ -269,7 +269,7 @@ public function testCreateSettingStopPropagationInBeforeEvents(): void $setting = self::createStub(Setting::class); $traceableEventDispatcher->addListener( BeforeCreateSettingEvent::class, - static function (BeforeCreateSettingEvent $event) use ($eventSetting) { + static function (BeforeCreateSettingEvent $event) use ($eventSetting): void { $event->setSetting($eventSetting); $event->stopPropagation(); }, diff --git a/tests/lib/Event/TrashServiceTest.php b/tests/lib/Event/TrashServiceTest.php index 056924f816..2785e3075d 100644 --- a/tests/lib/Event/TrashServiceTest.php +++ b/tests/lib/Event/TrashServiceTest.php @@ -66,7 +66,7 @@ public function testReturnEmptyTrashResultInBeforeEvents(): void $innerServiceMock = $this->createMock(TrashServiceInterface::class); $innerServiceMock->method('emptyTrash')->willReturn($resultList); - $traceableEventDispatcher->addListener(BeforeEmptyTrashEvent::class, static function (BeforeEmptyTrashEvent $event) use ($eventResultList) { + $traceableEventDispatcher->addListener(BeforeEmptyTrashEvent::class, static function (BeforeEmptyTrashEvent $event) use ($eventResultList): void { $event->setResultList($eventResultList); }, 10); @@ -99,7 +99,7 @@ public function testEmptyTrashStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(TrashServiceInterface::class); $innerServiceMock->method('emptyTrash')->willReturn($resultList); - $traceableEventDispatcher->addListener(BeforeEmptyTrashEvent::class, static function (BeforeEmptyTrashEvent $event) use ($eventResultList) { + $traceableEventDispatcher->addListener(BeforeEmptyTrashEvent::class, static function (BeforeEmptyTrashEvent $event) use ($eventResultList): void { $event->setResultList($eventResultList); $event->stopPropagation(); }, 10); @@ -164,7 +164,7 @@ public function testReturnTrashResultInBeforeEvents(): void $innerServiceMock = $this->createMock(TrashServiceInterface::class); $innerServiceMock->method('trash')->willReturn($trashItem); - $traceableEventDispatcher->addListener(BeforeTrashEvent::class, static function (BeforeTrashEvent $event) use ($eventTrashItem) { + $traceableEventDispatcher->addListener(BeforeTrashEvent::class, static function (BeforeTrashEvent $event) use ($eventTrashItem): void { $event->setResult($eventTrashItem); }, 10); @@ -198,7 +198,7 @@ public function testTrashStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(TrashServiceInterface::class); $innerServiceMock->method('trash')->willReturn($trashItem); - $traceableEventDispatcher->addListener(BeforeTrashEvent::class, static function (BeforeTrashEvent $event) use ($eventTrashItem) { + $traceableEventDispatcher->addListener(BeforeTrashEvent::class, static function (BeforeTrashEvent $event) use ($eventTrashItem): void { $event->setResult($eventTrashItem); $event->stopPropagation(); }, 10); @@ -233,7 +233,7 @@ public function testTrashStopPropagationInBeforeEventsSetsNullResult(): void $innerServiceMock = $this->createMock(TrashServiceInterface::class); $innerServiceMock->expects(self::never())->method('trash'); - $traceableEventDispatcher->addListener(BeforeTrashEvent::class, static function (BeforeTrashEvent $event) { + $traceableEventDispatcher->addListener(BeforeTrashEvent::class, static function (BeforeTrashEvent $event): void { $event->setResult(null); $event->stopPropagation(); }, 10); @@ -300,7 +300,7 @@ public function testReturnRecoverResultInBeforeEvents(): void $innerServiceMock = $this->createMock(TrashServiceInterface::class); $innerServiceMock->method('recover')->willReturn($location); - $traceableEventDispatcher->addListener(BeforeRecoverEvent::class, static function (BeforeRecoverEvent $event) use ($eventLocation) { + $traceableEventDispatcher->addListener(BeforeRecoverEvent::class, static function (BeforeRecoverEvent $event) use ($eventLocation): void { $event->setLocation($eventLocation); }, 10); @@ -335,7 +335,7 @@ public function testRecoverStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(TrashServiceInterface::class); $innerServiceMock->method('recover')->willReturn($location); - $traceableEventDispatcher->addListener(BeforeRecoverEvent::class, static function (BeforeRecoverEvent $event) use ($eventLocation) { + $traceableEventDispatcher->addListener(BeforeRecoverEvent::class, static function (BeforeRecoverEvent $event) use ($eventLocation): void { $event->setLocation($eventLocation); $event->stopPropagation(); }, 10); @@ -400,7 +400,7 @@ public function testReturnDeleteTrashItemResultInBeforeEvents(): void $innerServiceMock = $this->createMock(TrashServiceInterface::class); $innerServiceMock->method('deleteTrashItem')->willReturn($result); - $traceableEventDispatcher->addListener(BeforeDeleteTrashItemEvent::class, static function (BeforeDeleteTrashItemEvent $event) use ($eventResult) { + $traceableEventDispatcher->addListener(BeforeDeleteTrashItemEvent::class, static function (BeforeDeleteTrashItemEvent $event) use ($eventResult): void { $event->setResult($eventResult); }, 10); @@ -434,7 +434,7 @@ public function testDeleteTrashItemStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(TrashServiceInterface::class); $innerServiceMock->method('deleteTrashItem')->willReturn($result); - $traceableEventDispatcher->addListener(BeforeDeleteTrashItemEvent::class, static function (BeforeDeleteTrashItemEvent $event) use ($eventResult) { + $traceableEventDispatcher->addListener(BeforeDeleteTrashItemEvent::class, static function (BeforeDeleteTrashItemEvent $event) use ($eventResult): void { $event->setResult($eventResult); $event->stopPropagation(); }, 10); diff --git a/tests/lib/Event/URLAliasServiceTest.php b/tests/lib/Event/URLAliasServiceTest.php index 725611a1dc..59afb98e29 100644 --- a/tests/lib/Event/URLAliasServiceTest.php +++ b/tests/lib/Event/URLAliasServiceTest.php @@ -74,7 +74,7 @@ public function testReturnCreateGlobalUrlAliasResultInBeforeEvents(): void $innerServiceMock = $this->createMock(URLAliasServiceInterface::class); $innerServiceMock->method('createGlobalUrlAlias')->willReturn($urlAlias); - $traceableEventDispatcher->addListener(BeforeCreateGlobalUrlAliasEvent::class, static function (BeforeCreateGlobalUrlAliasEvent $event) use ($eventUrlAlias) { + $traceableEventDispatcher->addListener(BeforeCreateGlobalUrlAliasEvent::class, static function (BeforeCreateGlobalUrlAliasEvent $event) use ($eventUrlAlias): void { $event->setUrlAlias($eventUrlAlias); }, 10); @@ -112,7 +112,7 @@ public function testCreateGlobalUrlAliasStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(URLAliasServiceInterface::class); $innerServiceMock->method('createGlobalUrlAlias')->willReturn($urlAlias); - $traceableEventDispatcher->addListener(BeforeCreateGlobalUrlAliasEvent::class, static function (BeforeCreateGlobalUrlAliasEvent $event) use ($eventUrlAlias) { + $traceableEventDispatcher->addListener(BeforeCreateGlobalUrlAliasEvent::class, static function (BeforeCreateGlobalUrlAliasEvent $event) use ($eventUrlAlias): void { $event->setUrlAlias($eventUrlAlias); $event->stopPropagation(); }, 10); @@ -171,7 +171,7 @@ public function testRefreshSystemUrlAliasesForLocationStopPropagationInBeforeEve $innerServiceMock = self::createStub(URLAliasServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeRefreshSystemUrlAliasesForLocationEvent::class, static function (BeforeRefreshSystemUrlAliasesForLocationEvent $event) { + $traceableEventDispatcher->addListener(BeforeRefreshSystemUrlAliasesForLocationEvent::class, static function (BeforeRefreshSystemUrlAliasesForLocationEvent $event): void { $event->stopPropagation(); }, 10); @@ -242,7 +242,7 @@ public function testReturnCreateUrlAliasResultInBeforeEvents(): void $innerServiceMock = $this->createMock(URLAliasServiceInterface::class); $innerServiceMock->method('createUrlAlias')->willReturn($urlAlias); - $traceableEventDispatcher->addListener(BeforeCreateUrlAliasEvent::class, static function (BeforeCreateUrlAliasEvent $event) use ($eventUrlAlias) { + $traceableEventDispatcher->addListener(BeforeCreateUrlAliasEvent::class, static function (BeforeCreateUrlAliasEvent $event) use ($eventUrlAlias): void { $event->setUrlAlias($eventUrlAlias); }, 10); @@ -280,7 +280,7 @@ public function testCreateUrlAliasStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(URLAliasServiceInterface::class); $innerServiceMock->method('createUrlAlias')->willReturn($urlAlias); - $traceableEventDispatcher->addListener(BeforeCreateUrlAliasEvent::class, static function (BeforeCreateUrlAliasEvent $event) use ($eventUrlAlias) { + $traceableEventDispatcher->addListener(BeforeCreateUrlAliasEvent::class, static function (BeforeCreateUrlAliasEvent $event) use ($eventUrlAlias): void { $event->setUrlAlias($eventUrlAlias); $event->stopPropagation(); }, 10); @@ -339,7 +339,7 @@ public function testRemoveAliasesStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(URLAliasServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeRemoveAliasesEvent::class, static function (BeforeRemoveAliasesEvent $event) { + $traceableEventDispatcher->addListener(BeforeRemoveAliasesEvent::class, static function (BeforeRemoveAliasesEvent $event): void { $event->stopPropagation(); }, 10); diff --git a/tests/lib/Event/URLServiceTest.php b/tests/lib/Event/URLServiceTest.php index 33c84641fd..46120dabec 100644 --- a/tests/lib/Event/URLServiceTest.php +++ b/tests/lib/Event/URLServiceTest.php @@ -62,7 +62,7 @@ public function testReturnUpdateUrlResultInBeforeEvents(): void $innerServiceMock = $this->createMock(URLServiceInterface::class); $innerServiceMock->method('updateUrl')->willReturn($updatedUrl); - $traceableEventDispatcher->addListener(BeforeUpdateUrlEvent::class, static function (BeforeUpdateUrlEvent $event) use ($eventUpdatedUrl) { + $traceableEventDispatcher->addListener(BeforeUpdateUrlEvent::class, static function (BeforeUpdateUrlEvent $event) use ($eventUpdatedUrl): void { $event->setUpdatedUrl($eventUpdatedUrl); }, 10); @@ -97,7 +97,7 @@ public function testUpdateUrlStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(URLServiceInterface::class); $innerServiceMock->method('updateUrl')->willReturn($updatedUrl); - $traceableEventDispatcher->addListener(BeforeUpdateUrlEvent::class, static function (BeforeUpdateUrlEvent $event) use ($eventUpdatedUrl) { + $traceableEventDispatcher->addListener(BeforeUpdateUrlEvent::class, static function (BeforeUpdateUrlEvent $event) use ($eventUpdatedUrl): void { $event->setUpdatedUrl($eventUpdatedUrl); $event->stopPropagation(); }, 10); diff --git a/tests/lib/Event/URLWildcardServiceTest.php b/tests/lib/Event/URLWildcardServiceTest.php index 593bba2ba3..46aa68f2a9 100644 --- a/tests/lib/Event/URLWildcardServiceTest.php +++ b/tests/lib/Event/URLWildcardServiceTest.php @@ -67,7 +67,7 @@ public function testRemoveStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(URLWildcardServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeRemoveEvent::class, static function (BeforeRemoveEvent $event) { + $traceableEventDispatcher->addListener(BeforeRemoveEvent::class, static function (BeforeRemoveEvent $event): void { $event->stopPropagation(); }, 10); @@ -130,7 +130,7 @@ public function testUpdateStopPropagationInBeforeEvents(): void $traceableEventDispatcher->addListener( BeforeUpdateEvent::class, - static function (BeforeUpdateEvent $event) { + static function (BeforeUpdateEvent $event): void { $event->stopPropagation(); }, 10 @@ -207,7 +207,7 @@ public function testReturnCreateResultInBeforeEvents(): void $innerServiceMock = $this->createMock(URLWildcardServiceInterface::class); $innerServiceMock->method('create')->willReturn($urlWildcard); - $traceableEventDispatcher->addListener(BeforeCreateEvent::class, static function (BeforeCreateEvent $event) use ($eventUrlWildcard) { + $traceableEventDispatcher->addListener(BeforeCreateEvent::class, static function (BeforeCreateEvent $event) use ($eventUrlWildcard): void { $event->setUrlWildcard($eventUrlWildcard); }, 10); @@ -243,7 +243,7 @@ public function testCreateStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(URLWildcardServiceInterface::class); $innerServiceMock->method('create')->willReturn($urlWildcard); - $traceableEventDispatcher->addListener(BeforeCreateEvent::class, static function (BeforeCreateEvent $event) use ($eventUrlWildcard) { + $traceableEventDispatcher->addListener(BeforeCreateEvent::class, static function (BeforeCreateEvent $event) use ($eventUrlWildcard): void { $event->setUrlWildcard($eventUrlWildcard); $event->stopPropagation(); }, 10); @@ -308,7 +308,7 @@ public function testReturnTranslateResultInBeforeEvents(): void $innerServiceMock = $this->createMock(URLWildcardServiceInterface::class); $innerServiceMock->method('translate')->willReturn($result); - $traceableEventDispatcher->addListener(BeforeTranslateEvent::class, static function (BeforeTranslateEvent $event) use ($eventResult) { + $traceableEventDispatcher->addListener(BeforeTranslateEvent::class, static function (BeforeTranslateEvent $event) use ($eventResult): void { $event->setResult($eventResult); }, 10); @@ -342,7 +342,7 @@ public function testTranslateStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(URLWildcardServiceInterface::class); $innerServiceMock->method('translate')->willReturn($result); - $traceableEventDispatcher->addListener(BeforeTranslateEvent::class, static function (BeforeTranslateEvent $event) use ($eventResult) { + $traceableEventDispatcher->addListener(BeforeTranslateEvent::class, static function (BeforeTranslateEvent $event) use ($eventResult): void { $event->setResult($eventResult); $event->stopPropagation(); }, 10); diff --git a/tests/lib/Event/UserPreferenceServiceTest.php b/tests/lib/Event/UserPreferenceServiceTest.php index 9cdc3a72b1..7dd837a940 100644 --- a/tests/lib/Event/UserPreferenceServiceTest.php +++ b/tests/lib/Event/UserPreferenceServiceTest.php @@ -52,7 +52,7 @@ public function testSetUserPreferenceStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(UserPreferenceServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeSetUserPreferenceEvent::class, static function (BeforeSetUserPreferenceEvent $event) { + $traceableEventDispatcher->addListener(BeforeSetUserPreferenceEvent::class, static function (BeforeSetUserPreferenceEvent $event): void { $event->stopPropagation(); }, 10); diff --git a/tests/lib/Event/UserServiceTest.php b/tests/lib/Event/UserServiceTest.php index 3a173108b9..4a188f7e7b 100644 --- a/tests/lib/Event/UserServiceTest.php +++ b/tests/lib/Event/UserServiceTest.php @@ -85,7 +85,7 @@ public function testReturnUpdateUserGroupResultInBeforeEvents(): void $innerServiceMock = $this->createMock(UserServiceInterface::class); $innerServiceMock->method('updateUserGroup')->willReturn($updatedUserGroup); - $traceableEventDispatcher->addListener(BeforeUpdateUserGroupEvent::class, static function (BeforeUpdateUserGroupEvent $event) use ($eventUpdatedUserGroup) { + $traceableEventDispatcher->addListener(BeforeUpdateUserGroupEvent::class, static function (BeforeUpdateUserGroupEvent $event) use ($eventUpdatedUserGroup): void { $event->setUpdatedUserGroup($eventUpdatedUserGroup); }, 10); @@ -120,7 +120,7 @@ public function testUpdateUserGroupStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(UserServiceInterface::class); $innerServiceMock->method('updateUserGroup')->willReturn($updatedUserGroup); - $traceableEventDispatcher->addListener(BeforeUpdateUserGroupEvent::class, static function (BeforeUpdateUserGroupEvent $event) use ($eventUpdatedUserGroup) { + $traceableEventDispatcher->addListener(BeforeUpdateUserGroupEvent::class, static function (BeforeUpdateUserGroupEvent $event) use ($eventUpdatedUserGroup): void { $event->setUpdatedUserGroup($eventUpdatedUserGroup); $event->stopPropagation(); }, 10); @@ -187,7 +187,7 @@ public function testReturnUpdateUserResultInBeforeEvents(): void $innerServiceMock = $this->createMock(UserServiceInterface::class); $innerServiceMock->method('updateUser')->willReturn($updatedUser); - $traceableEventDispatcher->addListener(BeforeUpdateUserEvent::class, static function (BeforeUpdateUserEvent $event) use ($eventUpdatedUser) { + $traceableEventDispatcher->addListener(BeforeUpdateUserEvent::class, static function (BeforeUpdateUserEvent $event) use ($eventUpdatedUser): void { $event->setUpdatedUser($eventUpdatedUser); }, 10); @@ -222,7 +222,7 @@ public function testUpdateUserStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(UserServiceInterface::class); $innerServiceMock->method('updateUser')->willReturn($updatedUser); - $traceableEventDispatcher->addListener(BeforeUpdateUserEvent::class, static function (BeforeUpdateUserEvent $event) use ($eventUpdatedUser) { + $traceableEventDispatcher->addListener(BeforeUpdateUserEvent::class, static function (BeforeUpdateUserEvent $event) use ($eventUpdatedUser): void { $event->setUpdatedUser($eventUpdatedUser); $event->stopPropagation(); }, 10); @@ -283,7 +283,7 @@ public function testUnAssignUserFromUserGroupStopPropagationInBeforeEvents(): vo $innerServiceMock = self::createStub(UserServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeUnAssignUserFromUserGroupEvent::class, static function (BeforeUnAssignUserFromUserGroupEvent $event) { + $traceableEventDispatcher->addListener(BeforeUnAssignUserFromUserGroupEvent::class, static function (BeforeUnAssignUserFromUserGroupEvent $event): void { $event->stopPropagation(); }, 10); @@ -346,7 +346,7 @@ public function testReturnDeleteUserGroupResultInBeforeEvents(): void $innerServiceMock = $this->createMock(UserServiceInterface::class); $innerServiceMock->method('deleteUserGroup')->willReturn($locations); - $traceableEventDispatcher->addListener(BeforeDeleteUserGroupEvent::class, static function (BeforeDeleteUserGroupEvent $event) use ($eventLocations) { + $traceableEventDispatcher->addListener(BeforeDeleteUserGroupEvent::class, static function (BeforeDeleteUserGroupEvent $event) use ($eventLocations): void { $event->setLocations($eventLocations); }, 10); @@ -380,7 +380,7 @@ public function testDeleteUserGroupStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(UserServiceInterface::class); $innerServiceMock->method('deleteUserGroup')->willReturn($locations); - $traceableEventDispatcher->addListener(BeforeDeleteUserGroupEvent::class, static function (BeforeDeleteUserGroupEvent $event) use ($eventLocations) { + $traceableEventDispatcher->addListener(BeforeDeleteUserGroupEvent::class, static function (BeforeDeleteUserGroupEvent $event) use ($eventLocations): void { $event->setLocations($eventLocations); $event->stopPropagation(); }, 10); @@ -441,7 +441,7 @@ public function testAssignUserToUserGroupStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(UserServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeAssignUserToUserGroupEvent::class, static function (BeforeAssignUserToUserGroupEvent $event) { + $traceableEventDispatcher->addListener(BeforeAssignUserToUserGroupEvent::class, static function (BeforeAssignUserToUserGroupEvent $event): void { $event->stopPropagation(); }, 10); @@ -504,7 +504,7 @@ public function testReturnDeleteUserResultInBeforeEvents(): void $innerServiceMock = $this->createMock(UserServiceInterface::class); $innerServiceMock->method('deleteUser')->willReturn($locations); - $traceableEventDispatcher->addListener(BeforeDeleteUserEvent::class, static function (BeforeDeleteUserEvent $event) use ($eventLocations) { + $traceableEventDispatcher->addListener(BeforeDeleteUserEvent::class, static function (BeforeDeleteUserEvent $event) use ($eventLocations): void { $event->setLocations($eventLocations); }, 10); @@ -538,7 +538,7 @@ public function testDeleteUserStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(UserServiceInterface::class); $innerServiceMock->method('deleteUser')->willReturn($locations); - $traceableEventDispatcher->addListener(BeforeDeleteUserEvent::class, static function (BeforeDeleteUserEvent $event) use ($eventLocations) { + $traceableEventDispatcher->addListener(BeforeDeleteUserEvent::class, static function (BeforeDeleteUserEvent $event) use ($eventLocations): void { $event->setLocations($eventLocations); $event->stopPropagation(); }, 10); @@ -599,7 +599,7 @@ public function testMoveUserGroupStopPropagationInBeforeEvents(): void $innerServiceMock = self::createStub(UserServiceInterface::class); - $traceableEventDispatcher->addListener(BeforeMoveUserGroupEvent::class, static function (BeforeMoveUserGroupEvent $event) { + $traceableEventDispatcher->addListener(BeforeMoveUserGroupEvent::class, static function (BeforeMoveUserGroupEvent $event): void { $event->stopPropagation(); }, 10); @@ -664,7 +664,7 @@ public function testReturnCreateUserResultInBeforeEvents(): void $innerServiceMock = $this->createMock(UserServiceInterface::class); $innerServiceMock->method('createUser')->willReturn($user); - $traceableEventDispatcher->addListener(BeforeCreateUserEvent::class, static function (BeforeCreateUserEvent $event) use ($eventUser) { + $traceableEventDispatcher->addListener(BeforeCreateUserEvent::class, static function (BeforeCreateUserEvent $event) use ($eventUser): void { $event->setUser($eventUser); }, 10); @@ -699,7 +699,7 @@ public function testCreateUserStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(UserServiceInterface::class); $innerServiceMock->method('createUser')->willReturn($user); - $traceableEventDispatcher->addListener(BeforeCreateUserEvent::class, static function (BeforeCreateUserEvent $event) use ($eventUser) { + $traceableEventDispatcher->addListener(BeforeCreateUserEvent::class, static function (BeforeCreateUserEvent $event) use ($eventUser): void { $event->setUser($eventUser); $event->stopPropagation(); }, 10); @@ -766,7 +766,7 @@ public function testReturnCreateUserGroupResultInBeforeEvents(): void $innerServiceMock = $this->createMock(UserServiceInterface::class); $innerServiceMock->method('createUserGroup')->willReturn($userGroup); - $traceableEventDispatcher->addListener(BeforeCreateUserGroupEvent::class, static function (BeforeCreateUserGroupEvent $event) use ($eventUserGroup) { + $traceableEventDispatcher->addListener(BeforeCreateUserGroupEvent::class, static function (BeforeCreateUserGroupEvent $event) use ($eventUserGroup): void { $event->setUserGroup($eventUserGroup); }, 10); @@ -801,7 +801,7 @@ public function testCreateUserGroupStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(UserServiceInterface::class); $innerServiceMock->method('createUserGroup')->willReturn($userGroup); - $traceableEventDispatcher->addListener(BeforeCreateUserGroupEvent::class, static function (BeforeCreateUserGroupEvent $event) use ($eventUserGroup) { + $traceableEventDispatcher->addListener(BeforeCreateUserGroupEvent::class, static function (BeforeCreateUserGroupEvent $event) use ($eventUserGroup): void { $event->setUserGroup($eventUserGroup); $event->stopPropagation(); }, 10); @@ -868,7 +868,7 @@ public function testReturnUpdateUserTokenResultInBeforeEvents(): void $innerServiceMock = $this->createMock(UserServiceInterface::class); $innerServiceMock->method('updateUserToken')->willReturn($updatedUser); - $traceableEventDispatcher->addListener(BeforeUpdateUserTokenEvent::class, static function (BeforeUpdateUserTokenEvent $event) use ($eventUpdatedUser) { + $traceableEventDispatcher->addListener(BeforeUpdateUserTokenEvent::class, static function (BeforeUpdateUserTokenEvent $event) use ($eventUpdatedUser): void { $event->setUpdatedUser($eventUpdatedUser); }, 10); @@ -903,7 +903,7 @@ public function testUpdateUserTokenStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(UserServiceInterface::class); $innerServiceMock->method('updateUserToken')->willReturn($updatedUser); - $traceableEventDispatcher->addListener(BeforeUpdateUserTokenEvent::class, static function (BeforeUpdateUserTokenEvent $event) use ($eventUpdatedUser) { + $traceableEventDispatcher->addListener(BeforeUpdateUserTokenEvent::class, static function (BeforeUpdateUserTokenEvent $event) use ($eventUpdatedUser): void { $event->setUpdatedUser($eventUpdatedUser); $event->stopPropagation(); }, 10); diff --git a/tests/lib/FieldType/Generic/GenericTest.php b/tests/lib/FieldType/Generic/GenericTest.php index 7f881b1950..892e31db58 100644 --- a/tests/lib/FieldType/Generic/GenericTest.php +++ b/tests/lib/FieldType/Generic/GenericTest.php @@ -59,7 +59,7 @@ public function testValidateInvalid(array $fieldDefinitionData, FieldTypeValue $ { $constraintViolationList = new ConstraintViolationList( array_map( - static fn (ValidationError $error) => new ConstraintViolation( + static fn (ValidationError $error): \Symfony\Component\Validator\ConstraintViolation => new ConstraintViolation( (string)$error->getTranslatableMessage(), null, [], @@ -171,13 +171,13 @@ private function createSerializerMock(): ValueSerializerInterface $serializer ->method('decode') - ->willReturnCallback(static function (string $json) { + ->willReturnCallback(static function (string $json): mixed { return json_decode($json, true, 512, JSON_THROW_ON_ERROR); }); $serializer ->method('normalize') - ->willReturnCallback(static function (GenericFieldValueStub $value) { + ->willReturnCallback(static function (GenericFieldValueStub $value): array { return [ 'value' => $value->getValue(), ]; @@ -185,7 +185,7 @@ private function createSerializerMock(): ValueSerializerInterface $serializer ->method('denormalize') - ->willReturnCallback(static function (array $data, string $valueClass) { + ->willReturnCallback(static function (array $data, string $valueClass): \Ibexa\Tests\Core\FieldType\Generic\Stubs\Value { self::assertEquals(GenericFieldValueStub::class, $valueClass); return new GenericFieldValueStub($data['value']); diff --git a/tests/lib/FieldType/RelationListTest.php b/tests/lib/FieldType/RelationListTest.php index 6e36da344b..81ed1e7213 100644 --- a/tests/lib/FieldType/RelationListTest.php +++ b/tests/lib/FieldType/RelationListTest.php @@ -423,7 +423,7 @@ public function testValidateNotExistingContentRelations(): void $this->targetContentValidator ->expects($matcher) - ->method('validate')->willReturnCallback(function (...$parameters) use ($matcher, $invalidDestinationContentId, $invalidDestinationContentId2) { + ->method('validate')->willReturnCallback(function (...$parameters) use ($matcher, $invalidDestinationContentId, $invalidDestinationContentId2): ?ValidationError { if ($matcher->numberOfInvocations() === 1) { self::assertSame($invalidDestinationContentId, $parameters[0]); @@ -434,6 +434,8 @@ public function testValidateNotExistingContentRelations(): void return $this->generateValidationError($invalidDestinationContentId2); } + + return null; }); $validationErrors = $this->doValidate([], new Value([$invalidDestinationContentId, $invalidDestinationContentId2])); @@ -450,7 +452,7 @@ public function testValidateInvalidContentType(): void $matcher = self::exactly(2); $this->targetContentValidator->expects($matcher) - ->method('validate')->willReturnCallback(function (...$parameters) use ($matcher, $destinationContentId, $allowedContentTypes, $destinationContentId2) { + ->method('validate')->willReturnCallback(function (...$parameters) use ($matcher, $destinationContentId, $allowedContentTypes, $destinationContentId2): ?ValidationError { if ($matcher->numberOfInvocations() === 1) { self::assertSame($destinationContentId, $parameters[0]); self::assertSame($allowedContentTypes, $parameters[1]); @@ -463,6 +465,8 @@ public function testValidateInvalidContentType(): void return $this->generateContentTypeValidationError('test'); } + + return null; }); $validationErrors = $this->doValidate( diff --git a/tests/lib/FieldType/UserTest.php b/tests/lib/FieldType/UserTest.php index 9d490ddcb0..79f1caf735 100644 --- a/tests/lib/FieldType/UserTest.php +++ b/tests/lib/FieldType/UserTest.php @@ -508,7 +508,7 @@ public static function providerForTestValidate(): array 'email' ), ], - static function (InvocationMocker $loadByLoginInvocationMocker) { + static function (InvocationMocker $loadByLoginInvocationMocker): void { $loadByLoginInvocationMocker->willThrowException( new NotFoundException('user', 'user') ); @@ -536,7 +536,7 @@ static function (InvocationMocker $loadByLoginInvocationMocker) { 'username' ), ], - static function (InvocationMocker $loadByLoginInvocationMocker) { + static function (InvocationMocker $loadByLoginInvocationMocker): void { $loadByLoginInvocationMocker->willReturn( self::createStub(UserValue::class) ); diff --git a/tests/lib/IO/ConfigScopeChangeAwareIOServiceTest.php b/tests/lib/IO/ConfigScopeChangeAwareIOServiceTest.php index 6b83486844..c72f6f5257 100644 --- a/tests/lib/IO/ConfigScopeChangeAwareIOServiceTest.php +++ b/tests/lib/IO/ConfigScopeChangeAwareIOServiceTest.php @@ -49,21 +49,37 @@ protected function setUp(): void ); } - public function testConstructor(): void + public function testConstructorDoesNotResolvePrefixEagerly(): void { $this->innerIOService - ->expects(self::once()) + ->expects(self::never()) ->method('setPrefix') - ->with(self::PREFIX) ; - new ConfigScopeChangeAwareIOService( + // Assigned (rather than a bare `new` statement) purely to construct the object under test; + // the "never" expectation above is what PHPUnit verifies when the test finishes. + $ioService = new ConfigScopeChangeAwareIOService( $this->configResolver, $this->innerIOService, self::PREFIX_PARAMETER_NAME ); } + public function testPrefixIsResolvedLazilyOnFirstUse(): void + { + $this->innerIOService + ->expects(self::once()) + ->method('setPrefix') + ->with(self::PREFIX) + ; + + $this->innerIOService->method('exists')->willReturn(true); + + self::assertTrue($this->ioService->exists('test-id')); + // second call must not resolve the prefix again + self::assertTrue($this->ioService->exists('test-id')); + } + public function testSetPrefix(): void { $this->innerIOService @@ -273,14 +289,21 @@ public function testDeleteDirectory(): void $this->innerIOService->deleteDirectory($path); } - public function testOnConfigScopeChange(): void + public function testOnConfigScopeChangeResolvesPrefixAgainOnNextUse(): void { $event = self::createStub(ScopeChangeEvent::class); + $this->innerIOService->method('exists')->willReturn(true); + + // resolve the prefix once + $this->ioService->exists('test-id'); + + $this->ioService->onConfigScopeChange($event); + $this->innerIOService ->expects(self::once()) ->method('setPrefix') ->with(self::PREFIX); - $this->ioService->onConfigScopeChange($event); + $this->ioService->exists('test-id'); } } diff --git a/tests/lib/IO/IOMetadataHandler/LegacyDFSClusterTest.php b/tests/lib/IO/IOMetadataHandler/LegacyDFSClusterTest.php index 1778f18575..f0c7545f08 100644 --- a/tests/lib/IO/IOMetadataHandler/LegacyDFSClusterTest.php +++ b/tests/lib/IO/IOMetadataHandler/LegacyDFSClusterTest.php @@ -163,7 +163,7 @@ public function testDeletedirectory(): void $this->qbMock ->expects($matcher) - ->method('setParameter')->willReturnCallback(function (...$parameters) use ($matcher) { + ->method('setParameter')->willReturnCallback(function (...$parameters) use ($matcher): QueryBuilder&MockObject { if ($matcher->numberOfInvocations() === 1) { self::assertSame('esc', $parameters[0]); self::assertSame('\\', $parameters[1]); diff --git a/tests/lib/Limitation/MemberOfLimitationTypeTest.php b/tests/lib/Limitation/MemberOfLimitationTypeTest.php index 747ace7046..38f1fe6389 100644 --- a/tests/lib/Limitation/MemberOfLimitationTypeTest.php +++ b/tests/lib/Limitation/MemberOfLimitationTypeTest.php @@ -121,7 +121,7 @@ public function testValidateError(MemberOfLimitation $limitation, int $errorCoun if ($limitation->limitationValues !== null) { $matcher = self::exactly(2); $contentHandlerMock->expects($matcher) - ->method('loadContentInfo')->willReturnCallback(static function (...$parameters) use ($matcher) { + ->method('loadContentInfo')->willReturnCallback(static function (...$parameters) use ($matcher): ?ContentInfo { if ($matcher->numberOfInvocations() === 1) { self::assertSame(14, $parameters[0]); @@ -132,6 +132,8 @@ public function testValidateError(MemberOfLimitation $limitation, int $errorCoun return new ContentInfo(); } + + return null; }); $this->getPersistenceMock() @@ -174,7 +176,7 @@ public function testEvaluate( $matcher = self::exactly(2); $locationHandlerMock->expects($matcher) - ->method('load')->willReturnCallback(static function (...$parameters) use ($matcher) { + ->method('load')->willReturnCallback(static function (...$parameters) use ($matcher): ?Location { if ($matcher->numberOfInvocations() === 1) { self::assertSame(13, $parameters[0]); @@ -185,6 +187,8 @@ public function testEvaluate( return new Location(['contentId' => 25]); } + + return null; }); $this->getPersistenceMock() @@ -368,7 +372,7 @@ public function testEvaluateSelfGroup( } $matcher = self::exactly(2); $locationHandlerMock->expects($matcher) - ->method('loadLocationsByContent')->willReturnCallback(function (...$parameters) use ($matcher, $object, $currentUserLocation) { + ->method('loadLocationsByContent')->willReturnCallback(function (...$parameters) use ($matcher, $object, $currentUserLocation): ?array { if ($matcher->numberOfInvocations() === 1) { self::assertSame($object instanceof User ? $object->getUserId() : $object->getUser()->getUserId(), $parameters[0]); @@ -382,11 +386,13 @@ public function testEvaluateSelfGroup( return $currentUserLocation; } + + return null; }); $matcher = self::exactly(2 + count($currentUserGroupLocations)); $locationHandlerMock->expects($matcher) - ->method('load')->willReturnCallback(static function (...$parameters) use ($matcher, $currentUserGroupLocations) { + ->method('load')->willReturnCallback(static function (...$parameters) use ($matcher, $currentUserGroupLocations): Location { if ($matcher->numberOfInvocations() === 1) { self::assertSame(13, $parameters[0]); diff --git a/tests/lib/Limitation/ParentContentTypeLimitationTypeTest.php b/tests/lib/Limitation/ParentContentTypeLimitationTypeTest.php index ef1df5efe9..d042f33482 100644 --- a/tests/lib/Limitation/ParentContentTypeLimitationTypeTest.php +++ b/tests/lib/Limitation/ParentContentTypeLimitationTypeTest.php @@ -151,7 +151,7 @@ public function testValidatePass(ParentContentTypeLimitation $limitation): void $this->contentTypeHandlerMock ->expects($matcher) ->method('load') - ->willReturnCallback(static function ($actualValue) use ($matcher, $limitationValues) { + ->willReturnCallback(static function ($actualValue) use ($matcher, $limitationValues): int { self::assertSame($limitationValues[$matcher->numberOfInvocations() - 1], $actualValue); return 42; @@ -495,7 +495,7 @@ private function assertContentHandlerExpectations(array $contentIds, array $cont $this->contentHandlerMock ->expects($matcher) ->method('loadContentInfo') - ->willReturnCallback(static function ($contentId) use ($matcher, $contentIds, $contentInfos) { + ->willReturnCallback(static function ($contentId) use ($matcher, $contentIds, $contentInfos): SPIContentInfo { self::assertSame($contentIds[$matcher->numberOfInvocations() - 1], $contentId); return $contentInfos[$matcher->numberOfInvocations() - 1]; @@ -564,7 +564,7 @@ public function testEvaluate( $this->locationHandlerMock ->expects($locationMatcher) ->method('load') - ->willReturnCallback(static function ($parentLocationId) use ($locationMatcher, $locationLoadArguments, $locationLoadReturnValues) { + ->willReturnCallback(static function ($parentLocationId) use ($locationMatcher, $locationLoadArguments, $locationLoadReturnValues): SPILocation { self::assertSame($locationLoadArguments[$locationMatcher->numberOfInvocations() - 1], $parentLocationId); return $locationLoadReturnValues[$locationMatcher->numberOfInvocations() - 1]; diff --git a/tests/lib/Limitation/ParentDepthLimitationTypeTest.php b/tests/lib/Limitation/ParentDepthLimitationTypeTest.php index b35a346d3a..e8fa052ad0 100644 --- a/tests/lib/Limitation/ParentDepthLimitationTypeTest.php +++ b/tests/lib/Limitation/ParentDepthLimitationTypeTest.php @@ -328,7 +328,7 @@ public function testEvaluate( $this->locationHandlerMock ->expects($matcher) ->method('load') - ->willReturnCallback(static function ($parentLocationId) use ($matcher, $parentLocationIds, $persistenceLocations) { + ->willReturnCallback(static function ($parentLocationId) use ($matcher, $parentLocationIds, $persistenceLocations): Location { self::assertSame($parentLocationIds[$matcher->numberOfInvocations() - 1], $parentLocationId); return $persistenceLocations[$parentLocationId]; diff --git a/tests/lib/Limitation/RoleLimitationTypeTest.php b/tests/lib/Limitation/RoleLimitationTypeTest.php index 4da283fcc5..48065f7a67 100644 --- a/tests/lib/Limitation/RoleLimitationTypeTest.php +++ b/tests/lib/Limitation/RoleLimitationTypeTest.php @@ -105,7 +105,7 @@ public function testValidatePass(UserRoleLimitation $limitation): void if ($limitation->limitationValues !== null) { $matcher = self::any(); $userHandlerMock->expects($matcher) - ->method('loadRole')->willReturnCallback(static function (...$parameters) use ($matcher) { + ->method('loadRole')->willReturnCallback(static function (...$parameters) use ($matcher): void { if ($matcher->numberOfInvocations() === 1) { self::assertSame(4, $parameters[0]); self::assertSame(Role::STATUS_DEFINED, $parameters[1]); @@ -124,7 +124,7 @@ public function testValidatePass(UserRoleLimitation $limitation): void if ($limitation->limitationValues !== null) { $matcher = self::any(); $contentHandlerMock->expects($matcher) - ->method('loadContentInfo')->willReturnCallback(static function (...$parameters) use ($matcher) { + ->method('loadContentInfo')->willReturnCallback(static function (...$parameters) use ($matcher): void { if ($matcher->numberOfInvocations() === 1) { self::assertSame(14, $parameters[0]); } @@ -151,7 +151,7 @@ public function testValidateError(UserRoleLimitation $limitation, int $errorCoun if ($limitation->limitationValues !== null) { $matcher = self::exactly(2); $userHandlerMock->expects($matcher) - ->method('loadRole')->willReturnCallback(static function (...$parameters) use ($matcher) { + ->method('loadRole')->willReturnCallback(static function (...$parameters) use ($matcher): ?Role { if ($matcher->numberOfInvocations() === 1) { self::assertSame(4, $parameters[0]); self::assertSame(Role::STATUS_DEFINED, $parameters[1]); @@ -164,6 +164,8 @@ public function testValidateError(UserRoleLimitation $limitation, int $errorCoun return new Role(); } + + return null; }); $this->getPersistenceMock() diff --git a/tests/lib/Limitation/SubtreeLimitationTypeTest.php b/tests/lib/Limitation/SubtreeLimitationTypeTest.php index cbedceebb5..6fad3cde02 100644 --- a/tests/lib/Limitation/SubtreeLimitationTypeTest.php +++ b/tests/lib/Limitation/SubtreeLimitationTypeTest.php @@ -151,7 +151,7 @@ public function testValidatePass(SubtreeLimitation $limitation): void $this->locationHandlerMock ->expects($matcher) ->method('load') - ->willReturnCallback(static function (...$parameters) use ($matcher, $loadArguments, $loadReturnValues) { + ->willReturnCallback(static function (...$parameters) use ($matcher, $loadArguments, $loadReturnValues): SPILocation { self::assertSame($loadArguments[$matcher->numberOfInvocations() - 1], $parameters[0]); return $loadReturnValues[$matcher->numberOfInvocations() - 1]; @@ -202,7 +202,7 @@ public function testValidateError(SubtreeLimitation $limitation, $errorCount): v $this->locationHandlerMock ->expects($matcher) ->method('load') - ->willReturnCallback(static function (...$parameters) use ($matcher, $loadArguments, $loadExceptions) { + ->willReturnCallback(static function (...$parameters) use ($matcher, $loadArguments, $loadExceptions): void { self::assertSame($loadArguments[$matcher->numberOfInvocations() - 1], $parameters[0]); throw $loadExceptions[$matcher->numberOfInvocations() - 1]; @@ -241,7 +241,7 @@ public function testValidateErrorWrongPath(): void $this->locationHandlerMock ->expects($matcher) ->method('load') - ->willReturnCallback(static function (...$parameters) use ($matcher, $loadArguments, $loadReturnValues) { + ->willReturnCallback(static function (...$parameters) use ($matcher, $loadArguments, $loadReturnValues): SPILocation { self::assertSame($loadArguments[$matcher->numberOfInvocations() - 1], $parameters[0]); return $loadReturnValues[$matcher->numberOfInvocations() - 1]; @@ -454,7 +454,7 @@ public function testEvaluate( $this->locationHandlerMock ->expects($matcher) ->method('load') - ->willReturnCallback(static function (...$parameters) use ($matcher, $loadArguments, $loadReturnValues) { + ->willReturnCallback(static function (...$parameters) use ($matcher, $loadArguments, $loadReturnValues): Location { self::assertSame($loadArguments[$matcher->numberOfInvocations() - 1], $parameters[0]); return $loadReturnValues[$matcher->numberOfInvocations() - 1]; diff --git a/tests/lib/MVC/Symfony/Controller/Controller/Content/PreviewControllerTest.php b/tests/lib/MVC/Symfony/Controller/Controller/Content/PreviewControllerTest.php index a655df993e..91e67f0d4d 100644 --- a/tests/lib/MVC/Symfony/Controller/Controller/Content/PreviewControllerTest.php +++ b/tests/lib/MVC/Symfony/Controller/Controller/Content/PreviewControllerTest.php @@ -335,7 +335,7 @@ private function configurePreviewHelper( $matcher = self::exactly(2); $this->previewHelper ->expects($matcher) - ->method('setPreviewActive')->willReturnCallback(static function (...$parameters) use ($matcher) { + ->method('setPreviewActive')->willReturnCallback(static function (...$parameters) use ($matcher): void { if ($matcher->numberOfInvocations() === 1) { self::assertTrue($parameters[0]); } diff --git a/tests/lib/MVC/Symfony/FieldType/ImageAsset/ParameterProviderTest.php b/tests/lib/MVC/Symfony/FieldType/ImageAsset/ParameterProviderTest.php index 95ab0ba8d7..f18054a315 100644 --- a/tests/lib/MVC/Symfony/FieldType/ImageAsset/ParameterProviderTest.php +++ b/tests/lib/MVC/Symfony/FieldType/ImageAsset/ParameterProviderTest.php @@ -75,7 +75,7 @@ public function testGetViewParameters($status, array $expected): void ->method('isEmptyValue') ->willReturn(false); - $closure = static function (Repository $repository) use ($destinationContentId) { + $closure = static function (Repository $repository) use ($destinationContentId): \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo { return $repository->getContentService()->loadContentInfo($destinationContentId); }; @@ -103,7 +103,7 @@ public function testGetViewParametersHandleNotFoundException(): void ->method('isEmptyValue') ->willReturn(false); - $closure = static function (Repository $repository) use ($destinationContentId) { + $closure = static function (Repository $repository) use ($destinationContentId): \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo { return $repository->getContentService()->loadContentInfo($destinationContentId); }; diff --git a/tests/lib/MVC/Symfony/FieldType/RelationList/ParameterProviderTest.php b/tests/lib/MVC/Symfony/FieldType/RelationList/ParameterProviderTest.php index 7828434e39..ab8b775b1b 100644 --- a/tests/lib/MVC/Symfony/FieldType/RelationList/ParameterProviderTest.php +++ b/tests/lib/MVC/Symfony/FieldType/RelationList/ParameterProviderTest.php @@ -37,7 +37,7 @@ public function testGetViewParameters(array $desinationContentIds, array $expect $contentServiceMock ->method('loadContentInfoList') ->with($desinationContentIds) - ->will(self::returnCallback(static function ($arg) { + ->will(self::returnCallback(static function ($arg): array { $return = []; if (in_array(123, $arg)) { $return[123] = new ContentInfo(['status' => ContentInfo::STATUS_DRAFT]); diff --git a/tests/lib/MVC/Symfony/Routing/UrlAliasGeneratorTest.php b/tests/lib/MVC/Symfony/Routing/UrlAliasGeneratorTest.php index 4f453c0a17..0c28d5df88 100644 --- a/tests/lib/MVC/Symfony/Routing/UrlAliasGeneratorTest.php +++ b/tests/lib/MVC/Symfony/Routing/UrlAliasGeneratorTest.php @@ -260,7 +260,7 @@ public function testDoGenerateWithSiteAccessParam(URLAlias $urlAlias, array $par ->method('loadLocation') ->will( self::returnCallback( - static function ($locationId) { + static function ($locationId): \Ibexa\Core\Repository\Values\Content\Location { return new Location(['id' => $locationId]); } ) @@ -270,7 +270,7 @@ static function ($locationId) { ->method('reverseLookup') ->will( self::returnCallback( - static function ($location) use ($treeRootUrlAlias) { + static function ($location) use ($treeRootUrlAlias): URLAlias { return $treeRootUrlAlias[$location->id]; } ) diff --git a/tests/lib/MVC/Symfony/SiteAccess/Provider/ChainSiteAccessProviderTest.php b/tests/lib/MVC/Symfony/SiteAccess/Provider/ChainSiteAccessProviderTest.php index d5f904516e..fa51f46aff 100644 --- a/tests/lib/MVC/Symfony/SiteAccess/Provider/ChainSiteAccessProviderTest.php +++ b/tests/lib/MVC/Symfony/SiteAccess/Provider/ChainSiteAccessProviderTest.php @@ -161,7 +161,7 @@ private function createSiteAcccess(string $name, array $groupNames = []): SiteAc StaticSiteAccessProvider::class ); $undefinedSiteAccess->groups = array_map( - static function (string $groupName) { + static function (string $groupName): \Ibexa\Core\MVC\Symfony\SiteAccessGroup { return new SiteAccessGroup($groupName); }, $groupNames diff --git a/tests/lib/MVC/Symfony/Templating/Twig/Extension/FileSizeExtensionTest.php b/tests/lib/MVC/Symfony/Templating/Twig/Extension/FileSizeExtensionTest.php index 9c1f8ea3dc..6c44538a9a 100644 --- a/tests/lib/MVC/Symfony/Templating/Twig/Extension/FileSizeExtensionTest.php +++ b/tests/lib/MVC/Symfony/Templating/Twig/Extension/FileSizeExtensionTest.php @@ -120,7 +120,7 @@ protected function getTranslatorInterfaceMock() $this->translatorMock ->expects(self::any())->method('trans')->will( self::returnCallback( - static function ($suffixes) use ($that) { + static function ($suffixes) use ($that): ?string { foreach ($that->getLocale() as $value) { if ($value === 'fre-FR') { return $suffixes . ' French version'; @@ -130,6 +130,8 @@ static function ($suffixes) use ($that) { return $suffixes . ' wrong local so we take the default one which is en-GB here'; } } + + return null; } ) ); diff --git a/tests/lib/MVC/Symfony/View/ViewManagerTest.php b/tests/lib/MVC/Symfony/View/ViewManagerTest.php index d2cbcb5ddf..3866fdcc92 100644 --- a/tests/lib/MVC/Symfony/View/ViewManagerTest.php +++ b/tests/lib/MVC/Symfony/View/ViewManagerTest.php @@ -77,7 +77,7 @@ public function testRenderContent(): void ->method('configure') ->will( self::returnCallback( - static function (View $view) use ($templateIdentifier) { + static function (View $view) use ($templateIdentifier): void { $view->setTemplateIdentifier($templateIdentifier); } ) @@ -113,7 +113,7 @@ public function testRenderContentWithClosure(): void ->method('configure') ->will( self::returnCallback( - static function (View $view) use ($closure) { + static function (View $view) use ($closure): void { $view->setTemplateIdentifier($closure); } ) @@ -144,7 +144,7 @@ public function testRenderLocation(): void ->method('configure') ->will( self::returnCallback( - static function (View $view) use ($templateIdentifier) { + static function (View $view) use ($templateIdentifier): void { $view->setTemplateIdentifier($templateIdentifier); } ) @@ -193,7 +193,7 @@ public function testRenderLocationWithContentPassed(): void ->method('configure') ->will( self::returnCallback( - static function (View $view) use ($templateIdentifier) { + static function (View $view) use ($templateIdentifier): void { $view->setTemplateIdentifier($templateIdentifier); } ) @@ -246,7 +246,7 @@ public function testRenderLocationWithClosure(): void ->method('configure') ->will( self::returnCallback( - static function (View $view) use ($closure) { + static function (View $view) use ($closure): void { $view->setTemplateIdentifier($closure); } ) diff --git a/tests/lib/Pagination/ContentSearchAdapterTest.php b/tests/lib/Pagination/ContentSearchAdapterTest.php index 9ff0b6d8a4..599ce15177 100644 --- a/tests/lib/Pagination/ContentSearchAdapterTest.php +++ b/tests/lib/Pagination/ContentSearchAdapterTest.php @@ -53,7 +53,7 @@ public function testGetSlice(): void $adapter = $this->getAdapter($query, $this->searchService, self::EXAMPLE_LANGUAGE_FILTER); self::assertSame( - array_map(static fn (SearchHit $hit) => $hit->valueObject, $hits), + array_map(static fn (SearchHit $hit): mixed => $hit->valueObject, $hits), $adapter->getSlice(self::EXAMPLE_OFFSET, self::EXAMPLE_LIMIT) ); $this->assertSearchResult($nbResults, $adapter, $aggregationsResults); diff --git a/tests/lib/Pagination/LocationSearchAdapterTest.php b/tests/lib/Pagination/LocationSearchAdapterTest.php index 86cd980bd5..8c7d6c5752 100644 --- a/tests/lib/Pagination/LocationSearchAdapterTest.php +++ b/tests/lib/Pagination/LocationSearchAdapterTest.php @@ -51,7 +51,7 @@ public function testGetSlice(): void $adapter = $this->getAdapter($query, $this->searchService, self::EXAMPLE_LANGUAGE_FILTER); self::assertSame( - array_map(static fn (SearchHit $hit) => $hit->valueObject, $hits), + array_map(static fn (SearchHit $hit): mixed => $hit->valueObject, $hits), $adapter->getSlice(self::EXAMPLE_OFFSET, self::EXAMPLE_LIMIT) ); diff --git a/tests/lib/Persistence/Cache/AbstractBaseHandlerTestCase.php b/tests/lib/Persistence/Cache/AbstractBaseHandlerTestCase.php index 3afb04afb9..d89c911da0 100644 --- a/tests/lib/Persistence/Cache/AbstractBaseHandlerTestCase.php +++ b/tests/lib/Persistence/Cache/AbstractBaseHandlerTestCase.php @@ -112,7 +112,7 @@ protected function setUp(): void ); $this->cacheItemsClosure = \Closure::bind( - static function ($key, $value, $isHit, $defaultLifetime = 0) { + static function ($key, $value, $isHit, $defaultLifetime = 0): CacheItem { $item = new CacheItem(); $item->key = $key; $item->value = $value; diff --git a/tests/lib/Persistence/Cache/AbstractCacheHandlerTestCase.php b/tests/lib/Persistence/Cache/AbstractCacheHandlerTestCase.php index 7a0b38f5d1..93ea5b92e4 100644 --- a/tests/lib/Persistence/Cache/AbstractCacheHandlerTestCase.php +++ b/tests/lib/Persistence/Cache/AbstractCacheHandlerTestCase.php @@ -76,7 +76,7 @@ final public function testUnCachedMethods( $this->cacheIdentifierGeneratorMock ->expects($matcher) ->method('generateTag') - ->willReturnCallback(static function (...$parameters) use ($matcher, $tagGeneratingArguments, $tags) { + ->willReturnCallback(static function (...$parameters) use ($matcher, $tagGeneratingArguments, $tags): mixed { self::assertEquals($tagGeneratingArguments[$matcher->numberOfInvocations() - 1], $parameters); return $tags[$matcher->numberOfInvocations() - 1]; @@ -91,7 +91,7 @@ final public function testUnCachedMethods( $this->cacheIdentifierGeneratorMock ->expects($matcher) ->method('generateKey') - ->willReturnCallback(static function (...$parameters) use ($matcher, $keyGeneratingArguments, $key) { + ->willReturnCallback(static function (...$parameters) use ($matcher, $keyGeneratingArguments, $key): mixed { self::assertEquals($keyGeneratingArguments[$matcher->numberOfInvocations() - 1], $parameters); return $key[$matcher->numberOfInvocations() - 1]; @@ -168,7 +168,7 @@ final public function testLoadMethodsCacheHit( $this->cacheIdentifierGeneratorMock ->expects($matcher) ->method('generateTag') - ->willReturnCallback(static function (...$parameters) use ($matcher, $tagGeneratingArguments, $tagGeneratingResults) { + ->willReturnCallback(static function (...$parameters) use ($matcher, $tagGeneratingArguments, $tagGeneratingResults): mixed { self::assertEquals($tagGeneratingArguments[$matcher->numberOfInvocations() - 1], $parameters); return $tagGeneratingResults[$matcher->numberOfInvocations() - 1]; @@ -180,7 +180,7 @@ final public function testLoadMethodsCacheHit( $this->cacheIdentifierGeneratorMock ->expects($matcher) ->method('generateKey') - ->willReturnCallback(static function (...$parameters) use ($matcher, $keyGeneratingArguments, $keyGeneratingResults) { + ->willReturnCallback(static function (...$parameters) use ($matcher, $keyGeneratingArguments, $keyGeneratingResults): mixed { self::assertEquals($keyGeneratingArguments[$matcher->numberOfInvocations() - 1], $parameters); return $keyGeneratingResults[$matcher->numberOfInvocations() - 1]; @@ -262,7 +262,7 @@ final public function testLoadMethodsCacheMiss( $this->cacheIdentifierGeneratorMock ->expects($matcher) ->method('generateTag') - ->willReturnCallback(static function (...$parameters) use ($matcher, $tagGeneratingArguments, $tagGeneratingResults) { + ->willReturnCallback(static function (...$parameters) use ($matcher, $tagGeneratingArguments, $tagGeneratingResults): mixed { self::assertEquals($tagGeneratingArguments[$matcher->numberOfInvocations() - 1], $parameters); return $tagGeneratingResults[$matcher->numberOfInvocations() - 1]; @@ -274,7 +274,7 @@ final public function testLoadMethodsCacheMiss( $this->cacheIdentifierGeneratorMock ->expects($matcher) ->method('generateKey') - ->willReturnCallback(static function (...$parameters) use ($matcher, $keyGeneratingArguments, $keyGeneratingResults) { + ->willReturnCallback(static function (...$parameters) use ($matcher, $keyGeneratingArguments, $keyGeneratingResults): mixed { self::assertEquals($keyGeneratingArguments[$matcher->numberOfInvocations() - 1], $parameters); return $keyGeneratingResults[$matcher->numberOfInvocations() - 1]; diff --git a/tests/lib/Persistence/Cache/AbstractInMemoryCacheHandlerTestCase.php b/tests/lib/Persistence/Cache/AbstractInMemoryCacheHandlerTestCase.php index 05e8b68c83..9e08f71b9d 100644 --- a/tests/lib/Persistence/Cache/AbstractInMemoryCacheHandlerTestCase.php +++ b/tests/lib/Persistence/Cache/AbstractInMemoryCacheHandlerTestCase.php @@ -68,7 +68,7 @@ final public function testUnCachedMethods( $this->cacheIdentifierGeneratorMock ->expects($matcher) ->method('generateTag') - ->willReturnCallback(static function (...$parameters) use ($matcher, $tagGeneratingArguments, $tags) { + ->willReturnCallback(static function (...$parameters) use ($matcher, $tagGeneratingArguments, $tags): mixed { self::assertEquals($tagGeneratingArguments[$matcher->numberOfInvocations() - 1], $parameters); return $tags[$matcher->numberOfInvocations() - 1]; @@ -83,7 +83,7 @@ final public function testUnCachedMethods( $this->cacheIdentifierGeneratorMock ->expects($matcher) ->method('generateKey') - ->willReturnCallback(static function (...$parameters) use ($matcher, $keyGeneratingArguments, $key) { + ->willReturnCallback(static function (...$parameters) use ($matcher, $keyGeneratingArguments, $key): mixed { self::assertEquals($keyGeneratingArguments[$matcher->numberOfInvocations() - 1], $parameters); return $key[$matcher->numberOfInvocations() - 1]; @@ -157,7 +157,7 @@ final public function testLoadMethodsCacheHit( $this->cacheIdentifierGeneratorMock ->expects($matcher) ->method('generateTag') - ->willReturnCallback(static function (...$parameters) use ($matcher, $tagGeneratingArguments, $tagGeneratingResults) { + ->willReturnCallback(static function (...$parameters) use ($matcher, $tagGeneratingArguments, $tagGeneratingResults): mixed { self::assertEquals($tagGeneratingArguments[$matcher->numberOfInvocations() - 1], $parameters); return $tagGeneratingResults[$matcher->numberOfInvocations() - 1]; @@ -169,7 +169,7 @@ final public function testLoadMethodsCacheHit( $this->cacheIdentifierGeneratorMock ->expects($matcher) ->method('generateKey') - ->willReturnCallback(static function (...$parameters) use ($matcher, $keyGeneratingArguments, $keyGeneratingResults) { + ->willReturnCallback(static function (...$parameters) use ($matcher, $keyGeneratingArguments, $keyGeneratingResults): mixed { self::assertEquals($keyGeneratingArguments[$matcher->numberOfInvocations() - 1], $parameters); return $keyGeneratingResults[$matcher->numberOfInvocations() - 1]; @@ -245,7 +245,7 @@ final public function testLoadMethodsCacheMiss( $this->cacheIdentifierGeneratorMock ->expects($matcher) ->method('generateTag') - ->willReturnCallback(static function (...$parameters) use ($matcher, $tagGeneratingArguments, $tagGeneratingResults) { + ->willReturnCallback(static function (...$parameters) use ($matcher, $tagGeneratingArguments, $tagGeneratingResults): mixed { self::assertEquals($tagGeneratingArguments[$matcher->numberOfInvocations() - 1], $parameters); return $tagGeneratingResults[$matcher->numberOfInvocations() - 1]; @@ -257,7 +257,7 @@ final public function testLoadMethodsCacheMiss( $this->cacheIdentifierGeneratorMock ->expects($matcher) ->method('generateKey') - ->willReturnCallback(static function (...$parameters) use ($matcher, $keyGeneratingArguments, $keyGeneratingResults) { + ->willReturnCallback(static function (...$parameters) use ($matcher, $keyGeneratingArguments, $keyGeneratingResults): mixed { self::assertEquals($keyGeneratingArguments[$matcher->numberOfInvocations() - 1], $parameters); return $keyGeneratingResults[$matcher->numberOfInvocations() - 1]; diff --git a/tests/lib/Persistence/Cache/Adapter/InMemoryClearingProxyAdapterTest.php b/tests/lib/Persistence/Cache/Adapter/InMemoryClearingProxyAdapterTest.php index a33cd7c141..3ac89322e8 100644 --- a/tests/lib/Persistence/Cache/Adapter/InMemoryClearingProxyAdapterTest.php +++ b/tests/lib/Persistence/Cache/Adapter/InMemoryClearingProxyAdapterTest.php @@ -48,7 +48,7 @@ protected function setUp(): void ); $this->cacheItemsClosure = \Closure::bind( - static function ($key, $value, $isHit, $defaultLifetime = 0, $tags = []) { + static function ($key, $value, $isHit, $defaultLifetime = 0, $tags = []): CacheItem { $item = new CacheItem(); $item->isTaggable = true; $item->key = $key; diff --git a/tests/lib/Persistence/Cache/ContentHandlerTest.php b/tests/lib/Persistence/Cache/ContentHandlerTest.php index de7b495f39..b76966bc05 100644 --- a/tests/lib/Persistence/Cache/ContentHandlerTest.php +++ b/tests/lib/Persistence/Cache/ContentHandlerTest.php @@ -469,7 +469,7 @@ public function testDeleteContent(): void $this->cacheIdentifierGeneratorMock ->expects($matcher) - ->method('generateTag')->willReturnCallback(static function (...$parameters) use ($matcher) { + ->method('generateTag')->willReturnCallback(static function (...$parameters) use ($matcher): ?string { if ($matcher->numberOfInvocations() === 1) { self::assertSame('content', $parameters[0]); self::assertSame([42], $parameters[1]); @@ -484,6 +484,8 @@ public function testDeleteContent(): void return 'c-2'; } + + return null; }); $this->cacheMock diff --git a/tests/lib/Persistence/Cache/ContentTypeHandlerTest.php b/tests/lib/Persistence/Cache/ContentTypeHandlerTest.php index e286168b5a..b5950db2f2 100644 --- a/tests/lib/Persistence/Cache/ContentTypeHandlerTest.php +++ b/tests/lib/Persistence/Cache/ContentTypeHandlerTest.php @@ -429,7 +429,7 @@ public function testPublish(): void $this->cacheIdentifierGeneratorMock ->expects($matcher) - ->method('generateTag')->willReturnCallback(static function (...$parameters) use ($matcher) { + ->method('generateTag')->willReturnCallback(static function (...$parameters) use ($matcher): ?string { if ($matcher->numberOfInvocations() === 1) { self::assertSame('type', $parameters[0]); self::assertSame([5], $parameters[1]); @@ -451,12 +451,14 @@ public function testPublish(): void return 'cft-5'; } + + return null; }); $matcher = self::exactly(3); $this->cacheIdentifierGeneratorMock ->expects($matcher) - ->method('generateKey')->willReturnCallback(static function (...$parameters) use ($matcher) { + ->method('generateKey')->willReturnCallback(static function (...$parameters) use ($matcher): ?string { if ($matcher->numberOfInvocations() === 1) { self::assertSame('content_type', $parameters[0]); self::assertSame([], $parameters[1]); @@ -478,6 +480,8 @@ public function testPublish(): void return 'ibx-ctlbg-4'; } + + return null; }); $this->cacheMock diff --git a/tests/lib/Persistence/Cache/InMemory/InMemoryCacheTest.php b/tests/lib/Persistence/Cache/InMemory/InMemoryCacheTest.php index 4ae79bdc3d..9353040ec0 100644 --- a/tests/lib/Persistence/Cache/InMemory/InMemoryCacheTest.php +++ b/tests/lib/Persistence/Cache/InMemory/InMemoryCacheTest.php @@ -49,7 +49,7 @@ public function testGetByKey(): void self::assertNull($this->cache->get('first')); $obj = new \stdClass(); - $this->cache->setMulti([$obj], static function ($o) { return ['first']; }); + $this->cache->setMulti([$obj], static function ($o): array { return ['first']; }); self::assertSame($obj, $this->cache->get('first')); @@ -64,7 +64,7 @@ public function testGetBySecondaryIndex(): void self::assertNull($this->cache->get('secondary')); $obj = new \stdClass(); - $this->cache->setMulti([$obj], static function ($o) { return ['first', 'secondary']; }); + $this->cache->setMulti([$obj], static function ($o): array { return ['first', 'secondary']; }); self::assertSame($obj, $this->cache->get('first')); self::assertSame($obj, $this->cache->get('secondary')); @@ -81,7 +81,7 @@ public function testGetByList(): void self::assertNull($this->cache->get('list')); $obj = new \stdClass(); - $this->cache->setMulti([$obj], static function ($o) { return ['first']; }, 'list'); + $this->cache->setMulti([$obj], static function ($o): array { return ['first']; }, 'list'); self::assertSame($obj, $this->cache->get('first')); self::assertSame([$obj], $this->cache->get('list')); @@ -95,7 +95,7 @@ public function testGetByList(): void public function testDeleted(): void { $obj = new \stdClass(); - $this->cache->setMulti([$obj], static function ($o) { return ['first', 'second']; }, 'list'); + $this->cache->setMulti([$obj], static function ($o): array { return ['first', 'second']; }, 'list'); self::assertSame($obj, $this->cache->get('first')); self::assertSame($obj, $this->cache->get('second')); @@ -117,7 +117,7 @@ public function testDeleted(): void public function testClear(): void { $obj = new \stdClass(); - $this->cache->setMulti([$obj], static function ($o) { return ['first', 'second']; }, 'list'); + $this->cache->setMulti([$obj], static function ($o): array { return ['first', 'second']; }, 'list'); self::assertSame($obj, $this->cache->get('first')); self::assertSame($obj, $this->cache->get('second')); @@ -134,7 +134,7 @@ public function testClear(): void public function testSetWhenReachingSetLimit(): void { $obj = new \stdClass(); - $this->cache->setMulti([$obj, $obj], static function ($o) { return ['first', 'second']; }, 'list'); + $this->cache->setMulti([$obj, $obj], static function ($o): array { return ['first', 'second']; }, 'list'); self::assertNull($this->cache->get('first')); self::assertNull($this->cache->get('second')); @@ -144,14 +144,14 @@ public function testSetWhenReachingSetLimit(): void public function testSetWhenReachingTotalLimit(): void { $obj = new \stdClass(); - $this->cache->setMulti([$obj], static function ($o) { return ['first']; }); - $this->cache->setMulti([$obj], static function ($o) { return ['second']; }); - $this->cache->setMulti([$obj], static function ($o) { return ['third']; }); - $this->cache->setMulti([$obj], static function ($o) { return ['fourth']; }); - $this->cache->setMulti([$obj], static function ($o) { return ['fifth']; }); - $this->cache->setMulti([$obj], static function ($o) { return ['sixth']; }); - $this->cache->setMulti([$obj], static function ($o) { return ['seventh']; }); - $this->cache->setMulti([$obj], static function ($o) { return ['eight']; }); + $this->cache->setMulti([$obj], static function ($o): array { return ['first']; }); + $this->cache->setMulti([$obj], static function ($o): array { return ['second']; }); + $this->cache->setMulti([$obj], static function ($o): array { return ['third']; }); + $this->cache->setMulti([$obj], static function ($o): array { return ['fourth']; }); + $this->cache->setMulti([$obj], static function ($o): array { return ['fifth']; }); + $this->cache->setMulti([$obj], static function ($o): array { return ['sixth']; }); + $this->cache->setMulti([$obj], static function ($o): array { return ['seventh']; }); + $this->cache->setMulti([$obj], static function ($o): array { return ['eight']; }); self::assertNull($this->cache->get('first')); self::assertNull($this->cache->get('second')); @@ -169,19 +169,19 @@ public function testSetWhenReachingTotalLimit(): void public function testAccessCountsWhenReachingTotalLimit(): void { $obj = new \stdClass(); - $this->cache->setMulti([$obj], static function ($o) { return ['first']; }); - $this->cache->setMulti([$obj], static function ($o) { return ['second']; }); - $this->cache->setMulti([$obj], static function ($o) { return ['third']; }); - $this->cache->setMulti([$obj], static function ($o) { return ['fourth']; }); + $this->cache->setMulti([$obj], static function ($o): array { return ['first']; }); + $this->cache->setMulti([$obj], static function ($o): array { return ['second']; }); + $this->cache->setMulti([$obj], static function ($o): array { return ['third']; }); + $this->cache->setMulti([$obj], static function ($o): array { return ['fourth']; }); // Make sure these are read before we set further objects. $this->cache->get('first'); $this->cache->get('third'); - $this->cache->setMulti([$obj], static function ($o) { return ['fifth']; }); - $this->cache->setMulti([$obj], static function ($o) { return ['sixth']; }); - $this->cache->setMulti([$obj], static function ($o) { return ['seventh']; }); - $this->cache->setMulti([$obj], static function ($o) { return ['eight']; }); + $this->cache->setMulti([$obj], static function ($o): array { return ['fifth']; }); + $this->cache->setMulti([$obj], static function ($o): array { return ['sixth']; }); + $this->cache->setMulti([$obj], static function ($o): array { return ['seventh']; }); + $this->cache->setMulti([$obj], static function ($o): array { return ['eight']; }); self::assertSame($obj, $this->cache->get('first')); self::assertNull($this->cache->get('second')); diff --git a/tests/lib/Persistence/Cache/TrashHandlerTest.php b/tests/lib/Persistence/Cache/TrashHandlerTest.php index 4fb289f13b..e4ea943c83 100644 --- a/tests/lib/Persistence/Cache/TrashHandlerTest.php +++ b/tests/lib/Persistence/Cache/TrashHandlerTest.php @@ -145,7 +145,7 @@ private function setUpRoleAssignmentInvalidation(int $locationId, int $contentId $this->cacheIdentifierGeneratorMock ->expects($matcher) - ->method('generateTag')->willReturnCallback(static function (...$parameters) use ($matcher, $roleId, $contentId, $locationId) { + ->method('generateTag')->willReturnCallback(static function (...$parameters) use ($matcher, $roleId, $contentId, $locationId): ?string { if ($matcher->numberOfInvocations() === 1) { self::assertSame('role_assignment_role_list', $parameters[0]); self::assertSame([$roleId], $parameters[1]); @@ -167,6 +167,8 @@ private function setUpRoleAssignmentInvalidation(int $locationId, int $contentId return 'lp-' . $locationId; } + + return null; }); $this->cacheMock @@ -225,7 +227,7 @@ public function testDeleteTrashItem(): void $this->cacheIdentifierGeneratorMock ->expects($matcher) - ->method('generateTag')->willReturnCallback(static function (...$parameters) use ($matcher, $relationSourceContentId, $contentId, $trashedId) { + ->method('generateTag')->willReturnCallback(static function (...$parameters) use ($matcher, $relationSourceContentId, $contentId, $trashedId): ?string { if ($matcher->numberOfInvocations() === 1) { self::assertSame('content', $parameters[0]); self::assertSame([$relationSourceContentId], $parameters[1]); @@ -247,6 +249,8 @@ public function testDeleteTrashItem(): void return 'lp-' . $trashedId; } + + return null; }); $this->cacheMock @@ -311,7 +315,7 @@ public function testEmptyTrash(): void $this->cacheIdentifierGeneratorMock ->expects($matcher) ->method('generateTag') - ->willReturnCallback(static function (...$parameters) use ($matcher, $cacheIdentifierGeneratorArguments, $tags) { + ->willReturnCallback(static function (...$parameters) use ($matcher, $cacheIdentifierGeneratorArguments, $tags): string { self::assertSame(array_merge($cacheIdentifierGeneratorArguments, $cacheIdentifierGeneratorArguments)[$matcher->numberOfInvocations() - 1], $parameters); return array_merge($tags, $tags)[$matcher->numberOfInvocations() - 1]; diff --git a/tests/lib/Persistence/Cache/URLHandlerTest.php b/tests/lib/Persistence/Cache/URLHandlerTest.php index 5280025f85..21a66534fb 100644 --- a/tests/lib/Persistence/Cache/URLHandlerTest.php +++ b/tests/lib/Persistence/Cache/URLHandlerTest.php @@ -95,7 +95,7 @@ public function testUpdateUrlWhenAddressIsUpdated(): void $this->cacheIdentifierGeneratorMock ->expects($matcher) - ->method('generateTag')->willReturnCallback(static function (...$parameters) use ($matcher) { + ->method('generateTag')->willReturnCallback(static function (...$parameters) use ($matcher): ?string { if ($matcher->numberOfInvocations() === 1) { self::assertSame('url', $parameters[0]); self::assertSame([1], $parameters[1]); @@ -124,6 +124,8 @@ public function testUpdateUrlWhenAddressIsUpdated(): void return 'c-5'; } + + return null; }); $invalidateTagsMatcher = self::exactly(2); diff --git a/tests/lib/Persistence/Cache/UserHandlerTest.php b/tests/lib/Persistence/Cache/UserHandlerTest.php index 64ae71b155..39768c0ff9 100644 --- a/tests/lib/Persistence/Cache/UserHandlerTest.php +++ b/tests/lib/Persistence/Cache/UserHandlerTest.php @@ -574,7 +574,7 @@ public function testAssignRole(): void $this->cacheIdentifierGeneratorMock ->expects($matcher) - ->method('generateTag')->willReturnCallback(static function (...$parameters) use ($matcher, $tags) { + ->method('generateTag')->willReturnCallback(static function (...$parameters) use ($matcher, $tags): string { if ($matcher->numberOfInvocations() === 1) { self::assertSame('role_assignment_group_list', $parameters[0]); self::assertSame([14], $parameters[1]); @@ -643,7 +643,7 @@ public function testRemoveRoleAssignment(): void $matcher = self::exactly(count($tags)); $this->cacheIdentifierGeneratorMock ->expects($matcher) - ->method('generateTag')->willReturnCallback(static function (...$parameters) use ($matcher, $tags) { + ->method('generateTag')->willReturnCallback(static function (...$parameters) use ($matcher, $tags): string { if ($matcher->numberOfInvocations() === 1) { self::assertSame('role_assignment', $parameters[0]); diff --git a/tests/lib/Persistence/Legacy/Bookmark/Gateway/DoctrineDatabaseTest.php b/tests/lib/Persistence/Legacy/Bookmark/Gateway/DoctrineDatabaseTest.php index b7fb496b5b..d3b672db63 100644 --- a/tests/lib/Persistence/Legacy/Bookmark/Gateway/DoctrineDatabaseTest.php +++ b/tests/lib/Persistence/Legacy/Bookmark/Gateway/DoctrineDatabaseTest.php @@ -91,7 +91,7 @@ public static function dataProviderForLoadUserBookmarks(): array { $fixtures = (require __DIR__ . '/../_fixtures/bookmarks.php')[DoctrineDatabase::TABLE_BOOKMARKS]; - $expectedRows = static function ($userId) use ($fixtures) { + $expectedRows = static function ($userId) use ($fixtures): array { $rows = array_filter($fixtures, static function (array $row) use ($userId): bool { return $row['user_id'] == $userId; }); diff --git a/tests/lib/Persistence/Legacy/Content/ContentHandlerTest.php b/tests/lib/Persistence/Legacy/Content/ContentHandlerTest.php index 9bc5047b34..90b9a2502f 100644 --- a/tests/lib/Persistence/Legacy/Content/ContentHandlerTest.php +++ b/tests/lib/Persistence/Legacy/Content/ContentHandlerTest.php @@ -682,7 +682,7 @@ public function testUpdateContent(): void $handler->expects($loadMatcher) ->method('load') ->with(14, 4) - ->willReturnCallback(static function () use ($loadMatcher, $contentStub) { + ->willReturnCallback(static function () use ($loadMatcher, $contentStub): ?Content { if ($loadMatcher->numberOfInvocations() === 1) { return $contentStub; } @@ -1343,7 +1343,7 @@ public function testCopyAllVersions(): void $copyLoadMatcher = self::exactly(2); $handler->expects($copyLoadMatcher) ->method('load') - ->willReturnCallback(static function ($contentId, $versionNo) use ($copyLoadMatcher, $versionInfo) { + ->willReturnCallback(static function ($contentId, $versionNo) use ($copyLoadMatcher, $versionInfo): \Ibexa\Contracts\Core\Persistence\Content { self::assertSame(23, $contentId); if ($copyLoadMatcher->numberOfInvocations() === 1) { self::assertSame(2, $versionNo); diff --git a/tests/lib/Persistence/Legacy/Content/FieldHandlerTest.php b/tests/lib/Persistence/Legacy/Content/FieldHandlerTest.php index 876c70b436..6fc961f015 100644 --- a/tests/lib/Persistence/Legacy/Content/FieldHandlerTest.php +++ b/tests/lib/Persistence/Legacy/Content/FieldHandlerTest.php @@ -111,7 +111,7 @@ protected function assertCreateNewFields($storageHandlerUpdatesFields = false) $invocationOrder = 0; $storageHandlerMock->expects(self::exactly(5)) ->method('storeFieldData') - ->willReturnCallback(static function (...$parameters) use (&$invocationOrder, $expectedStoreFields, $storageHandlerUpdatesFields) { + ->willReturnCallback(static function (...$parameters) use (&$invocationOrder, $expectedStoreFields, $storageHandlerUpdatesFields): bool { self::assertInstanceOf(VersionInfo::class, $parameters[0]); self::assertEquals($expectedStoreFields[$invocationOrder], $parameters[1]); ++$invocationOrder; @@ -123,7 +123,7 @@ protected function assertCreateNewFields($storageHandlerUpdatesFields = false) /* @var $originalField */ $storageHandlerMock->expects(self::once()) ->method('copyFieldData') - ->willReturnCallback(static function (...$parameters) use (&$invocationOrder, $copyField, $originalField, $storageHandlerUpdatesFields) { + ->willReturnCallback(static function (...$parameters) use (&$invocationOrder, $copyField, $originalField, $storageHandlerUpdatesFields): bool { self::assertSame(5, $invocationOrder); self::assertInstanceOf(VersionInfo::class, $parameters[0]); self::assertEquals($copyField, $parameters[1]); @@ -217,7 +217,7 @@ protected function assertCreateNewFieldsForMainLanguage($storageHandlerUpdatesFi $matcher = self::exactly(3); $storageHandlerMock->expects($matcher) ->method('storeFieldData') - ->willReturnCallback(static function (...$parameters) use ($matcher, $expectedFields, $storageHandlerUpdatesFields) { + ->willReturnCallback(static function (...$parameters) use ($matcher, $expectedFields, $storageHandlerUpdatesFields): bool { self::assertInstanceOf(VersionInfo::class, $parameters[0]); self::assertEquals($expectedFields[$matcher->numberOfInvocations() - 1], $parameters[1]); @@ -307,7 +307,7 @@ protected function assertCreateExistingFieldsInNewVersion($storageHandlerUpdates $matcher = self::exactly(6); $storageHandlerMock->expects($matcher) ->method('copyFieldData') - ->willReturnCallback(static function (...$parameters) use ($matcher, $expectedCopyCalls, $storageHandlerUpdatesFields) { + ->willReturnCallback(static function (...$parameters) use ($matcher, $expectedCopyCalls, $storageHandlerUpdatesFields): bool { $index = $matcher->numberOfInvocations() - 1; self::assertInstanceOf(VersionInfo::class, $parameters[0]); self::assertEquals($expectedCopyCalls[$index]['field'], $parameters[1]); @@ -516,7 +516,7 @@ public function assertUpdateFieldsWithNewLanguage($storageHandlerUpdatesFields = $invocationOrder = 0; $storageHandlerMock->expects(self::exactly(2)) ->method('storeFieldData') - ->willReturnCallback(static function (...$parameters) use (&$invocationOrder, $expectedStoreFields, $storageHandlerUpdatesFields) { + ->willReturnCallback(static function (...$parameters) use (&$invocationOrder, $expectedStoreFields, $storageHandlerUpdatesFields): bool { self::assertInstanceOf(VersionInfo::class, $parameters[0]); self::assertEquals($expectedStoreFields[$invocationOrder], $parameters[1]); ++$invocationOrder; @@ -528,7 +528,7 @@ public function assertUpdateFieldsWithNewLanguage($storageHandlerUpdatesFields = /* @var $originalField */ $storageHandlerMock->expects(self::once()) ->method('copyFieldData') - ->willReturnCallback(static function (...$parameters) use (&$invocationOrder, $copyField, $originalField, $storageHandlerUpdatesFields) { + ->willReturnCallback(static function (...$parameters) use (&$invocationOrder, $copyField, $originalField, $storageHandlerUpdatesFields): bool { self::assertSame(2, $invocationOrder); self::assertInstanceOf(VersionInfo::class, $parameters[0]); self::assertEquals($copyField, $parameters[1]); @@ -652,7 +652,7 @@ public function assertUpdateFieldsExistingLanguages($storageHandlerUpdatesFields $storeCount = count($expectedStoreFields); $storageHandlerMock->expects(self::exactly($storeCount)) ->method('storeFieldData') - ->willReturnCallback(static function (...$parameters) use (&$invocationOrder, $expectedStoreFields, $storageHandlerUpdatesFields) { + ->willReturnCallback(static function (...$parameters) use (&$invocationOrder, $expectedStoreFields, $storageHandlerUpdatesFields): bool { self::assertInstanceOf(VersionInfo::class, $parameters[0]); self::assertEquals($expectedStoreFields[$invocationOrder], $parameters[1]); ++$invocationOrder; @@ -662,7 +662,7 @@ public function assertUpdateFieldsExistingLanguages($storageHandlerUpdatesFields $storageHandlerMock->expects(self::exactly(count($fieldsToCopy))) ->method('copyFieldData') - ->willReturnCallback(static function (...$parameters) use (&$invocationOrder, $fieldsToCopy, $storeCount, $storageHandlerUpdatesFields) { + ->willReturnCallback(static function (...$parameters) use (&$invocationOrder, $fieldsToCopy, $storeCount, $storageHandlerUpdatesFields): bool { $index = $invocationOrder - $storeCount; self::assertInstanceOf(VersionInfo::class, $parameters[0]); self::assertEquals($fieldsToCopy[$index]['copy'], $parameters[1]); @@ -767,7 +767,7 @@ public function assertUpdateFieldsForInitialLanguage($storageHandlerUpdatesField $storeCount = count($expectedStoreFields); $storageHandlerMock->expects(self::exactly($storeCount)) ->method('storeFieldData') - ->willReturnCallback(static function (...$parameters) use (&$invocationOrder, $expectedStoreFields, $storageHandlerUpdatesFields) { + ->willReturnCallback(static function (...$parameters) use (&$invocationOrder, $expectedStoreFields, $storageHandlerUpdatesFields): bool { self::assertInstanceOf(VersionInfo::class, $parameters[0]); self::assertEquals($expectedStoreFields[$invocationOrder], $parameters[1]); ++$invocationOrder; @@ -777,7 +777,7 @@ public function assertUpdateFieldsForInitialLanguage($storageHandlerUpdatesField $storageHandlerMock->expects(self::exactly(count($fieldsToCopy))) ->method('copyFieldData') - ->willReturnCallback(static function (...$parameters) use (&$invocationOrder, $fieldsToCopy, $storeCount, $storageHandlerUpdatesFields) { + ->willReturnCallback(static function (...$parameters) use (&$invocationOrder, $fieldsToCopy, $storeCount, $storageHandlerUpdatesFields): bool { $index = $invocationOrder - $storeCount; self::assertInstanceOf(VersionInfo::class, $parameters[0]); self::assertEquals($fieldsToCopy[$index]['copy'], $parameters[1]); diff --git a/tests/lib/Persistence/Legacy/Content/Language/CachingLanguageHandlerTest.php b/tests/lib/Persistence/Legacy/Content/Language/CachingLanguageHandlerTest.php index 620bff8e3a..d6b608a0f9 100644 --- a/tests/lib/Persistence/Legacy/Content/Language/CachingLanguageHandlerTest.php +++ b/tests/lib/Persistence/Legacy/Content/Language/CachingLanguageHandlerTest.php @@ -256,7 +256,7 @@ public function testDelete(): void $matcher = self::exactly(2); $cacheIdentifierGeneratorMock->expects($matcher) - ->method('generateKey')->willReturnCallback(static function (...$parameters) use ($matcher) { + ->method('generateKey')->willReturnCallback(static function (...$parameters) use ($matcher): ?string { if ($matcher->numberOfInvocations() === 1) { self::assertSame('language', $parameters[0]); self::assertSame([2], $parameters[1]); @@ -271,6 +271,8 @@ public function testDelete(): void return 'ibx-lal'; } + + return null; }); $innerHandlerMock->expects(self::once()) diff --git a/tests/lib/Persistence/Legacy/Content/Language/MaskGeneratorTest.php b/tests/lib/Persistence/Legacy/Content/Language/MaskGeneratorTest.php index 1d103d80a0..8c983d7817 100644 --- a/tests/lib/Persistence/Legacy/Content/Language/MaskGeneratorTest.php +++ b/tests/lib/Persistence/Legacy/Content/Language/MaskGeneratorTest.php @@ -255,7 +255,7 @@ protected function getLanguageHandler() ->method(self::anything())// loadByLanguageCode && loadListByLanguageCodes ->will( self::returnCallback( - static function ($languageCodes) { + static function ($languageCodes): Language|array { if (is_string($languageCodes)) { $language = $languageCodes; $languageCodes = [$language]; diff --git a/tests/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabaseTrashTest.php b/tests/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabaseTrashTest.php index 22f8d50839..18f0a6d3f6 100644 --- a/tests/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabaseTrashTest.php +++ b/tests/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabaseTrashTest.php @@ -324,7 +324,7 @@ public function testListTrashSortedPathStringDesc(): void '/1/2/69/', ], array_map( - static function ($trashItem) { + static function ($trashItem): mixed { return $trashItem['path_string']; }, $trashList = $handler->listTrashed( @@ -356,7 +356,7 @@ public function testListTrashSortedDepth(): void '/1/2/69/70/71/', ], array_map( - static function ($trashItem) { + static function ($trashItem): mixed { return $trashItem['path_string']; }, $trashList = $handler->listTrashed( diff --git a/tests/lib/Persistence/Legacy/Content/Location/TrashHandlerTest.php b/tests/lib/Persistence/Legacy/Content/Location/TrashHandlerTest.php index 130fa96d08..99c21dceba 100644 --- a/tests/lib/Persistence/Legacy/Content/Location/TrashHandlerTest.php +++ b/tests/lib/Persistence/Legacy/Content/Location/TrashHandlerTest.php @@ -88,7 +88,7 @@ public function testTrashSubtree(): void $this->locationGateway ->expects($countLocationsByContentIdMatcher) ->method('countLocationsByContentId') - ->willReturnCallback(static function ($contentId) use ($countLocationsByContentIdMatcher) { + ->willReturnCallback(static function ($contentId) use ($countLocationsByContentIdMatcher): int { if ($countLocationsByContentIdMatcher->numberOfInvocations() === 1) { self::assertSame(10, $contentId); @@ -158,7 +158,7 @@ public function testTrashSubtreeReturnsNull(): void $this->locationGateway ->expects($countLocationsByContentIdMatcher) ->method('countLocationsByContentId') - ->willReturnCallback(static function ($contentId) use ($countLocationsByContentIdMatcher) { + ->willReturnCallback(static function ($contentId) use ($countLocationsByContentIdMatcher): int { if ($countLocationsByContentIdMatcher->numberOfInvocations() === 1) { self::assertSame(10, $contentId); @@ -215,7 +215,7 @@ public function testTrashSubtreeUpdatesMainLocation(): void $this->locationGateway ->expects($countLocationsByContentIdMatcher) ->method('countLocationsByContentId') - ->willReturnCallback(static function ($contentId) use ($countLocationsByContentIdMatcher) { + ->willReturnCallback(static function ($contentId) use ($countLocationsByContentIdMatcher): int { if ($countLocationsByContentIdMatcher->numberOfInvocations() === 1) { self::assertSame(10, $contentId); @@ -375,7 +375,7 @@ public function testEmptyTrash(): void $this->locationGateway ->expects($countLocationsByContentIdMatcher) ->method('countLocationsByContentId') - ->willReturnCallback(static function ($contentId) use ($countLocationsByContentIdMatcher, $expectedTrashed) { + ->willReturnCallback(static function ($contentId) use ($countLocationsByContentIdMatcher, $expectedTrashed): int { $trashedElement = $expectedTrashed[$countLocationsByContentIdMatcher->numberOfInvocations() - 1]; self::assertSame($trashedElement['contentobject_id'], $contentId); diff --git a/tests/lib/Persistence/Legacy/Content/LocationHandlerTest.php b/tests/lib/Persistence/Legacy/Content/LocationHandlerTest.php index b6e083dbe0..c9b0deaa1e 100644 --- a/tests/lib/Persistence/Legacy/Content/LocationHandlerTest.php +++ b/tests/lib/Persistence/Legacy/Content/LocationHandlerTest.php @@ -211,7 +211,7 @@ public function testMoveSubtree(): void $this->locationGateway ->expects($getBasicNodeDataMatcher) ->method('getBasicNodeData') - ->willReturnCallback(static function (int $nodeId) use ($getBasicNodeDataMatcher, $sourceData, $destinationData) { + ->willReturnCallback(static function (int $nodeId) use ($getBasicNodeDataMatcher, $sourceData, $destinationData): array { $expectedArgs = [$sourceData['node_id'], $destinationData['node_id']]; $returnValues = [$sourceData, $destinationData]; $index = $getBasicNodeDataMatcher->numberOfInvocations() - 1; @@ -234,7 +234,7 @@ public function testMoveSubtree(): void $this->treeHandler ->expects($loadLocationMatcher) ->method('loadLocation') - ->willReturnCallback(static function (int $nodeId) use ($loadLocationMatcher, $sourceData, $destinationData) { + ->willReturnCallback(static function (int $nodeId) use ($loadLocationMatcher, $sourceData, $destinationData): \Ibexa\Contracts\Core\Persistence\Content\Location { $expectedArgs = [$sourceData['node_id'], $destinationData['node_id']]; $returnValues = [ new Location([ @@ -253,7 +253,7 @@ public function testMoveSubtree(): void $this->contentHandler ->expects($loadContentInfoMatcher) ->method('loadContentInfo') - ->willReturnCallback(static function (int $contentId) use ($loadContentInfoMatcher, $sourceData, $destinationData) { + ->willReturnCallback(static function (int $contentId) use ($loadContentInfoMatcher, $sourceData, $destinationData): \Ibexa\Contracts\Core\Persistence\Content\ContentInfo { $expectedArgs = [$destinationData['contentobject_id'], $sourceData['contentobject_id']]; $returnValues = [ new ContentInfo(['sectionId' => 12345]), @@ -506,7 +506,7 @@ public function testCopySubtree(): void $this->objectStateHandler ->expects(self::once()) ->method('loadAllGroups') - ->willReturnCallback(static function () use (&$objectStateHandlerInvocationOrder) { + ->willReturnCallback(static function () use (&$objectStateHandlerInvocationOrder): array { self::assertSame(0, $objectStateHandlerInvocationOrder++); return [ @@ -518,7 +518,7 @@ public function testCopySubtree(): void $this->objectStateHandler ->expects(self::exactly(2)) ->method('loadObjectStates') - ->willReturnCallback(static function (int $groupId) use (&$objectStateHandlerInvocationOrder) { + ->willReturnCallback(static function (int $groupId) use (&$objectStateHandlerInvocationOrder): array { $order = $objectStateHandlerInvocationOrder++; switch ($order) { case 1: @@ -543,7 +543,7 @@ public function testCopySubtree(): void $this->objectStateHandler ->expects(self::exactly(count($setContentStateExpectedArgs))) ->method('setContentState') - ->willReturnCallback(static function (int $contentId, int $groupId, int $stateId) use (&$objectStateHandlerInvocationOrder, $setContentStateExpectedArgs) { + ->willReturnCallback(static function (int $contentId, int $groupId, int $stateId) use (&$objectStateHandlerInvocationOrder, $setContentStateExpectedArgs): bool { $order = $objectStateHandlerInvocationOrder++; $index = $order - 3; self::assertArrayHasKey($index, $setContentStateExpectedArgs); @@ -596,7 +596,7 @@ public function testCopySubtree(): void $this->contentHandler ->expects(self::exactly(count($contentIds))) ->method('copy') - ->willReturnCallback(static function (int $contentId, int $versionNo) use (&$contentHandlerInvocationOrder, $copyExpectedArgs, $copyReturnValues) { + ->willReturnCallback(static function (int $contentId, int $versionNo) use (&$contentHandlerInvocationOrder, $copyExpectedArgs, $copyReturnValues): Content { $order = $contentHandlerInvocationOrder++; self::assertSame(0, $order % 2, sprintf('Expected copy() at an even invocation order, got %d', $order)); $index = intdiv($order, 2); @@ -608,7 +608,7 @@ public function testCopySubtree(): void $this->contentHandler ->expects(self::exactly(count($contentIds))) ->method('publish') - ->willReturnCallback(static function (int $contentId, int $versionNo, Content\MetadataUpdateStruct $metadataUpdateStruct) use (&$contentHandlerInvocationOrder, $publishExpectedArgs, $publishReturnValues) { + ->willReturnCallback(static function (int $contentId, int $versionNo, Content\MetadataUpdateStruct $metadataUpdateStruct) use (&$contentHandlerInvocationOrder, $publishExpectedArgs, $publishReturnValues): Content { $order = $contentHandlerInvocationOrder++; self::assertSame(1, $order % 2, sprintf('Expected publish() at an odd invocation order, got %d', $order)); $index = intdiv($order, 2); @@ -646,7 +646,7 @@ public function testCopySubtree(): void $this->locationMapper ->expects($getLocationCreateStructMatcher) ->method('getLocationCreateStruct') - ->willReturnCallback(static function (array $row) use ($getLocationCreateStructMatcher, $subtreeContentRows, $locationCreateStructReturnValues) { + ->willReturnCallback(static function (array $row) use ($getLocationCreateStructMatcher, $subtreeContentRows, $locationCreateStructReturnValues): CreateStruct { $index = $getLocationCreateStructMatcher->numberOfInvocations() - 1; self::assertSame($subtreeContentRows[$index], $row); @@ -657,7 +657,7 @@ public function testCopySubtree(): void $handler ->expects($createMatcher) ->method('create') - ->willReturnCallback(static function (CreateStruct $createStruct) use ($createMatcher, $expectedCreateStructArgs, $createReturnValues) { + ->willReturnCallback(static function (CreateStruct $createStruct) use ($createMatcher, $expectedCreateStructArgs, $createReturnValues): Location { $index = $createMatcher->numberOfInvocations() - 1; self::assertEquals($expectedCreateStructArgs[$index], $createStruct); @@ -680,7 +680,7 @@ public function testCopySubtree(): void $this->contentHandler ->expects(self::exactly(2)) ->method('loadContentInfo') - ->willReturnCallback(static function (int $contentId) use (&$contentHandlerInvocationOrder, $contentIds, $destinationData) { + ->willReturnCallback(static function (int $contentId) use (&$contentHandlerInvocationOrder, $contentIds, $destinationData): ContentInfo { $order = $contentHandlerInvocationOrder++; switch ($order) { case count($contentIds) * 2: diff --git a/tests/lib/Persistence/Legacy/Content/Mapper/ResolveVirtualFieldSubscriberTest.php b/tests/lib/Persistence/Legacy/Content/Mapper/ResolveVirtualFieldSubscriberTest.php index 0534b6f3e8..57d24fc55b 100644 --- a/tests/lib/Persistence/Legacy/Content/Mapper/ResolveVirtualFieldSubscriberTest.php +++ b/tests/lib/Persistence/Legacy/Content/Mapper/ResolveVirtualFieldSubscriberTest.php @@ -148,7 +148,7 @@ public function testPersistEmptyExternalStorageField(): void $storage->expects(self::once()) ->method('getFieldData') - ->willReturnCallback(static function (VersionInfo $versionInfo, Field $field) { + ->willReturnCallback(static function (VersionInfo $versionInfo, Field $field): void { $field->value->externalData = [ 'some_default' => 'external_data', ]; @@ -212,7 +212,7 @@ public function testPersistExternalStorageField(): void $storage = $this->createMock(FieldStorage::class); $storage->expects(self::once()) ->method('storeFieldData') - ->willReturnCallback(static function (VersionInfo $versionInfo, Field $field) { + ->willReturnCallback(static function (VersionInfo $versionInfo, Field $field): void { $field->value->externalData = $field->value->data; }); diff --git a/tests/lib/Persistence/Legacy/Content/MapperTest.php b/tests/lib/Persistence/Legacy/Content/MapperTest.php index 51095e6e4b..793d45b273 100644 --- a/tests/lib/Persistence/Legacy/Content/MapperTest.php +++ b/tests/lib/Persistence/Legacy/Content/MapperTest.php @@ -739,7 +739,7 @@ protected function getLanguageHandler(): Language\Handler ->method('load') ->will( self::returnCallback( - static function ($id) use ($languages) { + static function ($id) use ($languages): ?Language { foreach ($languages as $language) { if ($language->id == $id) { return $language; @@ -754,7 +754,7 @@ static function ($id) use ($languages) { ->method('loadByLanguageCode') ->will( self::returnCallback( - static function ($languageCode) use ($languages) { + static function ($languageCode) use ($languages): ?Language { foreach ($languages as $language) { if ($language->languageCode == $languageCode) { return $language; diff --git a/tests/lib/Persistence/Legacy/Content/TreeHandlerTest.php b/tests/lib/Persistence/Legacy/Content/TreeHandlerTest.php index 69acb8a88f..acd350de19 100644 --- a/tests/lib/Persistence/Legacy/Content/TreeHandlerTest.php +++ b/tests/lib/Persistence/Legacy/Content/TreeHandlerTest.php @@ -142,7 +142,7 @@ public function testRemoveSubtree(): void $this->getLocationGatewayMock() ->expects(self::exactly(3)) ->method('getBasicNodeData') - ->willReturnCallback(static function (int $nodeId) use (&$invocationOrder) { + ->willReturnCallback(static function (int $nodeId) use (&$invocationOrder): array { $order = $invocationOrder++; switch ($order) { case 0: @@ -174,7 +174,7 @@ public function testRemoveSubtree(): void $this->getLocationGatewayMock() ->expects(self::exactly(3)) ->method('getChildren') - ->willReturnCallback(static function (int $nodeId) use (&$invocationOrder) { + ->willReturnCallback(static function (int $nodeId) use (&$invocationOrder): array { $order = $invocationOrder++; switch ($order) { case 1: @@ -200,7 +200,7 @@ public function testRemoveSubtree(): void $this->getLocationGatewayMock() ->expects(self::exactly(2)) ->method('countLocationsByContentId') - ->willReturnCallback(static function (int $contentId) use (&$invocationOrder) { + ->willReturnCallback(static function (int $contentId) use (&$invocationOrder): int { $order = $invocationOrder++; switch ($order) { case 4: @@ -224,7 +224,7 @@ public function testRemoveSubtree(): void $this->getLocationGatewayMock() ->expects(self::exactly(3)) ->method('removeLocation') - ->willReturnCallback(static function (int $nodeId) use (&$invocationOrder) { + ->willReturnCallback(static function (int $nodeId) use (&$invocationOrder): void { $order = $invocationOrder++; switch ($order) { case 5: @@ -244,7 +244,7 @@ public function testRemoveSubtree(): void $this->getLocationGatewayMock() ->expects(self::exactly(3)) ->method('deleteNodeAssignment') - ->willReturnCallback(static function (int $contentId) use (&$invocationOrder) { + ->willReturnCallback(static function (int $contentId) use (&$invocationOrder): void { $order = $invocationOrder++; switch ($order) { case 6: @@ -265,7 +265,7 @@ public function testRemoveSubtree(): void ->expects(self::once()) ->method('getFallbackMainNodeData') ->with(102, 202) - ->willReturnCallback(static function () use (&$invocationOrder) { + ->willReturnCallback(static function () use (&$invocationOrder): array { self::assertSame(10, $invocationOrder++); return [ @@ -326,7 +326,7 @@ public function testChangeMainLocation(): void $treeHandler ->expects(self::exactly(2)) ->method('loadLocation') - ->willReturnCallback(static function (int $locationId) use (&$invocationOrder) { + ->willReturnCallback(static function (int $locationId) use (&$invocationOrder): Location { $order = $invocationOrder++; switch ($order) { case 0: @@ -345,7 +345,7 @@ public function testChangeMainLocation(): void $treeHandler ->expects(self::exactly(2)) ->method('loadContentInfo') - ->willReturnCallback(static function ($contentId) use (&$invocationOrder) { + ->willReturnCallback(static function ($contentId) use (&$invocationOrder): ContentInfo { $order = $invocationOrder++; switch ($order) { case 1: @@ -391,7 +391,7 @@ public function testChangeMainLocationToLocationWithoutContentInfo(): void $treeHandler ->expects(self::exactly(2)) ->method('loadLocation') - ->willReturnCallback(static function (int $locationId) use (&$invocationOrder) { + ->willReturnCallback(static function (int $locationId) use (&$invocationOrder): Location { $order = $invocationOrder++; switch ($order) { case 0: @@ -410,7 +410,7 @@ public function testChangeMainLocationToLocationWithoutContentInfo(): void $treeHandler ->expects(self::exactly(2)) ->method('loadContentInfo') - ->willReturnCallback(static function ($contentId) use (&$invocationOrder) { + ->willReturnCallback(static function ($contentId) use (&$invocationOrder): ContentInfo { $order = $invocationOrder++; switch ($order) { case 1: diff --git a/tests/lib/Persistence/Legacy/Content/Type/ContentTypeHandlerTest.php b/tests/lib/Persistence/Legacy/Content/Type/ContentTypeHandlerTest.php index f4cb258a79..cf9eacb25a 100644 --- a/tests/lib/Persistence/Legacy/Content/Type/ContentTypeHandlerTest.php +++ b/tests/lib/Persistence/Legacy/Content/Type/ContentTypeHandlerTest.php @@ -1039,7 +1039,7 @@ public function testPublishNoOldType(): void $matcher = self::exactly(2); $handler->expects($matcher) ->method('load') - ->willReturnCallback(static function (...$parameters) use ($matcher) { + ->willReturnCallback(static function (...$parameters) use ($matcher): \Ibexa\Contracts\Core\Persistence\Content\Type { if ($matcher->numberOfInvocations() === 1) { self::assertSame([23, 1], $parameters); diff --git a/tests/lib/Persistence/Legacy/Content/Type/ContentUpdater/Action/AddFieldTest.php b/tests/lib/Persistence/Legacy/Content/Type/ContentUpdater/Action/AddFieldTest.php index 65e549baa8..2f3b14f310 100644 --- a/tests/lib/Persistence/Legacy/Content/Type/ContentUpdater/Action/AddFieldTest.php +++ b/tests/lib/Persistence/Legacy/Content/Type/ContentUpdater/Action/AddFieldTest.php @@ -145,7 +145,7 @@ public function testApplySingleVersionMultipleTranslations(): void $action ->expects($matcher) ->method('insertField') - ->willReturnCallback(function (...$parameters) use ($matcher, $content) { + ->willReturnCallback(function (...$parameters) use ($matcher, $content): string { if ($matcher->numberOfInvocations() === 1) { self::assertEquals([$content, $this->getFieldReference(null, 1, 'eng-GB')], $parameters); @@ -184,7 +184,7 @@ public function testApplyMultipleVersionsSingleTranslation(): void $this->getContentGatewayMock() ->expects($loadMatcher) ->method('load') - ->willReturnCallback(static function (...$parameters) use ($loadMatcher, $contentId) { + ->willReturnCallback(static function (...$parameters) use ($loadMatcher, $contentId): array { self::assertSame([$contentId, $loadMatcher->numberOfInvocations(), null], $parameters); return []; @@ -194,7 +194,7 @@ public function testApplyMultipleVersionsSingleTranslation(): void $this->getContentMapperMock() ->expects($extractMatcher) ->method('extractContentFromRows') - ->willReturnCallback(static function (...$parameters) use ($extractMatcher, $content1, $content2) { + ->willReturnCallback(static function (...$parameters) use ($extractMatcher, $content1, $content2): array { self::assertSame([[], [], 'content_', null], $parameters); return $extractMatcher->numberOfInvocations() === 1 ? [$content1] : [$content2]; @@ -204,7 +204,7 @@ public function testApplyMultipleVersionsSingleTranslation(): void $action ->expects($insertMatcher) ->method('insertField') - ->willReturnCallback(function (...$parameters) use ($insertMatcher, $content1, $content2) { + ->willReturnCallback(function (...$parameters) use ($insertMatcher, $content1, $content2): string { if ($insertMatcher->numberOfInvocations() === 1) { self::assertEquals([$content1, $this->getFieldReference(null, 1, 'eng-GB')], $parameters); } else { @@ -241,7 +241,7 @@ public function testApplyMultipleVersionsMultipleTranslations(): void $this->getContentGatewayMock() ->expects($loadMatcher) ->method('load') - ->willReturnCallback(static function (...$parameters) use ($loadMatcher, $contentId) { + ->willReturnCallback(static function (...$parameters) use ($loadMatcher, $contentId): array { self::assertSame([$contentId, $loadMatcher->numberOfInvocations(), null], $parameters); return []; @@ -251,7 +251,7 @@ public function testApplyMultipleVersionsMultipleTranslations(): void $this->getContentMapperMock() ->expects($extractMatcher) ->method('extractContentFromRows') - ->willReturnCallback(static function (...$parameters) use ($extractMatcher, $content1, $content2) { + ->willReturnCallback(static function (...$parameters) use ($extractMatcher, $content1, $content2): array { self::assertSame([[], [], 'content_', null], $parameters); return $extractMatcher->numberOfInvocations() === 1 ? [$content1] : [$content2]; @@ -261,7 +261,7 @@ public function testApplyMultipleVersionsMultipleTranslations(): void $action ->expects($insertMatcher) ->method('insertField') - ->willReturnCallback(function (...$parameters) use ($insertMatcher, $content1, $content2) { + ->willReturnCallback(function (...$parameters) use ($insertMatcher, $content1, $content2): string { switch ($insertMatcher->numberOfInvocations()) { case 1: self::assertEquals([$content1, $this->getFieldReference(null, 1, 'eng-GB')], $parameters); diff --git a/tests/lib/Persistence/Legacy/Content/Type/ContentUpdater/Action/RemoveFieldTest.php b/tests/lib/Persistence/Legacy/Content/Type/ContentUpdater/Action/RemoveFieldTest.php index bb2525bdd8..7a6364d010 100644 --- a/tests/lib/Persistence/Legacy/Content/Type/ContentUpdater/Action/RemoveFieldTest.php +++ b/tests/lib/Persistence/Legacy/Content/Type/ContentUpdater/Action/RemoveFieldTest.php @@ -115,7 +115,7 @@ public function testApplyMultipleVersionsSingleTranslation(): void $this->getContentGatewayMock() ->expects($loadMatcher) ->method('load') - ->willReturnCallback(static function (...$parameters) use ($loadMatcher, $contentId) { + ->willReturnCallback(static function (...$parameters) use ($loadMatcher, $contentId): array { self::assertSame([$contentId, $loadMatcher->numberOfInvocations(), null], $parameters); return []; @@ -125,7 +125,7 @@ public function testApplyMultipleVersionsSingleTranslation(): void $this->getContentMapperMock() ->expects($extractMatcher) ->method('extractContentFromRows') - ->willReturnCallback(static function (...$parameters) use ($extractMatcher, $content1, $content2) { + ->willReturnCallback(static function (...$parameters) use ($extractMatcher, $content1, $content2): array { self::assertSame([[], [], 'content_', null], $parameters); return $extractMatcher->numberOfInvocations() === 1 ? [$content1] : [$content2]; @@ -140,7 +140,7 @@ public function testApplyMultipleVersionsSingleTranslation(): void $this->getContentStorageHandlerMock() ->expects($deleteFieldDataMatcher) ->method('deleteFieldData') - ->willReturnCallback(static function (...$parameters) use ($deleteFieldDataMatcher, $content1, $content2, $fieldId) { + ->willReturnCallback(static function (...$parameters) use ($deleteFieldDataMatcher, $content1, $content2, $fieldId): void { $expectedVersionInfo = $deleteFieldDataMatcher->numberOfInvocations() === 1 ? $content1->versionInfo : $content2->versionInfo; @@ -176,7 +176,7 @@ public function testApplyMultipleVersionsMultipleTranslations(): void $this->getContentGatewayMock() ->expects($loadMatcher) ->method('load') - ->willReturnCallback(static function (...$parameters) use ($loadMatcher, $contentId) { + ->willReturnCallback(static function (...$parameters) use ($loadMatcher, $contentId): array { self::assertSame([$contentId, $loadMatcher->numberOfInvocations(), null], $parameters); return []; @@ -186,7 +186,7 @@ public function testApplyMultipleVersionsMultipleTranslations(): void $this->getContentMapperMock() ->expects($extractMatcher) ->method('extractContentFromRows') - ->willReturnCallback(static function (...$parameters) use ($extractMatcher, $content1, $content2) { + ->willReturnCallback(static function (...$parameters) use ($extractMatcher, $content1, $content2): array { self::assertSame([[], [], 'content_', null], $parameters); return $extractMatcher->numberOfInvocations() === 1 ? [$content1] : [$content2]; @@ -196,7 +196,7 @@ public function testApplyMultipleVersionsMultipleTranslations(): void $this->getContentGatewayMock() ->expects($deleteFieldMatcher) ->method('deleteField') - ->willReturnCallback(static function (...$parameters) use ($deleteFieldMatcher, $fieldId1, $fieldId2) { + ->willReturnCallback(static function (...$parameters) use ($deleteFieldMatcher, $fieldId1, $fieldId2): void { $expected = $deleteFieldMatcher->numberOfInvocations() === 1 ? $fieldId1 : $fieldId2; self::assertSame([$expected], $parameters); }); @@ -205,7 +205,7 @@ public function testApplyMultipleVersionsMultipleTranslations(): void $this->getContentStorageHandlerMock() ->expects($deleteFieldDataMatcher) ->method('deleteFieldData') - ->willReturnCallback(static function (...$parameters) use ($deleteFieldDataMatcher, $content1, $content2, $fieldId1, $fieldId2) { + ->willReturnCallback(static function (...$parameters) use ($deleteFieldDataMatcher, $content1, $content2, $fieldId1, $fieldId2): void { $expectedVersionInfo = $deleteFieldDataMatcher->numberOfInvocations() === 1 ? $content1->versionInfo : $content2->versionInfo; diff --git a/tests/lib/Persistence/Legacy/Content/Type/ContentUpdaterTest.php b/tests/lib/Persistence/Legacy/Content/Type/ContentUpdaterTest.php index 892a1a8225..916246a0c1 100644 --- a/tests/lib/Persistence/Legacy/Content/Type/ContentUpdaterTest.php +++ b/tests/lib/Persistence/Legacy/Content/Type/ContentUpdaterTest.php @@ -111,7 +111,7 @@ public function testApplyUpdates(): void $actionAMatcher = self::exactly(2); $actionA->expects($actionAMatcher) ->method('apply') - ->willReturnCallback(static function (...$parameters) use ($actionAMatcher) { + ->willReturnCallback(static function (...$parameters) use ($actionAMatcher): void { self::assertSame([$actionAMatcher->numberOfInvocations() === 1 ? 11 : 22], $parameters); }); $actionB = $this->getMockForAbstractClass( @@ -123,7 +123,7 @@ public function testApplyUpdates(): void $actionBMatcher = self::exactly(2); $actionB->expects($actionBMatcher) ->method('apply') - ->willReturnCallback(static function (...$parameters) use ($actionBMatcher) { + ->willReturnCallback(static function (...$parameters) use ($actionBMatcher): void { self::assertSame([$actionBMatcher->numberOfInvocations() === 1 ? 11 : 22], $parameters); }); diff --git a/tests/lib/Persistence/Legacy/Content/Type/Gateway/DoctrineDatabaseTest.php b/tests/lib/Persistence/Legacy/Content/Type/Gateway/DoctrineDatabaseTest.php index 6320226fa2..23b11b3189 100644 --- a/tests/lib/Persistence/Legacy/Content/Type/Gateway/DoctrineDatabaseTest.php +++ b/tests/lib/Persistence/Legacy/Content/Type/Gateway/DoctrineDatabaseTest.php @@ -480,7 +480,7 @@ public function testInsertTypeContentClassName($column, $expectation): void self::assertQueryResult( array_map( - static function ($value) { + static function ($value): array { return [$value]; }, $expectation diff --git a/tests/lib/Persistence/Legacy/Content/Type/MapperTest.php b/tests/lib/Persistence/Legacy/Content/Type/MapperTest.php index ee0fec59f5..a70e788ecd 100644 --- a/tests/lib/Persistence/Legacy/Content/Type/MapperTest.php +++ b/tests/lib/Persistence/Legacy/Content/Type/MapperTest.php @@ -471,7 +471,7 @@ protected function getNonConvertingMapper() ) )->will( self::returnCallback( - static function () { + static function (): \Ibexa\Contracts\Core\Persistence\Content\Type\FieldDefinition { return new FieldDefinition(); } ) diff --git a/tests/lib/QueryType/BuiltIn/SortSpec/SortClauseParser/FieldSortClauseParserTest.php b/tests/lib/QueryType/BuiltIn/SortSpec/SortClauseParser/FieldSortClauseParserTest.php index 7b0bb97a40..e1743335eb 100644 --- a/tests/lib/QueryType/BuiltIn/SortSpec/SortClauseParser/FieldSortClauseParserTest.php +++ b/tests/lib/QueryType/BuiltIn/SortSpec/SortClauseParser/FieldSortClauseParserTest.php @@ -33,7 +33,7 @@ public function testParse(): void $parser = $this->createMock(SortSpecParserInterface::class); $matcher = self::exactly(3); $parser->expects($matcher) - ->method('match')->willReturnCallback(static function (...$parameters) use ($matcher) { + ->method('match')->willReturnCallback(static function (...$parameters) use ($matcher): ?Token { if ($matcher->numberOfInvocations() === 1) { self::assertSame(Token::TYPE_ID, $parameters[0]); @@ -49,6 +49,8 @@ public function testParse(): void return new Token(Token::TYPE_ID, self::EXAMPLE_FIELD_ID); } + + return null; }); $parser->method('parseSortDirection')->willReturn(Query::SORT_ASC); diff --git a/tests/lib/QueryType/BuiltIn/SortSpec/SortClauseParser/MapDistanceSortClauseParserTest.php b/tests/lib/QueryType/BuiltIn/SortSpec/SortClauseParser/MapDistanceSortClauseParserTest.php index ebe7d89bd1..8d1c147b1a 100644 --- a/tests/lib/QueryType/BuiltIn/SortSpec/SortClauseParser/MapDistanceSortClauseParserTest.php +++ b/tests/lib/QueryType/BuiltIn/SortSpec/SortClauseParser/MapDistanceSortClauseParserTest.php @@ -35,7 +35,7 @@ public function testParse(): void $parser = $this->createMock(SortSpecParserInterface::class); $matcher = self::exactly(5); $parser->expects($matcher) - ->method('match')->willReturnCallback(static function (...$parameters) use ($matcher) { + ->method('match')->willReturnCallback(static function (...$parameters) use ($matcher): ?Token { if ($matcher->numberOfInvocations() === 1) { self::assertSame(Token::TYPE_ID, $parameters[0]); @@ -61,6 +61,8 @@ public function testParse(): void return new Token(Token::TYPE_FLOAT, (string)self::EXAMPLE_LON); } + + return null; }); $parser->method('parseSortDirection')->willReturn(Query::SORT_ASC); diff --git a/tests/lib/Repository/Mapper/ContentLocationMapper/DecoratedLocationServiceTest.php b/tests/lib/Repository/Mapper/ContentLocationMapper/DecoratedLocationServiceTest.php index 28a79793f6..17de1670de 100644 --- a/tests/lib/Repository/Mapper/ContentLocationMapper/DecoratedLocationServiceTest.php +++ b/tests/lib/Repository/Mapper/ContentLocationMapper/DecoratedLocationServiceTest.php @@ -87,7 +87,7 @@ public function testLoadLocationList(): void $this->mapper ->expects($matcher) - ->method('setMapping')->willReturnCallback(static function (...$parameters) use ($matcher) { + ->method('setMapping')->willReturnCallback(static function (...$parameters) use ($matcher): void { if ($matcher->numberOfInvocations() === 1) { self::assertSame(1, $parameters[0]); self::assertSame(2, $parameters[1]); @@ -139,7 +139,7 @@ public function testLoadLocations(): void $this->mapper ->expects($matcher) - ->method('setMapping')->willReturnCallback(static function (...$parameters) use ($matcher) { + ->method('setMapping')->willReturnCallback(static function (...$parameters) use ($matcher): void { if ($matcher->numberOfInvocations() === 1) { self::assertSame(1, $parameters[0]); self::assertSame(2, $parameters[1]); @@ -193,7 +193,7 @@ public function testLoadLocationChildren(): void $this->mapper ->expects($matcher) - ->method('setMapping')->willReturnCallback(static function (...$parameters) use ($matcher) { + ->method('setMapping')->willReturnCallback(static function (...$parameters) use ($matcher): void { if ($matcher->numberOfInvocations() === 1) { self::assertSame(1, $parameters[0]); self::assertSame(2, $parameters[1]); @@ -241,7 +241,7 @@ public function testLoadAllLocations(): void $this->mapper ->expects($matcher) - ->method('setMapping')->willReturnCallback(static function (...$parameters) use ($matcher) { + ->method('setMapping')->willReturnCallback(static function (...$parameters) use ($matcher): void { if ($matcher->numberOfInvocations() === 1) { self::assertSame(1, $parameters[0]); self::assertSame(2, $parameters[1]); diff --git a/tests/lib/Repository/Permission/CachedPermissionServiceTest.php b/tests/lib/Repository/Permission/CachedPermissionServiceTest.php index 1998771022..3995d43c78 100644 --- a/tests/lib/Repository/Permission/CachedPermissionServiceTest.php +++ b/tests/lib/Repository/Permission/CachedPermissionServiceTest.php @@ -53,7 +53,7 @@ public static function providerForTestPermissionResolverPassTrough(): array ['setCurrentUserReference', [$userRef], null], ['hasAccess', ['content', 'remove', $userRef], false], ['canUser', ['content', 'remove', $valueObject, [new \stdClass()]], true], - ['sudo', [static function () {}, $repository], null], + ['sudo', [static function (): void {}, $repository], null], ]; } diff --git a/tests/lib/Repository/Service/Mock/BookmarkTest.php b/tests/lib/Repository/Service/Mock/BookmarkTest.php index 76de78bd2a..c0f0e1d095 100644 --- a/tests/lib/Repository/Service/Mock/BookmarkTest.php +++ b/tests/lib/Repository/Service/Mock/BookmarkTest.php @@ -64,11 +64,11 @@ public function testCreateBookmark(): void ->with(self::CURRENT_USER_ID, [self::LOCATION_ID]) ->willReturn([]); - $this->assertTransactionIsCommitted(function () { + $this->assertTransactionIsCommitted(function (): void { $this->bookmarkHandler ->expects($this->once()) ->method('create') - ->willReturnCallback(static function (CreateStruct $createStruct) { + ->willReturnCallback(static function (CreateStruct $createStruct): \Ibexa\Contracts\Core\Persistence\Bookmark\Bookmark { self::assertEquals(self::LOCATION_ID, $createStruct->locationId); self::assertEquals(self::CURRENT_USER_ID, $createStruct->userId); @@ -93,7 +93,7 @@ public function testCreateBookmarkThrowsInvalidArgumentException(): void ->with(self::CURRENT_USER_ID, [self::LOCATION_ID]) ->willReturn([self::LOCATION_ID => new Bookmark()]); - $this->assertTransactionIsNotStarted(function () { + $this->assertTransactionIsNotStarted(function (): void { $this->bookmarkHandler->expects($this->never())->method('create'); }); @@ -114,7 +114,7 @@ public function testCreateBookmarkWithRollback(): void ->with(self::CURRENT_USER_ID, [self::LOCATION_ID]) ->willReturn([]); - $this->assertTransactionIsRollback(function () { + $this->assertTransactionIsRollback(function (): void { $this->bookmarkHandler ->expects($this->once()) ->method('create') @@ -138,7 +138,7 @@ public function testDeleteBookmarkExisting(): void ->with(self::CURRENT_USER_ID, [self::LOCATION_ID]) ->willReturn([self::LOCATION_ID => $bookmark]); - $this->assertTransactionIsCommitted(function () use ($bookmark) { + $this->assertTransactionIsCommitted(function () use ($bookmark): void { $this->bookmarkHandler ->expects($this->once()) ->method('delete') @@ -162,7 +162,7 @@ public function testDeleteBookmarkWithRollback(): void ->with(self::CURRENT_USER_ID, [self::LOCATION_ID]) ->willReturn([self::LOCATION_ID => new Bookmark(['id' => self::BOOKMARK_ID])]); - $this->assertTransactionIsRollback(function () { + $this->assertTransactionIsRollback(function (): void { $this->bookmarkHandler ->expects($this->once()) ->method('delete') @@ -186,7 +186,7 @@ public function testDeleteBookmarkNonExisting(): void ->with(self::CURRENT_USER_ID, [self::LOCATION_ID]) ->willReturn([]); - $this->assertTransactionIsNotStarted(function () { + $this->assertTransactionIsNotStarted(function (): void { $this->bookmarkHandler->expects($this->never())->method('delete'); }); @@ -199,7 +199,7 @@ public function testLoadBookmarks(): void $limit = 25; $expectedTotalCount = 10; - $expectedItems = array_map(function ($locationId) { + $expectedItems = array_map(function ($locationId): \Ibexa\Core\Repository\Values\Content\Location { return $this->createLocation($locationId); }, range(1, $expectedTotalCount)); $locationList = new LocationList(['totalCount' => $expectedTotalCount, 'locations' => $expectedItems]); diff --git a/tests/lib/Repository/Service/Mock/ContentTest.php b/tests/lib/Repository/Service/Mock/ContentTest.php index 282ae4ad31..ce3022f1bf 100644 --- a/tests/lib/Repository/Service/Mock/ContentTest.php +++ b/tests/lib/Repository/Service/Mock/ContentTest.php @@ -1896,7 +1896,7 @@ public function testCreateContentWithInvalidLanguage($mainLanguageCode, $structF ->with(self::isString()) ->will( self::returnCallback( - static function ($languageCode) { + static function ($languageCode): \Ibexa\Contracts\Core\Repository\Values\Content\Language { if ($languageCode === 'Klingon') { throw new NotFoundException('Language', 'Klingon'); } @@ -1963,7 +1963,7 @@ protected function assertForCreateContentContentValidationException( ->method('acceptValue') ->will( self::returnCallback( - static function ($valueString) { + static function ($valueString): \Ibexa\Tests\Core\Repository\Service\Mock\ValueStub { return new ValueStub($valueString); } ) @@ -2152,7 +2152,7 @@ private function loadByLanguageCodeMock(\PHPUnit\Framework\MockObject\MockObject ->with(self::isString()) ->will( self::returnCallback( - static function () { + static function (): \Ibexa\Contracts\Core\Repository\Values\Content\Language { return new Language(['id' => 4242]); } ) @@ -2393,7 +2393,7 @@ static function () use ($contentCreateStruct): bool { ->method('acceptValue') ->will( self::returnCallback( - static function ($value) { + static function ($value): SPIValue { return $value instanceof SPIValue ? $value : new ValueStub($value); @@ -2472,7 +2472,7 @@ private function acceptFieldTypeValueMock(FieldType&MockObject $fieldTypeMock): ->method('acceptValue') ->will( self::returnCallback( - static function ($valueString) { + static function ($valueString): \Ibexa\Tests\Core\Repository\Service\Mock\ValueStub { return new ValueStub($valueString); } ) @@ -2483,7 +2483,7 @@ private function toHashFieldTypeMock(\PHPUnit\Framework\MockObject\MockObject $f { $fieldTypeMock ->method('toHash') - ->willReturnCallback(static function (SPIValue $value) { + ->willReturnCallback(static function (SPIValue $value): array { return ['value' => $value->value]; }); } @@ -2599,7 +2599,7 @@ public function testCreateContentWithLocations(): void $buildSPILocationCreateStructMatcher = self::exactly(2); $domainMapperMock->expects($buildSPILocationCreateStructMatcher) ->method('buildSPILocationCreateStruct') - ->willReturnCallback(static function ($locationCreateStruct, $parentLocationArg, $mainLocation, $contentId, $contentVersionNo, bool $isContentHidden) use ($buildSPILocationCreateStructMatcher, $locationCreateStruct1, $locationCreateStruct2, $parentLocation, $spiLocationCreateStruct) { + ->willReturnCallback(static function ($locationCreateStruct, $parentLocationArg, $mainLocation, $contentId, $contentVersionNo, bool $isContentHidden) use ($buildSPILocationCreateStructMatcher, $locationCreateStruct1, $locationCreateStruct2, $parentLocation, $spiLocationCreateStruct): SPILocation\CreateStruct { self::assertSame($parentLocation, $parentLocationArg); self::assertNull($contentId); self::assertNull($contentVersionNo); @@ -2725,7 +2725,7 @@ public function testCreateContentWithLocationsDuplicateUnderParent(): void ->with(self::isString()) ->will( self::returnCallback( - static function () { + static function (): \Ibexa\Contracts\Core\Repository\Values\Content\Language { return new Language(['id' => 4242]); } ) @@ -2736,7 +2736,7 @@ static function () { ->method('acceptValue') ->will( self::returnCallback( - static function ($valueString) { + static function ($valueString): \Ibexa\Tests\Core\Repository\Service\Mock\ValueStub { return new ValueStub($valueString); } ) @@ -2809,7 +2809,7 @@ static function ($object) use ($contentCreateStruct): string { ->method('acceptValue') ->will( self::returnCallback( - static function ($valueString) { + static function ($valueString): \Ibexa\Tests\Core\Repository\Service\Mock\ValueStub { return new ValueStub($valueString); } ) @@ -3250,7 +3250,7 @@ protected function assertForTestUpdateContentNonRedundantFieldSet( $nameSchemaServiceMock = $this->getNameSchemaServiceMock(); $fieldTypeMock = $this->createMock(SPIFieldType::class); $existingLanguageCodes = array_map( - static function (Field $field) { + static function (Field $field): string { return $field->languageCode; }, $existingFields @@ -3292,7 +3292,7 @@ static function (Field $field) { ->with(self::isString()) ->will( self::returnCallback( - static function () { + static function (): \Ibexa\Contracts\Core\Repository\Values\Content\Language { return new Language(['id' => 4242]); } ) @@ -3327,7 +3327,7 @@ static function () { ->method('acceptValue') ->will( self::returnCallback( - static function ($value) { + static function ($value): SPIValue { return $value instanceof SPIValue ? $value : new ValueStub($value); @@ -4820,7 +4820,7 @@ public function testUpdateContentWithInvalidLanguage($initialLanguageCode, $stru ->with(self::isString()) ->will( self::returnCallback( - static function ($languageCode) { + static function ($languageCode): \Ibexa\Contracts\Core\Repository\Values\Content\Language { if ($languageCode === 'Klingon') { throw new NotFoundException('Language', 'Klingon'); } @@ -4905,7 +4905,7 @@ protected function assertForUpdateContentContentValidationException( ->method('acceptValue') ->will( self::returnCallback( - static function ($value) { + static function ($value): SPIValue { return $value instanceof SPIValue ? $value : new ValueStub($value); @@ -4923,7 +4923,7 @@ static function ($value) { ->with(self::isString()) ->will( self::returnCallback( - static function ($languageCode) { + static function ($languageCode): \Ibexa\Contracts\Core\Repository\Values\Content\Language { if ($languageCode === 'Klingon') { throw new NotFoundException('Language', 'Klingon'); } @@ -5110,7 +5110,7 @@ public function assertForTestUpdateContentRequiredField( $languageHandlerMock = $this->getPersistenceMock()->contentLanguageHandler(); $fieldTypeMock = $this->createMock(SPIFieldType::class); $existingLanguageCodes = array_map( - static function (Field $field) { + static function (Field $field): string { return $field->languageCode; }, $existingFields @@ -5264,7 +5264,7 @@ public function assertForTestUpdateContentThrowsContentFieldValidationException( $languageHandlerMock = $this->getPersistenceMock()->contentLanguageHandler(); $fieldTypeMock = $this->createMock(SPIFieldType::class); $existingLanguageCodes = array_map( - static function (Field $field) { + static function (Field $field): string { return $field->languageCode; }, $existingFields @@ -5301,7 +5301,7 @@ static function (Field $field) { ->method('acceptValue') ->will( self::returnCallback( - static function ($value) { + static function ($value): SPIValue { return $value instanceof SPIValue ? $value : new ValueStub($value); @@ -5324,7 +5324,7 @@ static function (ValueStub $value) use ($emptyValue): bool { ->method('validate') ->will( self::returnCallback( - static function (FieldDefinition $fieldDefinition) use ($allFieldErrors, $structFields) { + static function (FieldDefinition $fieldDefinition) use ($allFieldErrors, $structFields): ?ValidationError { foreach ($structFields as $structField) { if ($structField->fieldDefIdentifier !== $fieldDefinition->identifier) { continue; @@ -5635,7 +5635,7 @@ public function testCopyContent(): void $destinationLocationTarget = (new DestinationLocation($locationCreateStruct->parentLocationId, $contentInfoMock)); $matcher = self::exactly(2); $permissionResolverMock->expects($matcher) - ->method('canUser')->willReturnCallback(static function (...$parameters) use ($matcher, $contentInfoMock, $location, $destinationLocationTarget) { + ->method('canUser')->willReturnCallback(static function (...$parameters) use ($matcher, $contentInfoMock, $location, $destinationLocationTarget): ?bool { if ($matcher->numberOfInvocations() === 1) { self::assertSame('content', $parameters[0]); self::assertSame('create', $parameters[1]); @@ -5652,6 +5652,8 @@ public function testCopyContent(): void return true; } + + return null; }); $spiContentInfo = new SPIContentInfo(['id' => 42]); @@ -5776,7 +5778,7 @@ public function testCopyContentWithVersionInfo(): void $destinationLocationTarget = (new DestinationLocation($locationCreateStruct->parentLocationId, $contentInfoMock)); $matcher = self::exactly(2); $permissionResolverMock->expects($matcher) - ->method('canUser')->willReturnCallback(static function (...$parameters) use ($matcher, $contentInfoMock, $location, $destinationLocationTarget) { + ->method('canUser')->willReturnCallback(static function (...$parameters) use ($matcher, $contentInfoMock, $location, $destinationLocationTarget): ?bool { if ($matcher->numberOfInvocations() === 1) { self::assertSame('content', $parameters[0]); self::assertSame('create', $parameters[1]); @@ -5793,6 +5795,8 @@ public function testCopyContentWithVersionInfo(): void return true; } + + return null; }); $spiContentInfo = new SPIContentInfo(['id' => 42]); @@ -5891,7 +5895,7 @@ public function testCopyContentWithRollback(): void $destinationLocationTarget = (new DestinationLocation($locationCreateStruct->parentLocationId, $contentInfoMock)); $matcher = self::exactly(2); $permissionResolverMock->expects($matcher) - ->method('canUser')->willReturnCallback(static function (...$parameters) use ($matcher, $contentInfoMock, $location, $destinationLocationTarget) { + ->method('canUser')->willReturnCallback(static function (...$parameters) use ($matcher, $contentInfoMock, $location, $destinationLocationTarget): ?bool { if ($matcher->numberOfInvocations() === 1) { self::assertSame('content', $parameters[0]); self::assertSame('create', $parameters[1]); @@ -5908,6 +5912,8 @@ public function testCopyContentWithRollback(): void return true; } + + return null; }); $contentHandlerMock->expects(self::once()) @@ -6121,7 +6127,7 @@ protected function mockPublishUrlAliasesForContent(APIContent $content) $locationGetMatcher = self::exactly(4); $location->expects($locationGetMatcher) ->method('__get') - ->willReturnCallback(static function ($property) use ($locationGetMatcher) { + ->willReturnCallback(static function ($property) use ($locationGetMatcher): int { $invocation = $locationGetMatcher->numberOfInvocations(); if ($invocation === 1 || $invocation === 3) { self::assertSame('id', $property); diff --git a/tests/lib/Repository/Service/Mock/PermissionTest.php b/tests/lib/Repository/Service/Mock/PermissionTest.php index 047d31a60b..526531b65f 100644 --- a/tests/lib/Repository/Service/Mock/PermissionTest.php +++ b/tests/lib/Repository/Service/Mock/PermissionTest.php @@ -211,7 +211,7 @@ public function testHasAccessReturnsFalseButSudoSoTrue(): void ->method(self::anything()); $result = $service->sudo( - static function (Repository $repo) { + static function (Repository $repo): array|bool { return $repo->getPermissionResolver()->hasAccess('dummy-module', 'dummy-function'); }, $repositoryMock @@ -320,7 +320,7 @@ public function testHasAccessReturnsPermissionSets(array $roles, array $roleAssi $roleDomainMapper ->expects($buildDomainPolicyObjectMatcher) ->method('buildDomainPolicyObject') - ->willReturnCallback(static function ($policy) use ($buildDomainPolicyObjectMatcher, $expectedBuildDomainPolicyObjectCalls) { + ->willReturnCallback(static function ($policy) use ($buildDomainPolicyObjectMatcher, $expectedBuildDomainPolicyObjectCalls): string { [$expectedPolicy, $policyName] = $expectedBuildDomainPolicyObjectCalls[$buildDomainPolicyObjectMatcher->numberOfInvocations() - 1]; self::assertSame($expectedPolicy, $policy); @@ -438,7 +438,7 @@ public function testHasAccessReturnsLimitationNotFoundException(array $roles, ar $roleDomainMapper ->expects($buildDomainPolicyObjectMatcher) ->method('buildDomainPolicyObject') - ->willReturnCallback(static function ($policy) use ($buildDomainPolicyObjectMatcher, $expectedBuildDomainPolicyObjectCalls) { + ->willReturnCallback(static function ($policy) use ($buildDomainPolicyObjectMatcher, $expectedBuildDomainPolicyObjectCalls): string { [$expectedPolicy, $policyName] = $expectedBuildDomainPolicyObjectCalls[$buildDomainPolicyObjectMatcher->numberOfInvocations() - 1]; self::assertSame($expectedPolicy, $policy); @@ -630,7 +630,7 @@ public function testHasAccessReturnsPermissionSetsWithRoleLimitation(array $role $roleDomainMapper ->expects($buildDomainPolicyObjectMatcher) ->method('buildDomainPolicyObject') - ->willReturnCallback(static function ($policy) use ($buildDomainPolicyObjectMatcher, $expectedBuildDomainPolicyObjectCalls) { + ->willReturnCallback(static function ($policy) use ($buildDomainPolicyObjectMatcher, $expectedBuildDomainPolicyObjectCalls): string { [$expectedPolicy, $policyName] = $expectedBuildDomainPolicyObjectCalls[$buildDomainPolicyObjectMatcher->numberOfInvocations() - 1]; self::assertSame($expectedPolicy, $policy); @@ -643,7 +643,7 @@ public function testHasAccessReturnsPermissionSetsWithRoleLimitation(array $role $limitationTypeMock ->expects($buildValueMatcher) ->method('buildValue') - ->willReturnCallback(static function ($values) use ($buildValueMatcher, $expectedBuildValueCalls) { + ->willReturnCallback(static function ($values) use ($buildValueMatcher, $expectedBuildValueCalls): Limitation { [$expectedValues, $limitation] = $expectedBuildValueCalls[$buildValueMatcher->numberOfInvocations() - 1]; self::assertSame($expectedValues, $values); @@ -678,7 +678,7 @@ private function mockLoadRoleSequence($userHandlerMock, array $roleAssignments, $userHandlerMock ->expects($matcher) ->method('loadRole') - ->willReturnCallback(static function ($roleId, $status = Role::STATUS_DEFINED) use ($matcher, $roleAssignmentList, $roles) { + ->willReturnCallback(static function ($roleId, $status = Role::STATUS_DEFINED) use ($matcher, $roleAssignmentList, $roles): Role { $roleAssignment = $roleAssignmentList[$matcher->numberOfInvocations() - 1]; self::assertSame($roleAssignment->roleId, $roleId); @@ -1000,7 +1000,7 @@ public function testCanUserComplex(array $roleLimitationEvaluations, array $poli $limitationServiceMock ->expects($getLimitationTypeMatcher) ->method('getLimitationType') - ->willReturnCallback(static function ($identifier) use ($getLimitationTypeMatcher, $expectedGetLimitationTypeCalls) { + ->willReturnCallback(static function ($identifier) use ($getLimitationTypeMatcher, $expectedGetLimitationTypeCalls): Type { [$expectedIdentifier, $limitation] = $expectedGetLimitationTypeCalls[$getLimitationTypeMatcher->numberOfInvocations() - 1]; self::assertSame($expectedIdentifier, $identifier); diff --git a/tests/lib/Repository/Service/Mock/SearchTest.php b/tests/lib/Repository/Service/Mock/SearchTest.php index 63417e7281..9290c7fc6a 100644 --- a/tests/lib/Repository/Service/Mock/SearchTest.php +++ b/tests/lib/Repository/Service/Mock/SearchTest.php @@ -242,7 +242,7 @@ public function testFindContentWhenDomainMapperThrowsException(): void $mapper->expects(self::once()) ->method('buildContentDomainObjectsOnSearchResult') ->with(self::equalTo($result), self::equalTo([])) - ->willReturnCallback(static function (SearchResult $spiResult) use ($info) { + ->willReturnCallback(static function (SearchResult $spiResult) use ($info): array { unset($spiResult->searchHits[0]); if ($spiResult->totalCount !== null) { --$spiResult->totalCount; @@ -300,7 +300,7 @@ public function testFindContentNoPermissionsFilter(): void $mapper->expects(self::once()) ->method('buildContentDomainObjectsOnSearchResult') ->with(self::isInstanceOf(SearchResult::class), self::equalTo([])) - ->willReturnCallback(static function (SearchResult $spiResult) use ($contentMock) { + ->willReturnCallback(static function (SearchResult $spiResult) use ($contentMock): array { $spiResult->searchHits[0]->valueObject = $contentMock; return []; @@ -370,7 +370,7 @@ public function testFindContentWithPermission(): void ->expects(self::once()) ->method('buildContentDomainObjectsOnSearchResult') ->with(self::isInstanceOf(SearchResult::class), self::equalTo([])) - ->willReturnCallback(static function (SearchResult $spiResult) use ($contentMock) { + ->willReturnCallback(static function (SearchResult $spiResult) use ($contentMock): array { $spiResult->searchHits[0]->valueObject = $contentMock; return []; @@ -482,7 +482,7 @@ public function testFindContentWithDefaultQueryValues(): void ->expects(self::once()) ->method('buildContentDomainObjectsOnSearchResult') ->with(self::isInstanceOf(SearchResult::class), self::equalTo([])) - ->willReturnCallback(static function (SearchResult $spiResult) use ($contentMock) { + ->willReturnCallback(static function (SearchResult $spiResult) use ($contentMock): array { $spiResult->searchHits[0]->valueObject = $contentMock; return []; @@ -686,7 +686,7 @@ public function testFindLocationsWithPermission(): void $domainMapperMock->expects(self::once()) ->method('buildLocationDomainObjectsOnSearchResult') ->with(self::equalTo($spiResult)) - ->willReturnCallback(static function (SearchResult $spiResult) use ($endResult) { + ->willReturnCallback(static function (SearchResult $spiResult) use ($endResult): array { $spiResult->searchHits[0] = $endResult->searchHits[0]; return []; @@ -753,7 +753,7 @@ public function testFindLocationsWithNoPermissionsFilter(): void $domainMapperMock->expects(self::once()) ->method('buildLocationDomainObjectsOnSearchResult') ->with(self::equalTo($spiResult)) - ->willReturnCallback(static function (SearchResult $spiResult) use ($endResult) { + ->willReturnCallback(static function (SearchResult $spiResult) use ($endResult): array { $spiResult->searchHits[0] = $endResult->searchHits[0]; return []; @@ -803,7 +803,7 @@ public function testFindLocationsBackgroundIndexerWhenDomainMapperThrowsExceptio $mapper->expects(self::once()) ->method('buildLocationDomainObjectsOnSearchResult') ->with(self::equalTo($result)) - ->willReturnCallback(static function (SearchResult $spiResult) use ($location) { + ->willReturnCallback(static function (SearchResult $spiResult) use ($location): array { unset($spiResult->searchHits[0]); if ($spiResult->totalCount !== null) { --$spiResult->totalCount; @@ -909,7 +909,7 @@ public function testFindLocationsWithDefaultQueryValues(): void $domainMapperMock->expects(self::once()) ->method('buildLocationDomainObjectsOnSearchResult') ->with(self::equalTo($spiResult)) - ->willReturnCallback(static function (SearchResult $spiResult) use ($endResult) { + ->willReturnCallback(static function (SearchResult $spiResult) use ($endResult): array { $spiResult->searchHits[0] = $endResult->searchHits[0]; return []; diff --git a/tests/lib/Repository/Service/Mock/UrlTest.php b/tests/lib/Repository/Service/Mock/UrlTest.php index 4798c9581b..b60f78d56d 100644 --- a/tests/lib/Repository/Service/Mock/UrlTest.php +++ b/tests/lib/Repository/Service/Mock/UrlTest.php @@ -161,7 +161,7 @@ public function testUpdateUrl(): void $this->urlHandler ->expects(self::once()) ->method('updateUrl') - ->willReturnCallback(static function ($id, $struct) use ($apiUrl, $apiStruct) { + ->willReturnCallback(static function ($id, $struct) use ($apiUrl, $apiStruct): void { self::assertEquals($apiUrl->id, $id); self::assertEquals($apiStruct->url, $struct->url); @@ -221,7 +221,7 @@ public function testUpdateUrlStatus(): void $this->urlHandler ->expects(self::once()) ->method('updateUrl') - ->willReturnCallback(static function ($id, $struct) use ($apiUrl, $apiStruct) { + ->willReturnCallback(static function ($id, $struct) use ($apiUrl, $apiStruct): void { self::assertEquals($apiUrl->id, $id); self::assertEquals($apiUrl->url, $struct->url); @@ -351,11 +351,11 @@ public function testFindUsages($offset, $limit, ContentQuery $expectedQuery, arr $searchService ->expects(self::once()) ->method('findContentInfo') - ->willReturnCallback(static function ($query) use ($expectedQuery, $usages) { + ->willReturnCallback(static function ($query) use ($expectedQuery, $usages): \Ibexa\Contracts\Core\Repository\Values\Content\Search\SearchResult { self::assertEquals($expectedQuery, $query); return new ContentSearchResults([ - 'searchHits' => array_map(static function ($id) { + 'searchHits' => array_map(static function ($id): \Ibexa\Contracts\Core\Repository\Values\Content\Search\SearchHit { return new SearchHit([ 'valueObject' => new ContentInfo([ 'id' => $id, @@ -467,7 +467,7 @@ protected function configurePermissions(array $permissions) $this->permissionResolver ->expects($matcher) ->method('canUser') - ->willReturnCallback(static function (...$parameters) use ($matcher, $permissions) { + ->willReturnCallback(static function (...$parameters) use ($matcher, $permissions): bool { self::assertEquals($permissions[$matcher->numberOfInvocations() - 1], $parameters); return true; diff --git a/tests/lib/Repository/Service/Mock/UserPreferenceTest.php b/tests/lib/Repository/Service/Mock/UserPreferenceTest.php index 06e308aec0..b9c8f1c321 100644 --- a/tests/lib/Repository/Service/Mock/UserPreferenceTest.php +++ b/tests/lib/Repository/Service/Mock/UserPreferenceTest.php @@ -51,11 +51,11 @@ public function testSetUserPreference(): void 'value' => 'value', ]); - $this->assertTransactionIsCommitted(function () { + $this->assertTransactionIsCommitted(function (): void { $this->userSPIPreferenceHandler ->expects($this->once()) ->method('setUserPreference') - ->willReturnCallback(static function (UserPreferenceSetStruct $setStruct) { + ->willReturnCallback(static function (UserPreferenceSetStruct $setStruct): \Ibexa\Contracts\Core\Persistence\UserPreference\UserPreference { self::assertEquals(self::USER_PREFERENCE_NAME, $setStruct->name); self::assertEquals(self::USER_PREFERENCE_VALUE, $setStruct->value); self::assertEquals(self::CURRENT_USER_ID, $setStruct->userId); @@ -75,7 +75,7 @@ public function testSetUserPreferenceThrowsInvalidArgumentException(): void 'value' => 'value', ]); - $this->assertTransactionIsNotStarted(function () { + $this->assertTransactionIsNotStarted(function (): void { $this->userSPIPreferenceHandler->expects($this->never())->method('setUserPreference'); }); @@ -91,7 +91,7 @@ public function testSetUserPreferenceWithRollback(): void 'value' => 'value', ]); - $this->assertTransactionIsRollback(function () { + $this->assertTransactionIsRollback(function (): void { $this->userSPIPreferenceHandler ->expects($this->once()) ->method('setUserPreference') @@ -130,7 +130,7 @@ public function testLoadUserPreferences(): void $limit = 25; $expectedTotalCount = 10; - $expectedItems = array_map(function () { + $expectedItems = array_map(function (): \Ibexa\Contracts\Core\Repository\Values\UserPreference\UserPreference { return $this->createAPIUserPreference(); }, range(1, $expectedTotalCount)); @@ -144,7 +144,7 @@ public function testLoadUserPreferences(): void ->expects(self::once()) ->method('loadUserPreferences') ->with(self::CURRENT_USER_ID, $offset, $limit) - ->willReturn(array_map(static function ($locationId) { + ->willReturn(array_map(static function ($locationId): \Ibexa\Contracts\Core\Persistence\UserPreference\UserPreference { return new UserPreference([ 'name' => 'setting', 'value' => 'value', diff --git a/tests/lib/Repository/SiteAccessAware/SearchServiceTest.php b/tests/lib/Repository/SiteAccessAware/SearchServiceTest.php index 6fff0c994c..c53ff9fc36 100644 --- a/tests/lib/Repository/SiteAccessAware/SearchServiceTest.php +++ b/tests/lib/Repository/SiteAccessAware/SearchServiceTest.php @@ -43,7 +43,7 @@ public static function providerForLanguagesLookupMethods(): array $content = new Content(); $searchResults = new SearchResult(); - $callback = function ($languageLookup) { + $callback = function ($languageLookup): void { $this->languageResolverMock ->expects($this->once()) ->method('getUseAlwaysAvailable') diff --git a/tests/lib/Repository/SiteAccessAware/UrlAliasServiceTest.php b/tests/lib/Repository/SiteAccessAware/UrlAliasServiceTest.php index b89d9a229f..de3b47742a 100644 --- a/tests/lib/Repository/SiteAccessAware/UrlAliasServiceTest.php +++ b/tests/lib/Repository/SiteAccessAware/UrlAliasServiceTest.php @@ -47,7 +47,7 @@ public static function providerForLanguagesLookupMethods(): array $location = new Location(); $urlAlias = new URLAlias(); - $callback = function ($languageLookup) { + $callback = function ($languageLookup): void { $this->languageResolverMock ->expects($this->once()) ->method('getShowAllTranslations') diff --git a/tests/lib/Search/FieldNameResolverTest.php b/tests/lib/Search/FieldNameResolverTest.php index 48fd3d135d..8b07b0889c 100644 --- a/tests/lib/Search/FieldNameResolverTest.php +++ b/tests/lib/Search/FieldNameResolverTest.php @@ -95,7 +95,7 @@ public function testGetFieldNames(): void $mockedFieldNameResolver ->expects($getIndexFieldNameMatcher) ->method('getIndexFieldName') - ->willReturnCallback(static function ($criterion, $contentTypeIdentifier, $fieldDefinitionIdentifier, $fieldTypeIdentifier, $fieldName) use ($getIndexFieldNameMatcher) { + ->willReturnCallback(static function ($criterion, $contentTypeIdentifier, $fieldDefinitionIdentifier, $fieldTypeIdentifier, $fieldName) use ($getIndexFieldNameMatcher): array { self::assertInstanceOf(APICriterion::class, $criterion); self::assertSame('field_definition_identifier_1', $fieldDefinitionIdentifier); self::assertNull($fieldName); @@ -163,7 +163,7 @@ public function testGetFieldNamesWithNamedField(): void $mockedFieldNameResolver ->expects($getIndexFieldNameMatcher) ->method('getIndexFieldName') - ->willReturnCallback(static function ($criterion, $contentTypeIdentifier, $fieldDefinitionIdentifier, $fieldTypeIdentifier, $fieldName) use ($getIndexFieldNameMatcher) { + ->willReturnCallback(static function ($criterion, $contentTypeIdentifier, $fieldDefinitionIdentifier, $fieldTypeIdentifier, $fieldName) use ($getIndexFieldNameMatcher): array { self::assertInstanceOf(APICriterion::class, $criterion); self::assertSame('field_definition_identifier_1', $fieldDefinitionIdentifier); self::assertSame('field_name', $fieldName); diff --git a/tests/lib/Search/Legacy/Content/AbstractTestCase.php b/tests/lib/Search/Legacy/Content/AbstractTestCase.php index 378b877427..66ed06834d 100644 --- a/tests/lib/Search/Legacy/Content/AbstractTestCase.php +++ b/tests/lib/Search/Legacy/Content/AbstractTestCase.php @@ -71,7 +71,7 @@ protected function assertSearchResults($expectedIds, $searchResult) protected function getIds($searchResult) { $ids = array_map( - static function ($hit) { + static function ($hit): mixed { return $hit->valueObject->id; }, $searchResult->searchHits diff --git a/tests/lib/Search/Legacy/Content/HandlerContentSortTest.php b/tests/lib/Search/Legacy/Content/HandlerContentSortTest.php index 65898f883e..753fa645f4 100644 --- a/tests/lib/Search/Legacy/Content/HandlerContentSortTest.php +++ b/tests/lib/Search/Legacy/Content/HandlerContentSortTest.php @@ -180,7 +180,7 @@ public function testNoSorting(): void ); $ids = array_map( - static function ($hit) { + static function ($hit): mixed { return $hit->valueObject->id; }, $result->searchHits @@ -211,7 +211,7 @@ public function testSortDateModified(): void self::assertEquals( [4, 12, 13, 42, 10, 14, 11, 226], array_map( - static function ($hit) { + static function ($hit): mixed { return $hit->valueObject->id; }, $result->searchHits @@ -239,7 +239,7 @@ public function testSortDatePublished(): void self::assertEquals( [4, 10, 11, 12, 13, 14, 226, 42], array_map( - static function ($hit) { + static function ($hit): mixed { return $hit->valueObject->id; }, $result->searchHits @@ -275,7 +275,7 @@ public function testSortSectionIdentifier(): void 6 => [154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164], ]; $contentIds = array_map( - static function ($hit) { + static function ($hit): mixed { return $hit->valueObject->id; }, $result->searchHits @@ -321,7 +321,7 @@ public function testSortSectionName(): void 'users' => [4, 10, 11, 12, 13, 14, 42, 226], ]; $contentIds = array_map( - static function ($hit) { + static function ($hit): mixed { return $hit->valueObject->id; }, $result->searchHits @@ -365,7 +365,7 @@ public function testSortContentName(): void self::assertEquals( [226, 14, 12, 10, 42, 57, 13, 50, 49, 41, 11, 51, 62, 4, 58, 59, 61, 60, 64, 63, 200, 66, 201], array_map( - static function ($hit) { + static function ($hit): mixed { return $hit->valueObject->id; }, $result->searchHits @@ -425,7 +425,7 @@ public function testSortFieldText(): void 'tutorials for' => [106], ]; $contentIds = array_map( - static function ($hit) { + static function ($hit): mixed { return $hit->valueObject->id; }, $result->searchHits @@ -468,7 +468,7 @@ public function testSortFieldNumeric(): void self::assertEquals( [73, 71, 72, 69], array_map( - static function ($hit) { + static function ($hit): mixed { return $hit->valueObject->id; }, $result->searchHits diff --git a/tests/lib/Search/Legacy/Content/HandlerContentTest.php b/tests/lib/Search/Legacy/Content/HandlerContentTest.php index d39a2f2491..fd82d51a55 100644 --- a/tests/lib/Search/Legacy/Content/HandlerContentTest.php +++ b/tests/lib/Search/Legacy/Content/HandlerContentTest.php @@ -1034,7 +1034,7 @@ public function testFullTextFilterNoStopwordRemoval(): void self::assertCount( 10, array_map( - static function ($hit) { + static function ($hit): mixed { return $hit->valueObject->id; }, $result->searchHits diff --git a/tests/lib/Search/Legacy/Content/HandlerLocationSortTest.php b/tests/lib/Search/Legacy/Content/HandlerLocationSortTest.php index bae10da0b7..f5ba733ec7 100644 --- a/tests/lib/Search/Legacy/Content/HandlerLocationSortTest.php +++ b/tests/lib/Search/Legacy/Content/HandlerLocationSortTest.php @@ -31,7 +31,7 @@ class HandlerLocationSortTest extends AbstractTestCase protected function getIds($searchResult) { $ids = array_map( - static function ($hit) { + static function ($hit): mixed { return $hit->valueObject->id; }, $searchResult->searchHits @@ -485,7 +485,7 @@ public function testSortSectionName(): void 'users' => [5, 12, 13, 14, 15, 44, 45, 228], ]; $locationIds = array_map( - static function ($hit) { + static function ($hit): mixed { return $hit->valueObject->id; }, $result->searchHits @@ -561,7 +561,7 @@ public function testSortFieldText(): void 'tutorials for' => [108], ]; $locationIds = array_map( - static function ($hit) { + static function ($hit): mixed { return $hit->valueObject->id; }, $result->searchHits @@ -604,7 +604,7 @@ public function testSortFieldNumeric(): void self::assertEquals( [75, 73, 74, 71], array_map( - static function ($hit) { + static function ($hit): mixed { return $hit->valueObject->id; }, $result->searchHits diff --git a/tests/lib/Search/Legacy/Content/HandlerLocationTest.php b/tests/lib/Search/Legacy/Content/HandlerLocationTest.php index 38e3dd9188..409e2e4260 100644 --- a/tests/lib/Search/Legacy/Content/HandlerLocationTest.php +++ b/tests/lib/Search/Legacy/Content/HandlerLocationTest.php @@ -1142,7 +1142,7 @@ public function testFullTextFilterNoStopwordRemoval(): void self::assertCount( 10, array_map( - static function ($hit) { + static function ($hit): mixed { return $hit->valueObject->id; }, $result->searchHits From 2b30723b5e226af228f80173b89722c14770b498 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Nowak?= Date: Tue, 22 Sep 2026 14:30:28 +0200 Subject: [PATCH 4/6] IBX-12654: Fixed static:: calls to abstract static methods to use $this:: per convention --- .../FieldType/SearchBaseIntegrationTestCase.php | 4 ++-- .../SearchMultivaluedBaseIntegrationTestCase.php | 4 ++-- .../Validator/BaseNumericValidatorTestCase.php | 12 ++++++------ .../SiteAccessAware/AbstractServiceTestCase.php | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/integration/Core/Repository/FieldType/SearchBaseIntegrationTestCase.php b/tests/integration/Core/Repository/FieldType/SearchBaseIntegrationTestCase.php index 61d8e37e31..95629216d8 100644 --- a/tests/integration/Core/Repository/FieldType/SearchBaseIntegrationTestCase.php +++ b/tests/integration/Core/Repository/FieldType/SearchBaseIntegrationTestCase.php @@ -310,12 +310,12 @@ public function testCreateTestContent(): array $context = [ $repository, $this->createTestSearchContent( - static::getValidSearchValueOne(), + $this::getValidSearchValueOne(), $repository, $contentType )->id, $this->createTestSearchContent( - static::getValidSearchValueTwo(), + $this::getValidSearchValueTwo(), $repository, $contentType )->id, diff --git a/tests/integration/Core/Repository/FieldType/SearchMultivaluedBaseIntegrationTestCase.php b/tests/integration/Core/Repository/FieldType/SearchMultivaluedBaseIntegrationTestCase.php index 22684298ff..4a9b2df75c 100644 --- a/tests/integration/Core/Repository/FieldType/SearchMultivaluedBaseIntegrationTestCase.php +++ b/tests/integration/Core/Repository/FieldType/SearchMultivaluedBaseIntegrationTestCase.php @@ -160,12 +160,12 @@ public function testCreateMultivaluedTestContent(): array $context = [ $repository, $this->createTestSearchContent( - static::getValidMultivaluedSearchValuesOne(), + $this::getValidMultivaluedSearchValuesOne(), $repository, $contentType )->id, $this->createTestSearchContent( - static::getValidMultivaluedSearchValuesTwo(), + $this::getValidMultivaluedSearchValuesTwo(), $repository, $contentType )->id, diff --git a/tests/lib/FieldType/Validator/BaseNumericValidatorTestCase.php b/tests/lib/FieldType/Validator/BaseNumericValidatorTestCase.php index ff0727b3aa..49c9808c35 100644 --- a/tests/lib/FieldType/Validator/BaseNumericValidatorTestCase.php +++ b/tests/lib/FieldType/Validator/BaseNumericValidatorTestCase.php @@ -184,10 +184,10 @@ public function testValidateConstraintsCorrectValues(array $data): void $constraints = []; if (array_key_exists('min', $data)) { - $constraints[static::getMinNumericValueName()] = $data['min']; + $constraints[$this::getMinNumericValueName()] = $data['min']; } if (array_key_exists('max', $data)) { - $constraints[static::getMinNumericValueName()] = $data['max']; + $constraints[$this::getMinNumericValueName()] = $data['max']; } self::assertEmpty( @@ -203,8 +203,8 @@ public function testValidateConstraintsCorrectValues(array $data): void #[DataProvider('providerForConstraintsInitializeSetGet')] final public function testConstraintsInitializeGet(array $constraints): void { - $minNumericValueName = static::getMinNumericValueName(); - $maxNumericValueName = static::getMaxNumericValueName(); + $minNumericValueName = $this::getMinNumericValueName(); + $maxNumericValueName = $this::getMaxNumericValueName(); $validator = $this->getValidatorInstance(); $validator->initializeWithConstraints( $constraints @@ -219,8 +219,8 @@ final public function testConstraintsInitializeGet(array $constraints): void #[DataProvider('providerForConstraintsInitializeSetGet')] final public function testConstraintsSetGet(array $constraints): void { - $minNumericValueName = static::getMinNumericValueName(); - $maxNumericValueName = static::getMaxNumericValueName(); + $minNumericValueName = $this::getMinNumericValueName(); + $maxNumericValueName = $this::getMaxNumericValueName(); $validator = $this->getValidatorInstance(); $validator->{$minNumericValueName} = $constraints[$minNumericValueName]; $validator->{$maxNumericValueName} = $constraints[$maxNumericValueName]; diff --git a/tests/lib/Repository/SiteAccessAware/AbstractServiceTestCase.php b/tests/lib/Repository/SiteAccessAware/AbstractServiceTestCase.php index a7cfea24da..9d2532ed85 100644 --- a/tests/lib/Repository/SiteAccessAware/AbstractServiceTestCase.php +++ b/tests/lib/Repository/SiteAccessAware/AbstractServiceTestCase.php @@ -289,10 +289,10 @@ final public function testIfThereIsMissingTest(): void { $tested = array_merge( array_diff( - array_column(self::toArray(static::providerForLanguagesLookupMethods()), 0), + array_column(self::toArray($this::providerForLanguagesLookupMethods()), 0), [self::NO_DATA_METHOD] ), - array_column(self::toArray(static::providerForPassTroughMethods()), 0) + array_column(self::toArray($this::providerForPassTroughMethods()), 0) ); $class = new ReflectionClass($this->getSiteAccessAwareServiceClassName()); From 607fca4edbd6ba58e195cf678a7412f767e228e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Nowak?= Date: Tue, 22 Sep 2026 14:40:21 +0200 Subject: [PATCH 5/6] IBX-12654: Fixed composer root version resolution in backend-ci.yaml jobs --- .github/workflows/backend-ci.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/backend-ci.yaml b/.github/workflows/backend-ci.yaml index 3111203e64..66e94d1e28 100644 --- a/.github/workflows/backend-ci.yaml +++ b/.github/workflows/backend-ci.yaml @@ -18,6 +18,8 @@ jobs: steps: - uses: actions/checkout@v7 + - uses: ibexa/gh-workflows/actions/setup-composer-root-version@main + - uses: ibexa/gh-workflows/actions/composer-install@main with: php-version: ${{ matrix.php }} @@ -44,6 +46,7 @@ jobs: - '8.4' steps: - uses: actions/checkout@v7 + - uses: ibexa/gh-workflows/actions/setup-composer-root-version@main - name: Install Composer dependencies uses: ibexa/gh-workflows/actions/composer-install@main with: @@ -69,6 +72,8 @@ jobs: steps: - uses: actions/checkout@v7 + - uses: ibexa/gh-workflows/actions/setup-composer-root-version@main + - uses: ibexa/gh-workflows/actions/composer-install@main with: php-version: ${{ matrix.php }} @@ -121,6 +126,8 @@ jobs: steps: - uses: actions/checkout@v7 + - uses: ibexa/gh-workflows/actions/setup-composer-root-version@main + - uses: ibexa/gh-workflows/actions/composer-install@main with: php-version: ${{ matrix.php }} @@ -173,6 +180,8 @@ jobs: steps: - uses: actions/checkout@v7 + - uses: ibexa/gh-workflows/actions/setup-composer-root-version@main + - uses: ibexa/gh-workflows/actions/composer-install@main with: php-version: ${{ matrix.php }} @@ -229,6 +238,8 @@ jobs: php-version: ${{ matrix.php }} coverage: none + - uses: ibexa/gh-workflows/actions/setup-composer-root-version@main + - name: Add solr dependency run: | VERSION=$(jq -r '.extra | ."branch-alias" | ."dev-main"' < composer.json) From 2a669f235ba8baeec4577b915f4461f9c7539ba0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Nowak?= Date: Wed, 23 Sep 2026 14:11:43 +0200 Subject: [PATCH 6/6] IBX-12654: Replaced fully-qualified closure return types with imports Co-Authored-By: Claude Opus 5.5 (1M context) --- .../Core/Features/Context/ContentContext.php | 8 ++++---- src/lib/FieldType/Author/Type.php | 2 +- .../SudoMainLocationLoader.php | 3 ++- .../ImageAsset/ParameterProvider.php | 2 +- .../Symfony/Matcher/ContentBased/Depth.php | 2 +- .../ContentBased/Id/ParentContentType.php | 6 +++--- .../ContentBased/Id/ParentLocation.php | 2 +- .../Identifier/ParentContentType.php | 5 +++-- .../ContentBased/Identifier/Section.php | 7 ++++--- .../Provider/StaticSiteAccessProvider.php | 2 +- .../View/Builder/ContentViewBuilder.php | 4 ++-- src/lib/Persistence/Cache/ContentHandler.php | 6 +++--- .../Cache/ContentLanguageHandler.php | 4 ++-- .../Persistence/Cache/ContentTypeHandler.php | 11 +++++----- src/lib/Persistence/Cache/LocationHandler.php | 4 ++-- src/lib/Persistence/Cache/UserHandler.php | 14 ++++++------- src/lib/Repository/NotificationService.php | 4 ++-- src/lib/Repository/RoleService.php | 2 +- src/lib/Repository/SectionService.php | 2 +- src/lib/Repository/UserPreferenceService.php | 2 +- .../Fragment/DirectFragmentRendererTest.php | 4 ++-- .../bundle/Core/URLChecker/URLCheckerTest.php | 2 +- .../Limitation/MemberOfLimitationTest.php | 3 ++- .../Core/Limitation/RoleLimitationTest.php | 3 ++- .../ContentServiceAuthorizationTest.php | 2 +- .../Core/Repository/ContentServiceTest.php | 5 +++-- .../LocationLimitationIntegrationTest.php | 3 ++- tests/lib/FieldType/Generic/GenericTest.php | 4 ++-- .../ImageAsset/ParameterProviderTest.php | 4 ++-- .../Symfony/Routing/UrlAliasGeneratorTest.php | 2 +- .../Provider/ChainSiteAccessProviderTest.php | 2 +- .../Legacy/Content/ContentHandlerTest.php | 2 +- .../Legacy/Content/LocationHandlerTest.php | 4 ++-- .../Content/Type/ContentTypeHandlerTest.php | 2 +- .../Legacy/Content/Type/MapperTest.php | 2 +- .../Repository/Service/Mock/BookmarkTest.php | 4 ++-- .../Repository/Service/Mock/ContentTest.php | 20 +++++++++---------- tests/lib/Repository/Service/Mock/UrlTest.php | 4 ++-- .../Service/Mock/UserPreferenceTest.php | 6 +++--- 39 files changed, 89 insertions(+), 81 deletions(-) diff --git a/src/bundle/Core/Features/Context/ContentContext.php b/src/bundle/Core/Features/Context/ContentContext.php index 2de5a88b3d..bff9965fac 100644 --- a/src/bundle/Core/Features/Context/ContentContext.php +++ b/src/bundle/Core/Features/Context/ContentContext.php @@ -66,7 +66,7 @@ public function createContentItem($contentTypeIdentifier, array $fields) $draft = $this->createDraft($contentTypeIdentifier, $fields); $this->currentContent = $this->repository->sudo( - function () use ($draft): \Ibexa\Contracts\Core\Repository\Values\Content\Content { + function () use ($draft): Content { return $this->repository->getContentService()->publishVersion($draft->versionInfo); } ); @@ -79,7 +79,7 @@ function () use ($draft): \Ibexa\Contracts\Core\Repository\Values\Content\Conten public function createDraftForContent(Content $content) { $this->currentDraft = $this->repository->sudo( - function () use ($content): \Ibexa\Contracts\Core\Repository\Values\Content\Content { + function () use ($content): Content { return $this->repository->getContentService()->createContentDraft($content->contentInfo); } ); @@ -105,7 +105,7 @@ public function updateDraft($fields) $updateStruct->setField($fieldDefIdentifier, $fieldValueUpdate); } - $updatedDraft = $this->repository->sudo(function () use ($updateStruct): \Ibexa\Contracts\Core\Repository\Values\Content\Content { + $updatedDraft = $this->repository->sudo(function () use ($updateStruct): Content { return $this->repository->getContentService()->updateContent( $this->currentDraft->versionInfo, $updateStruct @@ -140,7 +140,7 @@ public function createDraft($contentTypeIdentifier, array $fields) $locationCreateStruct = $this->repository->getLocationService()->newLocationCreateStruct(2); $this->currentDraft = $this->repository->sudo( - function () use ($createStruct, $locationCreateStruct): \Ibexa\Contracts\Core\Repository\Values\Content\Content { + function () use ($createStruct, $locationCreateStruct): Content { return $this->repository->getContentService()->createContent( $createStruct, [$locationCreateStruct] diff --git a/src/lib/FieldType/Author/Type.php b/src/lib/FieldType/Author/Type.php index 91e44e72c9..0193f711a3 100644 --- a/src/lib/FieldType/Author/Type.php +++ b/src/lib/FieldType/Author/Type.php @@ -138,7 +138,7 @@ public function fromHash($hash) { return new Value( array_map( - static function ($author): \Ibexa\Core\FieldType\Author\Author { + static function ($author): Author { return new Author($author); }, $hash diff --git a/src/lib/Helper/ContentInfoLocationLoader/SudoMainLocationLoader.php b/src/lib/Helper/ContentInfoLocationLoader/SudoMainLocationLoader.php index 6c19fe4668..a426f05d7f 100644 --- a/src/lib/Helper/ContentInfoLocationLoader/SudoMainLocationLoader.php +++ b/src/lib/Helper/ContentInfoLocationLoader/SudoMainLocationLoader.php @@ -10,6 +10,7 @@ use Exception; use Ibexa\Contracts\Core\Repository\Repository; use Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo; +use Ibexa\Contracts\Core\Repository\Values\Content\Location; use Ibexa\Core\Base\Exceptions\NotFoundException; use Ibexa\Core\Helper\ContentInfoLocationLoader; @@ -34,7 +35,7 @@ public function loadLocation(ContentInfo $contentInfo) try { return $this->repository->sudo( - static function (Repository $repository) use ($contentInfo): \Ibexa\Contracts\Core\Repository\Values\Content\Location { + static function (Repository $repository) use ($contentInfo): Location { return $repository->getLocationService()->loadLocation($contentInfo->mainLocationId); } ); diff --git a/src/lib/MVC/Symfony/FieldType/ImageAsset/ParameterProvider.php b/src/lib/MVC/Symfony/FieldType/ImageAsset/ParameterProvider.php index ad92597317..7e467d3d6c 100644 --- a/src/lib/MVC/Symfony/FieldType/ImageAsset/ParameterProvider.php +++ b/src/lib/MVC/Symfony/FieldType/ImageAsset/ParameterProvider.php @@ -73,7 +73,7 @@ public function getViewParameters(Field $field): array private function loadContentInfo(int $id): ContentInfo { return $this->repository->sudo( - static function (Repository $repository) use ($id): \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo { + static function (Repository $repository) use ($id): ContentInfo { return $repository->getContentService()->loadContentInfo($id); } ); diff --git a/src/lib/MVC/Symfony/Matcher/ContentBased/Depth.php b/src/lib/MVC/Symfony/Matcher/ContentBased/Depth.php index dbd08e0b18..6d72d2b4fc 100644 --- a/src/lib/MVC/Symfony/Matcher/ContentBased/Depth.php +++ b/src/lib/MVC/Symfony/Matcher/ContentBased/Depth.php @@ -38,7 +38,7 @@ public function matchLocation(Location $location): bool public function matchContentInfo(ContentInfo $contentInfo): bool { $location = $this->repository->sudo( - static function (Repository $repository) use ($contentInfo): \Ibexa\Contracts\Core\Repository\Values\Content\Location { + static function (Repository $repository) use ($contentInfo): Location { return $repository->getLocationService()->loadLocation($contentInfo->mainLocationId); } ); diff --git a/src/lib/MVC/Symfony/Matcher/ContentBased/Id/ParentContentType.php b/src/lib/MVC/Symfony/Matcher/ContentBased/Id/ParentContentType.php index 3ba25261cf..2efe48eb3b 100644 --- a/src/lib/MVC/Symfony/Matcher/ContentBased/Id/ParentContentType.php +++ b/src/lib/MVC/Symfony/Matcher/ContentBased/Id/ParentContentType.php @@ -26,7 +26,7 @@ class ParentContentType extends MultipleValued public function matchLocation(APILocation $location): bool { $parent = $this->repository->sudo( - static function (Repository $repository) use ($location): \Ibexa\Contracts\Core\Repository\Values\Content\Location { + static function (Repository $repository) use ($location): APILocation { return $repository->getLocationService()->loadLocation($location->parentLocationId); } ); @@ -44,7 +44,7 @@ static function (Repository $repository) use ($location): \Ibexa\Contracts\Core\ public function matchContentInfo(ContentInfo $contentInfo) { $location = $this->repository->sudo( - static function (Repository $repository) use ($contentInfo): \Ibexa\Contracts\Core\Repository\Values\Content\Location { + static function (Repository $repository) use ($contentInfo): APILocation { return $repository->getLocationService()->loadLocation($contentInfo->mainLocationId); } ); @@ -70,7 +70,7 @@ public function match(View $view): bool private function loadParentLocation($locationId) { return $this->repository->sudo( - static function (Repository $repository) use ($locationId): \Ibexa\Contracts\Core\Repository\Values\Content\Location { + static function (Repository $repository) use ($locationId): APILocation { return $repository->getLocationService()->loadLocation($locationId); } ); diff --git a/src/lib/MVC/Symfony/Matcher/ContentBased/Id/ParentLocation.php b/src/lib/MVC/Symfony/Matcher/ContentBased/Id/ParentLocation.php index 356e62ba20..f4d0d41b3f 100644 --- a/src/lib/MVC/Symfony/Matcher/ContentBased/Id/ParentLocation.php +++ b/src/lib/MVC/Symfony/Matcher/ContentBased/Id/ParentLocation.php @@ -38,7 +38,7 @@ public function matchLocation(APILocation $location): bool public function matchContentInfo(ContentInfo $contentInfo): bool { $location = $this->repository->sudo( - static function (Repository $repository) use ($contentInfo): \Ibexa\Contracts\Core\Repository\Values\Content\Location { + static function (Repository $repository) use ($contentInfo): APILocation { return $repository->getLocationService()->loadLocation($contentInfo->mainLocationId); } ); diff --git a/src/lib/MVC/Symfony/Matcher/ContentBased/Identifier/ParentContentType.php b/src/lib/MVC/Symfony/Matcher/ContentBased/Identifier/ParentContentType.php index f942a51054..e81eb5bcb1 100644 --- a/src/lib/MVC/Symfony/Matcher/ContentBased/Identifier/ParentContentType.php +++ b/src/lib/MVC/Symfony/Matcher/ContentBased/Identifier/ParentContentType.php @@ -10,6 +10,7 @@ use Ibexa\Contracts\Core\Repository\Repository; use Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo; use Ibexa\Contracts\Core\Repository\Values\Content\Location as APILocation; +use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType as APIContentType; use Ibexa\Core\MVC\Symfony\Matcher\ContentBased\MultipleValued; use Ibexa\Core\MVC\Symfony\View\ContentValueView; use Ibexa\Core\MVC\Symfony\View\LocationValueView; @@ -27,7 +28,7 @@ class ParentContentType extends MultipleValued public function matchLocation(APILocation $location): bool { $parentContentType = $this->repository->sudo( - static function (Repository $repository) use ($location): \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType { + static function (Repository $repository) use ($location): APIContentType { $parent = $repository->getLocationService()->loadLocation($location->parentLocationId); return $repository @@ -49,7 +50,7 @@ static function (Repository $repository) use ($location): \Ibexa\Contracts\Core\ public function matchContentInfo(ContentInfo $contentInfo) { $location = $this->repository->sudo( - static function (Repository $repository) use ($contentInfo): \Ibexa\Contracts\Core\Repository\Values\Content\Location { + static function (Repository $repository) use ($contentInfo): APILocation { return $repository->getLocationService()->loadLocation($contentInfo->mainLocationId); } ); diff --git a/src/lib/MVC/Symfony/Matcher/ContentBased/Identifier/Section.php b/src/lib/MVC/Symfony/Matcher/ContentBased/Identifier/Section.php index ce4b65b587..5a4184c07e 100644 --- a/src/lib/MVC/Symfony/Matcher/ContentBased/Identifier/Section.php +++ b/src/lib/MVC/Symfony/Matcher/ContentBased/Identifier/Section.php @@ -10,6 +10,7 @@ use Ibexa\Contracts\Core\Repository\Repository; use Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo; use Ibexa\Contracts\Core\Repository\Values\Content\Location; +use Ibexa\Contracts\Core\Repository\Values\Content\Section as APISection; use Ibexa\Core\MVC\Symfony\Matcher\ContentBased\MultipleValued; use Ibexa\Core\MVC\Symfony\View\ContentValueView; use Ibexa\Core\MVC\Symfony\View\View; @@ -26,7 +27,7 @@ class Section extends MultipleValued public function matchLocation(Location $location): bool { $section = $this->repository->sudo( - static function (Repository $repository) use ($location): \Ibexa\Contracts\Core\Repository\Values\Content\Section { + static function (Repository $repository) use ($location): APISection { return $repository->getSectionService()->loadSection( $location->getContentInfo()->getSectionId() ); @@ -46,7 +47,7 @@ static function (Repository $repository) use ($location): \Ibexa\Contracts\Core\ public function matchContentInfo(ContentInfo $contentInfo): bool { $section = $this->repository->sudo( - static function (Repository $repository) use ($contentInfo): \Ibexa\Contracts\Core\Repository\Values\Content\Section { + static function (Repository $repository) use ($contentInfo): APISection { return $repository->getSectionService()->loadSection( $contentInfo->getSectionId() ); @@ -64,7 +65,7 @@ public function match(View $view): bool $contentInfo = $view->getContent()->contentInfo; $section = $this->repository->sudo( - static function (Repository $repository) use ($contentInfo): \Ibexa\Contracts\Core\Repository\Values\Content\Section { + static function (Repository $repository) use ($contentInfo): APISection { return $repository->getSectionService()->loadSection( $contentInfo->getSectionId() ); diff --git a/src/lib/MVC/Symfony/SiteAccess/Provider/StaticSiteAccessProvider.php b/src/lib/MVC/Symfony/SiteAccess/Provider/StaticSiteAccessProvider.php index 91a6781bd3..abf255bbe2 100644 --- a/src/lib/MVC/Symfony/SiteAccess/Provider/StaticSiteAccessProvider.php +++ b/src/lib/MVC/Symfony/SiteAccess/Provider/StaticSiteAccessProvider.php @@ -66,7 +66,7 @@ private function createSiteAccess(string $name): SiteAccess { $siteAccess = new SiteAccess($name, SiteAccess::DEFAULT_MATCHING_TYPE, null, self::class); $siteAccess->groups = array_map( - static function ($groupName): \Ibexa\Core\MVC\Symfony\SiteAccessGroup { + static function ($groupName): SiteAccessGroup { return new SiteAccessGroup($groupName); }, $this->groupsBySiteAccess[$name] ?? [] diff --git a/src/lib/MVC/Symfony/View/Builder/ContentViewBuilder.php b/src/lib/MVC/Symfony/View/Builder/ContentViewBuilder.php index 32da7c092e..20f0e6b6ec 100644 --- a/src/lib/MVC/Symfony/View/Builder/ContentViewBuilder.php +++ b/src/lib/MVC/Symfony/View/Builder/ContentViewBuilder.php @@ -208,7 +208,7 @@ private function loadContent($contentId, ?string $languageCode = null) private function loadEmbeddedContent($contentId, ?Location $location = null, ?string $languageCode = null) { $content = $this->repository->sudo( - static function (Repository $repository) use ($contentId, $languageCode): \Ibexa\Contracts\Core\Repository\Values\Content\Content { + static function (Repository $repository) use ($contentId, $languageCode): Content { return $repository->getContentService()->loadContent($contentId, $languageCode ? [$languageCode] : null); } ); @@ -242,7 +242,7 @@ static function (Repository $repository) use ($contentId, $languageCode): \Ibexa private function loadLocation($locationId) { $location = $this->repository->sudo( - static function (Repository $repository) use ($locationId): \Ibexa\Contracts\Core\Repository\Values\Content\Location { + static function (Repository $repository) use ($locationId): Location { return $repository->getLocationService()->loadLocation($locationId); } ); diff --git a/src/lib/Persistence/Cache/ContentHandler.php b/src/lib/Persistence/Cache/ContentHandler.php index 1d1c335708..c5939497d9 100644 --- a/src/lib/Persistence/Cache/ContentHandler.php +++ b/src/lib/Persistence/Cache/ContentHandler.php @@ -154,7 +154,7 @@ public function load($contentId, $versionNo = null, ?array $translations = null) return $this->getCacheValue( (int) $contentId, $this->cacheIdentifierGenerator->generateKey(self::CONTENT_IDENTIFIER, [], true) . '-', - function ($id) use ($versionNo, $translations): \Ibexa\Contracts\Core\Persistence\Content { + function ($id) use ($versionNo, $translations): Content { return $this->persistenceHandler->contentHandler()->load($id, $versionNo, $translations); }, $this->getContentTags, @@ -207,7 +207,7 @@ public function loadContentInfo($contentId) return $this->getCacheValue( $contentId, $this->cacheIdentifierGenerator->generateKey(self::CONTENT_INFO_IDENTIFIER, [], true) . '-', - function ($contentId): \Ibexa\Contracts\Core\Persistence\Content\ContentInfo { + function ($contentId): ContentInfo { return $this->persistenceHandler->contentHandler()->loadContentInfo($contentId); }, $this->getContentInfoTags, @@ -240,7 +240,7 @@ public function loadContentInfoByRemoteId($remoteId) return $this->getCacheValue( $this->cacheIdentifierSanitizer->escapeForCacheKey($remoteId), $this->cacheIdentifierGenerator->generateKey(self::CONTENT_INFO_BY_REMOTE_ID_IDENTIFIER, [], true) . '-', - function () use ($remoteId): \Ibexa\Contracts\Core\Persistence\Content\ContentInfo { + function () use ($remoteId): ContentInfo { return $this->persistenceHandler->contentHandler()->loadContentInfoByRemoteId($remoteId); }, $this->getContentInfoTags, diff --git a/src/lib/Persistence/Cache/ContentLanguageHandler.php b/src/lib/Persistence/Cache/ContentLanguageHandler.php index 5b4e541adb..333173f175 100644 --- a/src/lib/Persistence/Cache/ContentLanguageHandler.php +++ b/src/lib/Persistence/Cache/ContentLanguageHandler.php @@ -87,7 +87,7 @@ public function load($id) return $this->getCacheValue( $id, $this->cacheIdentifierGenerator->generateKey(self::LANGUAGE_IDENTIFIER, [], true) . '-', - function ($id): \Ibexa\Contracts\Core\Persistence\Content\Language { + function ($id): Language { return $this->persistenceHandler->contentLanguageHandler()->load($id); }, $this->getTags, @@ -119,7 +119,7 @@ public function loadByLanguageCode($languageCode) return $this->getCacheValue( $this->cacheIdentifierSanitizer->escapeForCacheKey($languageCode), $this->cacheIdentifierGenerator->generateKey(self::LANGUAGE_CODE_IDENTIFIER, [], true) . '-', - function () use ($languageCode): \Ibexa\Contracts\Core\Persistence\Content\Language { + function () use ($languageCode): Language { return $this->persistenceHandler->contentLanguageHandler()->loadByLanguageCode($languageCode); }, $this->getTags, diff --git a/src/lib/Persistence/Cache/ContentTypeHandler.php b/src/lib/Persistence/Cache/ContentTypeHandler.php index 72fe803394..b4e2176c82 100644 --- a/src/lib/Persistence/Cache/ContentTypeHandler.php +++ b/src/lib/Persistence/Cache/ContentTypeHandler.php @@ -10,6 +10,7 @@ use Ibexa\Contracts\Core\Persistence\Content\Type; use Ibexa\Contracts\Core\Persistence\Content\Type\CreateStruct; use Ibexa\Contracts\Core\Persistence\Content\Type\FieldDefinition; +use Ibexa\Contracts\Core\Persistence\Content\Type\Group; use Ibexa\Contracts\Core\Persistence\Content\Type\Group\CreateStruct as GroupCreateStruct; use Ibexa\Contracts\Core\Persistence\Content\Type\Group\UpdateStruct as GroupUpdateStruct; use Ibexa\Contracts\Core\Persistence\Content\Type\Handler as ContentTypeHandlerInterface; @@ -150,7 +151,7 @@ public function loadGroup($groupId) return $this->getCacheValue( $groupId, $this->cacheIdentifierGenerator->generateKey(self::CONTENT_TYPE_GROUP_IDENTIFIER, [], true) . '-', - function ($groupId): \Ibexa\Contracts\Core\Persistence\Content\Type\Group { + function ($groupId): Group { return $this->persistenceHandler->contentTypeHandler()->loadGroup($groupId); }, $this->getGroupTags, @@ -182,7 +183,7 @@ public function loadGroupByIdentifier($identifier) return $this->getCacheValue( $this->cacheIdentifierSanitizer->escapeForCacheKey($identifier), $this->cacheIdentifierGenerator->generateKey(self::CONTENT_TYPE_GROUP_IDENTIFIER, [], true) . '-', - function () use ($identifier): \Ibexa\Contracts\Core\Persistence\Content\Type\Group { + function () use ($identifier): Group { return $this->persistenceHandler->contentTypeHandler()->loadGroupByIdentifier($identifier); }, $this->getGroupTags, @@ -272,7 +273,7 @@ public function load($typeId, $status = Type::STATUS_DEFINED) return $this->getCacheValue( $typeId, $this->cacheIdentifierGenerator->generateKey(self::CONTENT_TYPE_IDENTIFIER, [], true) . '-', - function ($typeId) use ($status): \Ibexa\Contracts\Core\Persistence\Content\Type { + function ($typeId) use ($status): Type { return $this->persistenceHandler->contentTypeHandler()->load($typeId, $status); }, $this->getTypeTags, @@ -290,7 +291,7 @@ public function loadByIdentifier($identifier) return $this->getCacheValue( $this->cacheIdentifierSanitizer->escapeForCacheKey($identifier), $this->cacheIdentifierGenerator->generateKey(self::CONTENT_TYPE_IDENTIFIER, [], true) . '-', - function () use ($identifier): \Ibexa\Contracts\Core\Persistence\Content\Type { + function () use ($identifier): Type { return $this->persistenceHandler->contentTypeHandler()->loadByIdentifier($identifier); }, $this->getTypeTags, @@ -307,7 +308,7 @@ public function loadByRemoteId($remoteId) return $this->getCacheValue( $this->cacheIdentifierSanitizer->escapeForCacheKey($remoteId), $this->cacheIdentifierGenerator->generateKey(self::CONTENT_TYPE_IDENTIFIER, [], true) . '-', - function () use ($remoteId): \Ibexa\Contracts\Core\Persistence\Content\Type { + function () use ($remoteId): Type { return $this->persistenceHandler->contentTypeHandler()->loadByRemoteId($remoteId); }, $this->getTypeTags, diff --git a/src/lib/Persistence/Cache/LocationHandler.php b/src/lib/Persistence/Cache/LocationHandler.php index 5f4554e09b..99e1a84c0d 100644 --- a/src/lib/Persistence/Cache/LocationHandler.php +++ b/src/lib/Persistence/Cache/LocationHandler.php @@ -69,7 +69,7 @@ public function load($locationId, ?array $translations = null, bool $useAlwaysAv return $this->getCacheValue( (int) $locationId, $this->cacheIdentifierGenerator->generateKey(self::LOCATION_IDENTIFIER, [], true) . '-', - function ($id) use ($translations, $useAlwaysAvailable): \Ibexa\Contracts\Core\Persistence\Content\Location { + function ($id) use ($translations, $useAlwaysAvailable): Location { return $this->persistenceHandler->locationHandler()->load($id, $translations, $useAlwaysAvailable); }, $this->getLocationTags, @@ -231,7 +231,7 @@ public function loadByRemoteId($remoteId, ?array $translations = null, bool $use return $this->getCacheValue( $this->cacheIdentifierSanitizer->escapeForCacheKey($remoteId), $this->cacheIdentifierGenerator->generateKey(self::LOCATION_REMOTE_ID_IDENTIFIER, [], true) . '-', - function () use ($remoteId, $translations, $useAlwaysAvailable): \Ibexa\Contracts\Core\Persistence\Content\Location { + function () use ($remoteId, $translations, $useAlwaysAvailable): Location { return $this->persistenceHandler->locationHandler()->loadByRemoteId($remoteId, $translations, $useAlwaysAvailable); }, $this->getLocationTags, diff --git a/src/lib/Persistence/Cache/UserHandler.php b/src/lib/Persistence/Cache/UserHandler.php index 9c1350875a..5661cac01e 100644 --- a/src/lib/Persistence/Cache/UserHandler.php +++ b/src/lib/Persistence/Cache/UserHandler.php @@ -160,7 +160,7 @@ public function load($userId) return $this->getCacheValue( $userId, $this->cacheIdentifierGenerator->generateKey(self::USER_IDENTIFIER, [], true) . '-', - function ($userId): \Ibexa\Contracts\Core\Persistence\User { + function ($userId): User { return $this->persistenceHandler->userHandler()->load($userId); }, $this->getUserTags, @@ -176,7 +176,7 @@ public function loadByLogin($login) return $this->getCacheValue( $this->cacheIdentifierSanitizer->escapeForCacheKey($login), $this->cacheIdentifierGenerator->generateKey(self::USER_IDENTIFIER, [], true) . '-', - function () use ($login): \Ibexa\Contracts\Core\Persistence\User { + function () use ($login): User { return $this->persistenceHandler->userHandler()->loadByLogin($login); }, $this->getUserTags, @@ -194,7 +194,7 @@ public function loadByEmail(string $email): User $cachedValue = $this->getCacheValue( $this->cacheIdentifierSanitizer->escapeForCacheKey($email), $this->cacheIdentifierGenerator->generateKey(self::USER_IDENTIFIER, [], true) . '-', - function () use ($email): \Ibexa\Contracts\Core\Persistence\User { + function () use ($email): User { return $this->persistenceHandler->userHandler()->loadByEmail($email); }, $this->getUserTags, @@ -236,7 +236,7 @@ public function loadUserByToken($hash) return $this->getCacheValue( $hash, $this->cacheIdentifierGenerator->generateKey(self::USER_IDENTIFIER, [], true) . '-', - function ($hash): \Ibexa\Contracts\Core\Persistence\User { + function ($hash): User { return $this->persistenceHandler->userHandler()->loadUserByToken($hash); }, function (User $user) use ($getUserTagsFn): array { @@ -407,7 +407,7 @@ public function loadRole($roleId, $status = Role::STATUS_DEFINED) return $this->getCacheValue( $roleId, $this->cacheIdentifierGenerator->generateKey(self::ROLE_IDENTIFIER, [], true) . '-', - function ($roleId): \Ibexa\Contracts\Core\Persistence\User\Role { + function ($roleId): Role { return $this->persistenceHandler->userHandler()->loadRole($roleId); }, $this->getRoleTags, @@ -429,7 +429,7 @@ public function loadRoleByIdentifier($identifier, $status = Role::STATUS_DEFINED return $this->getCacheValue( $this->cacheIdentifierSanitizer->escapeForCacheKey($identifier), $this->cacheIdentifierGenerator->generateKey(self::ROLE_IDENTIFIER, [], true) . '-', - function () use ($identifier): \Ibexa\Contracts\Core\Persistence\User\Role { + function () use ($identifier): Role { return $this->persistenceHandler->userHandler()->loadRoleByIdentifier($identifier); }, $this->getRoleTags, @@ -466,7 +466,7 @@ public function loadRoleAssignment($roleAssignmentId) return $this->getCacheValue( $roleAssignmentId, $this->cacheIdentifierGenerator->generateKey(self::ROLE_ASSIGNMENT_IDENTIFIER, [], true) . '-', - function ($roleAssignmentId): \Ibexa\Contracts\Core\Persistence\User\RoleAssignment { + function ($roleAssignmentId): RoleAssignment { return $this->persistenceHandler->userHandler()->loadRoleAssignment($roleAssignmentId); }, $this->getRoleAssignmentTags, diff --git a/src/lib/Repository/NotificationService.php b/src/lib/Repository/NotificationService.php index 32cc35cc90..006bc243c8 100644 --- a/src/lib/Repository/NotificationService.php +++ b/src/lib/Repository/NotificationService.php @@ -39,7 +39,7 @@ public function loadNotifications(int $offset = 0, int $limit = 25): Notificatio $list->totalCount = $this->persistenceHandler->countNotifications($currentUserId); if ($list->totalCount > 0) { - $list->items = array_map(function (Notification $spiNotification): \Ibexa\Contracts\Core\Repository\Values\Notification\Notification { + $list->items = array_map(function (Notification $spiNotification): APINotification { return $this->buildDomainObject($spiNotification); }, $this->persistenceHandler->loadUserNotifications($currentUserId, $offset, $limit)); } @@ -55,7 +55,7 @@ public function findNotifications(?NotificationQuery $query = null): Notificatio $list->totalCount = $this->persistenceHandler->countNotifications($currentUserId, $query); if ($list->totalCount > 0) { - $list->items = array_map(function (Notification $spiNotification): \Ibexa\Contracts\Core\Repository\Values\Notification\Notification { + $list->items = array_map(function (Notification $spiNotification): APINotification { return $this->buildDomainObject($spiNotification); }, $this->persistenceHandler->findUserNotifications($currentUserId, $query)); } diff --git a/src/lib/Repository/RoleService.php b/src/lib/Repository/RoleService.php index 916eb6c900..3b87f88400 100644 --- a/src/lib/Repository/RoleService.php +++ b/src/lib/Repository/RoleService.php @@ -642,7 +642,7 @@ public function loadRoleByIdentifier(string $identifier): APIRole public function loadRoles(): iterable { $roles = array_map( - function ($spiRole): \Ibexa\Contracts\Core\Repository\Values\User\Role { + function ($spiRole): APIRole { return $this->roleDomainMapper->buildDomainRoleObject($spiRole); }, $this->userHandler->loadRoles() diff --git a/src/lib/Repository/SectionService.php b/src/lib/Repository/SectionService.php index 1a74d44a4b..b5468f1be8 100644 --- a/src/lib/Repository/SectionService.php +++ b/src/lib/Repository/SectionService.php @@ -210,7 +210,7 @@ public function loadSection(int $sectionId): Section */ public function loadSections(): iterable { - $sections = array_map(function ($spiSection): \Ibexa\Contracts\Core\Repository\Values\Content\Section { + $sections = array_map(function ($spiSection): Section { return $this->buildDomainSectionObject($spiSection); }, $this->sectionHandler->loadAll()); diff --git a/src/lib/Repository/UserPreferenceService.php b/src/lib/Repository/UserPreferenceService.php index dd490421b8..9ac0f15386 100644 --- a/src/lib/Repository/UserPreferenceService.php +++ b/src/lib/Repository/UserPreferenceService.php @@ -47,7 +47,7 @@ public function loadUserPreferences(int $offset = 0, int $limit = 25): UserPrefe $list->totalCount = $this->userPreferenceHandler->countUserPreferences($currentUserId); if ($list->totalCount > 0) { - $list->items = array_map(function (UserPreference $spiUserPreference): \Ibexa\Contracts\Core\Repository\Values\UserPreference\UserPreference { + $list->items = array_map(function (UserPreference $spiUserPreference): APIUserPreference { return $this->buildDomainObject($spiUserPreference); }, $this->userPreferenceHandler->loadUserPreferences($currentUserId, $offset, $limit)); } diff --git a/tests/bundle/Core/Fragment/DirectFragmentRendererTest.php b/tests/bundle/Core/Fragment/DirectFragmentRendererTest.php index 31b87a0b1d..21f6343119 100644 --- a/tests/bundle/Core/Fragment/DirectFragmentRendererTest.php +++ b/tests/bundle/Core/Fragment/DirectFragmentRendererTest.php @@ -59,7 +59,7 @@ public function testSubRequestBuilding(): void $controllerResolver ->method('getController') - ->willReturn(static function (): \Symfony\Component\HttpFoundation\Response { + ->willReturn(static function (): Response { return new Response('response_body'); }); @@ -75,7 +75,7 @@ public function testControllerResponse(): void $controllerResolver ->method('getController') - ->willReturn(static function (): \Symfony\Component\HttpFoundation\Response { + ->willReturn(static function (): Response { return new Response('response_body'); }); diff --git a/tests/bundle/Core/URLChecker/URLCheckerTest.php b/tests/bundle/Core/URLChecker/URLCheckerTest.php index d71e5bb4d6..d595c7ccda 100644 --- a/tests/bundle/Core/URLChecker/URLCheckerTest.php +++ b/tests/bundle/Core/URLChecker/URLCheckerTest.php @@ -35,7 +35,7 @@ protected function setUp(): void $this->urlService ->expects(self::any()) ->method('createUpdateStruct') - ->willReturnCallback(static function (): \Ibexa\Contracts\Core\Repository\Values\URL\URLUpdateStruct { + ->willReturnCallback(static function (): URLUpdateStruct { return new URLUpdateStruct(); }); diff --git a/tests/integration/Core/Limitation/MemberOfLimitationTest.php b/tests/integration/Core/Limitation/MemberOfLimitationTest.php index 38b9caf714..d7efed45e9 100644 --- a/tests/integration/Core/Limitation/MemberOfLimitationTest.php +++ b/tests/integration/Core/Limitation/MemberOfLimitationTest.php @@ -10,6 +10,7 @@ use Ibexa\Contracts\Core\Repository\Repository; use Ibexa\Contracts\Core\Repository\Values\User\Limitation\MemberOfLimitation; +use Ibexa\Contracts\Core\Repository\Values\User\UserGroup; use Ibexa\Core\Limitation\MemberOfLimitationType; use Ibexa\Tests\Integration\Core\Repository\Limitation\PermissionResolver\BaseLimitationIntegrationTestCase; use PHPUnit\Framework\Attributes\DataProvider; @@ -62,7 +63,7 @@ public function testCanUserAssignRoleToUser(array $limitations, bool $expectedRe 'assign', $limitations, $repository->sudo( - static function (Repository $repository): \Ibexa\Contracts\Core\Repository\Values\User\UserGroup { + static function (Repository $repository): UserGroup { return $repository->getUserService()->loadUserGroup(self::USERS_GROUP_ID); }, $repository diff --git a/tests/integration/Core/Limitation/RoleLimitationTest.php b/tests/integration/Core/Limitation/RoleLimitationTest.php index 4aa19d30dd..2131466800 100644 --- a/tests/integration/Core/Limitation/RoleLimitationTest.php +++ b/tests/integration/Core/Limitation/RoleLimitationTest.php @@ -10,6 +10,7 @@ use Ibexa\Contracts\Core\Repository\Repository; use Ibexa\Contracts\Core\Repository\Values\User\Limitation\UserRoleLimitation; +use Ibexa\Contracts\Core\Repository\Values\User\UserGroup; use Ibexa\Tests\Integration\Core\Repository\Limitation\PermissionResolver\BaseLimitationIntegrationTestCase; use PHPUnit\Framework\Attributes\DataProvider; @@ -57,7 +58,7 @@ public function testCanUserAssignRole(array $limitations, bool $expectedResult): 'assign', $limitations, $repository->sudo( - static function (Repository $repository): \Ibexa\Contracts\Core\Repository\Values\User\UserGroup { + static function (Repository $repository): UserGroup { return $repository->getUserService()->loadUserGroup(self::USERS_GROUP_ID); }, $repository diff --git a/tests/integration/Core/Repository/ContentServiceAuthorizationTest.php b/tests/integration/Core/Repository/ContentServiceAuthorizationTest.php index 5b163539e4..1ccc21b86c 100644 --- a/tests/integration/Core/Repository/ContentServiceAuthorizationTest.php +++ b/tests/integration/Core/Repository/ContentServiceAuthorizationTest.php @@ -129,7 +129,7 @@ public function testSudo(): void $contentId = $this->generateId('object', 10); $this->setRestrictedEditorUser(); - $contentInfo = $repository->sudo(static function (Repository $repository) use ($contentId): \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo { + $contentInfo = $repository->sudo(static function (Repository $repository) use ($contentId): ContentInfo { return $repository->getContentService()->loadContentInfo($contentId); }); diff --git a/tests/integration/Core/Repository/ContentServiceTest.php b/tests/integration/Core/Repository/ContentServiceTest.php index 8c908662c5..ccbcf08c5d 100644 --- a/tests/integration/Core/Repository/ContentServiceTest.php +++ b/tests/integration/Core/Repository/ContentServiceTest.php @@ -21,6 +21,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Field; use Ibexa\Contracts\Core\Repository\Values\Content\Language; use Ibexa\Contracts\Core\Repository\Values\Content\Location; +use Ibexa\Contracts\Core\Repository\Values\Content\LocationCreateStruct; use Ibexa\Contracts\Core\Repository\Values\Content\Relation; use Ibexa\Contracts\Core\Repository\Values\Content\RelationList\RelationListItemInterface; use Ibexa\Contracts\Core\Repository\Values\Content\RelationType; @@ -5876,7 +5877,7 @@ public function testHideContent(): void $contentTypeService = $this->getRepository()->getContentTypeService(); $locationCreateStructs = array_map( - function (Location $parentLocation): \Ibexa\Contracts\Core\Repository\Values\Content\LocationCreateStruct { + function (Location $parentLocation): LocationCreateStruct { return $this->locationService->newLocationCreateStruct($parentLocation->id); }, $this->createParentLocationsForHideReveal(2) @@ -5916,7 +5917,7 @@ public function testRevealContent(): void $contentTypeService = $this->getRepository()->getContentTypeService(); $locationCreateStructs = array_map( - function (Location $parentLocation): \Ibexa\Contracts\Core\Repository\Values\Content\LocationCreateStruct { + function (Location $parentLocation): LocationCreateStruct { return $this->locationService->newLocationCreateStruct($parentLocation->id); }, $this->createParentLocationsForHideReveal(2) diff --git a/tests/integration/Core/Repository/Limitation/PermissionResolver/LocationLimitationIntegrationTest.php b/tests/integration/Core/Repository/Limitation/PermissionResolver/LocationLimitationIntegrationTest.php index 40fef0b2e6..40bb70d583 100644 --- a/tests/integration/Core/Repository/Limitation/PermissionResolver/LocationLimitationIntegrationTest.php +++ b/tests/integration/Core/Repository/Limitation/PermissionResolver/LocationLimitationIntegrationTest.php @@ -10,6 +10,7 @@ use Ibexa\Contracts\Core\Limitation\Target\Version; use Ibexa\Contracts\Core\Repository\Repository; +use Ibexa\Contracts\Core\Repository\Values\Content\TrashItem; use Ibexa\Contracts\Core\Repository\Values\User\Limitation\LocationLimitation; use PHPUnit\Framework\Attributes\DataProvider; @@ -80,7 +81,7 @@ public function testCanUserReadTrashedContent(array $limitations, bool $expected $this->loginAsEditorUserWithLimitations('content', 'read', $limitations); $trashItem = $repository->sudo( - static function (Repository $repository) use ($location): ?\Ibexa\Contracts\Core\Repository\Values\Content\TrashItem { + static function (Repository $repository) use ($location): ?TrashItem { return $repository->getTrashService()->trash($location); } ); diff --git a/tests/lib/FieldType/Generic/GenericTest.php b/tests/lib/FieldType/Generic/GenericTest.php index 892e31db58..d90b5ee0cd 100644 --- a/tests/lib/FieldType/Generic/GenericTest.php +++ b/tests/lib/FieldType/Generic/GenericTest.php @@ -59,7 +59,7 @@ public function testValidateInvalid(array $fieldDefinitionData, FieldTypeValue $ { $constraintViolationList = new ConstraintViolationList( array_map( - static fn (ValidationError $error): \Symfony\Component\Validator\ConstraintViolation => new ConstraintViolation( + static fn (ValidationError $error): ConstraintViolation => new ConstraintViolation( (string)$error->getTranslatableMessage(), null, [], @@ -185,7 +185,7 @@ private function createSerializerMock(): ValueSerializerInterface $serializer ->method('denormalize') - ->willReturnCallback(static function (array $data, string $valueClass): \Ibexa\Tests\Core\FieldType\Generic\Stubs\Value { + ->willReturnCallback(static function (array $data, string $valueClass): GenericFieldValueStub { self::assertEquals(GenericFieldValueStub::class, $valueClass); return new GenericFieldValueStub($data['value']); diff --git a/tests/lib/MVC/Symfony/FieldType/ImageAsset/ParameterProviderTest.php b/tests/lib/MVC/Symfony/FieldType/ImageAsset/ParameterProviderTest.php index f18054a315..c9cbbeed69 100644 --- a/tests/lib/MVC/Symfony/FieldType/ImageAsset/ParameterProviderTest.php +++ b/tests/lib/MVC/Symfony/FieldType/ImageAsset/ParameterProviderTest.php @@ -75,7 +75,7 @@ public function testGetViewParameters($status, array $expected): void ->method('isEmptyValue') ->willReturn(false); - $closure = static function (Repository $repository) use ($destinationContentId): \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo { + $closure = static function (Repository $repository) use ($destinationContentId): ContentInfo { return $repository->getContentService()->loadContentInfo($destinationContentId); }; @@ -103,7 +103,7 @@ public function testGetViewParametersHandleNotFoundException(): void ->method('isEmptyValue') ->willReturn(false); - $closure = static function (Repository $repository) use ($destinationContentId): \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo { + $closure = static function (Repository $repository) use ($destinationContentId): ContentInfo { return $repository->getContentService()->loadContentInfo($destinationContentId); }; diff --git a/tests/lib/MVC/Symfony/Routing/UrlAliasGeneratorTest.php b/tests/lib/MVC/Symfony/Routing/UrlAliasGeneratorTest.php index 0c28d5df88..813ca4f24b 100644 --- a/tests/lib/MVC/Symfony/Routing/UrlAliasGeneratorTest.php +++ b/tests/lib/MVC/Symfony/Routing/UrlAliasGeneratorTest.php @@ -260,7 +260,7 @@ public function testDoGenerateWithSiteAccessParam(URLAlias $urlAlias, array $par ->method('loadLocation') ->will( self::returnCallback( - static function ($locationId): \Ibexa\Core\Repository\Values\Content\Location { + static function ($locationId): Location { return new Location(['id' => $locationId]); } ) diff --git a/tests/lib/MVC/Symfony/SiteAccess/Provider/ChainSiteAccessProviderTest.php b/tests/lib/MVC/Symfony/SiteAccess/Provider/ChainSiteAccessProviderTest.php index fa51f46aff..088732dfb3 100644 --- a/tests/lib/MVC/Symfony/SiteAccess/Provider/ChainSiteAccessProviderTest.php +++ b/tests/lib/MVC/Symfony/SiteAccess/Provider/ChainSiteAccessProviderTest.php @@ -161,7 +161,7 @@ private function createSiteAcccess(string $name, array $groupNames = []): SiteAc StaticSiteAccessProvider::class ); $undefinedSiteAccess->groups = array_map( - static function (string $groupName): \Ibexa\Core\MVC\Symfony\SiteAccessGroup { + static function (string $groupName): SiteAccessGroup { return new SiteAccessGroup($groupName); }, $groupNames diff --git a/tests/lib/Persistence/Legacy/Content/ContentHandlerTest.php b/tests/lib/Persistence/Legacy/Content/ContentHandlerTest.php index 90b9a2502f..da879a194c 100644 --- a/tests/lib/Persistence/Legacy/Content/ContentHandlerTest.php +++ b/tests/lib/Persistence/Legacy/Content/ContentHandlerTest.php @@ -1343,7 +1343,7 @@ public function testCopyAllVersions(): void $copyLoadMatcher = self::exactly(2); $handler->expects($copyLoadMatcher) ->method('load') - ->willReturnCallback(static function ($contentId, $versionNo) use ($copyLoadMatcher, $versionInfo): \Ibexa\Contracts\Core\Persistence\Content { + ->willReturnCallback(static function ($contentId, $versionNo) use ($copyLoadMatcher, $versionInfo): Content { self::assertSame(23, $contentId); if ($copyLoadMatcher->numberOfInvocations() === 1) { self::assertSame(2, $versionNo); diff --git a/tests/lib/Persistence/Legacy/Content/LocationHandlerTest.php b/tests/lib/Persistence/Legacy/Content/LocationHandlerTest.php index c9b0deaa1e..7072ed6287 100644 --- a/tests/lib/Persistence/Legacy/Content/LocationHandlerTest.php +++ b/tests/lib/Persistence/Legacy/Content/LocationHandlerTest.php @@ -234,7 +234,7 @@ public function testMoveSubtree(): void $this->treeHandler ->expects($loadLocationMatcher) ->method('loadLocation') - ->willReturnCallback(static function (int $nodeId) use ($loadLocationMatcher, $sourceData, $destinationData): \Ibexa\Contracts\Core\Persistence\Content\Location { + ->willReturnCallback(static function (int $nodeId) use ($loadLocationMatcher, $sourceData, $destinationData): Location { $expectedArgs = [$sourceData['node_id'], $destinationData['node_id']]; $returnValues = [ new Location([ @@ -253,7 +253,7 @@ public function testMoveSubtree(): void $this->contentHandler ->expects($loadContentInfoMatcher) ->method('loadContentInfo') - ->willReturnCallback(static function (int $contentId) use ($loadContentInfoMatcher, $sourceData, $destinationData): \Ibexa\Contracts\Core\Persistence\Content\ContentInfo { + ->willReturnCallback(static function (int $contentId) use ($loadContentInfoMatcher, $sourceData, $destinationData): ContentInfo { $expectedArgs = [$destinationData['contentobject_id'], $sourceData['contentobject_id']]; $returnValues = [ new ContentInfo(['sectionId' => 12345]), diff --git a/tests/lib/Persistence/Legacy/Content/Type/ContentTypeHandlerTest.php b/tests/lib/Persistence/Legacy/Content/Type/ContentTypeHandlerTest.php index cf9eacb25a..a9765e5f73 100644 --- a/tests/lib/Persistence/Legacy/Content/Type/ContentTypeHandlerTest.php +++ b/tests/lib/Persistence/Legacy/Content/Type/ContentTypeHandlerTest.php @@ -1039,7 +1039,7 @@ public function testPublishNoOldType(): void $matcher = self::exactly(2); $handler->expects($matcher) ->method('load') - ->willReturnCallback(static function (...$parameters) use ($matcher): \Ibexa\Contracts\Core\Persistence\Content\Type { + ->willReturnCallback(static function (...$parameters) use ($matcher): Type { if ($matcher->numberOfInvocations() === 1) { self::assertSame([23, 1], $parameters); diff --git a/tests/lib/Persistence/Legacy/Content/Type/MapperTest.php b/tests/lib/Persistence/Legacy/Content/Type/MapperTest.php index a70e788ecd..c6f7a0c672 100644 --- a/tests/lib/Persistence/Legacy/Content/Type/MapperTest.php +++ b/tests/lib/Persistence/Legacy/Content/Type/MapperTest.php @@ -471,7 +471,7 @@ protected function getNonConvertingMapper() ) )->will( self::returnCallback( - static function (): \Ibexa\Contracts\Core\Persistence\Content\Type\FieldDefinition { + static function (): FieldDefinition { return new FieldDefinition(); } ) diff --git a/tests/lib/Repository/Service/Mock/BookmarkTest.php b/tests/lib/Repository/Service/Mock/BookmarkTest.php index c0f0e1d095..e0903ed54c 100644 --- a/tests/lib/Repository/Service/Mock/BookmarkTest.php +++ b/tests/lib/Repository/Service/Mock/BookmarkTest.php @@ -68,7 +68,7 @@ public function testCreateBookmark(): void $this->bookmarkHandler ->expects($this->once()) ->method('create') - ->willReturnCallback(static function (CreateStruct $createStruct): \Ibexa\Contracts\Core\Persistence\Bookmark\Bookmark { + ->willReturnCallback(static function (CreateStruct $createStruct): Bookmark { self::assertEquals(self::LOCATION_ID, $createStruct->locationId); self::assertEquals(self::CURRENT_USER_ID, $createStruct->userId); @@ -199,7 +199,7 @@ public function testLoadBookmarks(): void $limit = 25; $expectedTotalCount = 10; - $expectedItems = array_map(function ($locationId): \Ibexa\Core\Repository\Values\Content\Location { + $expectedItems = array_map(function ($locationId): Location { return $this->createLocation($locationId); }, range(1, $expectedTotalCount)); $locationList = new LocationList(['totalCount' => $expectedTotalCount, 'locations' => $expectedItems]); diff --git a/tests/lib/Repository/Service/Mock/ContentTest.php b/tests/lib/Repository/Service/Mock/ContentTest.php index ce3022f1bf..55956bda9a 100644 --- a/tests/lib/Repository/Service/Mock/ContentTest.php +++ b/tests/lib/Repository/Service/Mock/ContentTest.php @@ -1896,7 +1896,7 @@ public function testCreateContentWithInvalidLanguage($mainLanguageCode, $structF ->with(self::isString()) ->will( self::returnCallback( - static function ($languageCode): \Ibexa\Contracts\Core\Repository\Values\Content\Language { + static function ($languageCode): Language { if ($languageCode === 'Klingon') { throw new NotFoundException('Language', 'Klingon'); } @@ -1963,7 +1963,7 @@ protected function assertForCreateContentContentValidationException( ->method('acceptValue') ->will( self::returnCallback( - static function ($valueString): \Ibexa\Tests\Core\Repository\Service\Mock\ValueStub { + static function ($valueString): ValueStub { return new ValueStub($valueString); } ) @@ -2152,7 +2152,7 @@ private function loadByLanguageCodeMock(\PHPUnit\Framework\MockObject\MockObject ->with(self::isString()) ->will( self::returnCallback( - static function (): \Ibexa\Contracts\Core\Repository\Values\Content\Language { + static function (): Language { return new Language(['id' => 4242]); } ) @@ -2472,7 +2472,7 @@ private function acceptFieldTypeValueMock(FieldType&MockObject $fieldTypeMock): ->method('acceptValue') ->will( self::returnCallback( - static function ($valueString): \Ibexa\Tests\Core\Repository\Service\Mock\ValueStub { + static function ($valueString): ValueStub { return new ValueStub($valueString); } ) @@ -2725,7 +2725,7 @@ public function testCreateContentWithLocationsDuplicateUnderParent(): void ->with(self::isString()) ->will( self::returnCallback( - static function (): \Ibexa\Contracts\Core\Repository\Values\Content\Language { + static function (): Language { return new Language(['id' => 4242]); } ) @@ -2736,7 +2736,7 @@ static function (): \Ibexa\Contracts\Core\Repository\Values\Content\Language { ->method('acceptValue') ->will( self::returnCallback( - static function ($valueString): \Ibexa\Tests\Core\Repository\Service\Mock\ValueStub { + static function ($valueString): ValueStub { return new ValueStub($valueString); } ) @@ -2809,7 +2809,7 @@ static function ($object) use ($contentCreateStruct): string { ->method('acceptValue') ->will( self::returnCallback( - static function ($valueString): \Ibexa\Tests\Core\Repository\Service\Mock\ValueStub { + static function ($valueString): ValueStub { return new ValueStub($valueString); } ) @@ -3292,7 +3292,7 @@ static function (Field $field): string { ->with(self::isString()) ->will( self::returnCallback( - static function (): \Ibexa\Contracts\Core\Repository\Values\Content\Language { + static function (): Language { return new Language(['id' => 4242]); } ) @@ -4820,7 +4820,7 @@ public function testUpdateContentWithInvalidLanguage($initialLanguageCode, $stru ->with(self::isString()) ->will( self::returnCallback( - static function ($languageCode): \Ibexa\Contracts\Core\Repository\Values\Content\Language { + static function ($languageCode): Language { if ($languageCode === 'Klingon') { throw new NotFoundException('Language', 'Klingon'); } @@ -4923,7 +4923,7 @@ static function ($value): SPIValue { ->with(self::isString()) ->will( self::returnCallback( - static function ($languageCode): \Ibexa\Contracts\Core\Repository\Values\Content\Language { + static function ($languageCode): Language { if ($languageCode === 'Klingon') { throw new NotFoundException('Language', 'Klingon'); } diff --git a/tests/lib/Repository/Service/Mock/UrlTest.php b/tests/lib/Repository/Service/Mock/UrlTest.php index b60f78d56d..d74b2cdbc6 100644 --- a/tests/lib/Repository/Service/Mock/UrlTest.php +++ b/tests/lib/Repository/Service/Mock/UrlTest.php @@ -351,11 +351,11 @@ public function testFindUsages($offset, $limit, ContentQuery $expectedQuery, arr $searchService ->expects(self::once()) ->method('findContentInfo') - ->willReturnCallback(static function ($query) use ($expectedQuery, $usages): \Ibexa\Contracts\Core\Repository\Values\Content\Search\SearchResult { + ->willReturnCallback(static function ($query) use ($expectedQuery, $usages): ContentSearchResults { self::assertEquals($expectedQuery, $query); return new ContentSearchResults([ - 'searchHits' => array_map(static function ($id): \Ibexa\Contracts\Core\Repository\Values\Content\Search\SearchHit { + 'searchHits' => array_map(static function ($id): SearchHit { return new SearchHit([ 'valueObject' => new ContentInfo([ 'id' => $id, diff --git a/tests/lib/Repository/Service/Mock/UserPreferenceTest.php b/tests/lib/Repository/Service/Mock/UserPreferenceTest.php index b9c8f1c321..79872f7587 100644 --- a/tests/lib/Repository/Service/Mock/UserPreferenceTest.php +++ b/tests/lib/Repository/Service/Mock/UserPreferenceTest.php @@ -55,7 +55,7 @@ public function testSetUserPreference(): void $this->userSPIPreferenceHandler ->expects($this->once()) ->method('setUserPreference') - ->willReturnCallback(static function (UserPreferenceSetStruct $setStruct): \Ibexa\Contracts\Core\Persistence\UserPreference\UserPreference { + ->willReturnCallback(static function (UserPreferenceSetStruct $setStruct): UserPreference { self::assertEquals(self::USER_PREFERENCE_NAME, $setStruct->name); self::assertEquals(self::USER_PREFERENCE_VALUE, $setStruct->value); self::assertEquals(self::CURRENT_USER_ID, $setStruct->userId); @@ -130,7 +130,7 @@ public function testLoadUserPreferences(): void $limit = 25; $expectedTotalCount = 10; - $expectedItems = array_map(function (): \Ibexa\Contracts\Core\Repository\Values\UserPreference\UserPreference { + $expectedItems = array_map(function (): APIUserPreference { return $this->createAPIUserPreference(); }, range(1, $expectedTotalCount)); @@ -144,7 +144,7 @@ public function testLoadUserPreferences(): void ->expects(self::once()) ->method('loadUserPreferences') ->with(self::CURRENT_USER_ID, $offset, $limit) - ->willReturn(array_map(static function ($locationId): \Ibexa\Contracts\Core\Persistence\UserPreference\UserPreference { + ->willReturn(array_map(static function ($locationId): UserPreference { return new UserPreference([ 'name' => 'setting', 'value' => 'value',