From 242cac29b6f9937849f3f4fdbbb492cfa9759b28 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Wed, 24 Jun 2026 23:13:57 +0200 Subject: [PATCH] [PHPStan] Fixed reported issues after PHPStan update (#767) For more details see https://github.com/ibexa/core/pull/767 Key changes: * Fixed `HostElement::match` SiteAccess matcher implementation * [Tests] Dropped a call to `parent::supportsLikeWildcard` in children of `SearchBaseIntegrationTest` * [Tests] Improved HostElementNormalizerTest * [Tests][PHPStan] Added `@phpstan-ignore new.resultUnused` to ContentTest * [PHPStan] Removed resolved issues from the baseline * [Tests][PHPStan] Added `@phpstan-ignore new.resultUnused` to UrlAliasTest --------- Co-Authored-By: Vidar Langseid --- phpstan-baseline-lte-8.3.neon | 6 ------ phpstan-baseline.neon | 2 +- .../MVC/Symfony/SiteAccess/Matcher/HostElement.php | 2 +- .../FieldType/DateAndTimeIntegrationTest.php | 7 +------ .../Core/Repository/FieldType/DateIntegrationTest.php | 7 +------ .../Repository/FieldType/RelationIntegrationTest.php | 7 +------ .../FieldType/RelationListIntegrationTest.php | 7 +------ .../Repository/FieldType/SelectionIntegrationTest.php | 4 +--- .../Core/Repository/FieldType/TimeIntegrationTest.php | 7 +------ .../Serializer/HostElementNormalizerTest.php | 11 +++++++---- tests/lib/Repository/Service/Mock/ContentTest.php | 1 + tests/lib/Repository/Service/Mock/UrlAliasTest.php | 1 + 12 files changed, 17 insertions(+), 45 deletions(-) diff --git a/phpstan-baseline-lte-8.3.neon b/phpstan-baseline-lte-8.3.neon index ab58eb7013..1ac105db1c 100644 --- a/phpstan-baseline-lte-8.3.neon +++ b/phpstan-baseline-lte-8.3.neon @@ -1,11 +1,5 @@ parameters: ignoreErrors: - - - message: '#^Call to new Ibexa\\Core\\Repository\\URLAliasService\(\) on a separate line has no effect\.$#' - identifier: new.resultUnused - count: 1 - path: tests/lib/Repository/Service/Mock/UrlAliasTest.php - - message: '#^Dead catch \- Ibexa\\Contracts\\Core\\Repository\\Exceptions\\NotFoundException is never thrown in the try block\.$#' identifier: catch.neverThrown diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 4adced4037..8425c66ed4 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -31239,7 +31239,7 @@ parameters: - message: '#^Offset ''scheme'' might not exist on array\{scheme\?\: string, host\: string, port\: int\<0, 65535\>, user\?\: string, pass\?\: string, path\?\: string, query\?\: string, fragment\?\: string\}\.$#' identifier: offsetAccess.notFound - count: 4 + count: 2 path: tests/bundle/Core/Routing/DefaultRouterTest.php - diff --git a/src/lib/MVC/Symfony/SiteAccess/Matcher/HostElement.php b/src/lib/MVC/Symfony/SiteAccess/Matcher/HostElement.php index 3a1bbb4427..839dc2ffe6 100644 --- a/src/lib/MVC/Symfony/SiteAccess/Matcher/HostElement.php +++ b/src/lib/MVC/Symfony/SiteAccess/Matcher/HostElement.php @@ -57,7 +57,7 @@ public function match() { $elements = $this->getHostElements(); - return isset($elements[$this->elementNumber - 1]) ? $elements[$this->elementNumber - 1] : false; + return $elements[$this->elementNumber - 1] ?? false; } public function getName() diff --git a/tests/integration/Core/Repository/FieldType/DateAndTimeIntegrationTest.php b/tests/integration/Core/Repository/FieldType/DateAndTimeIntegrationTest.php index 8b733ee841..b237f045e3 100644 --- a/tests/integration/Core/Repository/FieldType/DateAndTimeIntegrationTest.php +++ b/tests/integration/Core/Repository/FieldType/DateAndTimeIntegrationTest.php @@ -30,13 +30,8 @@ public function getTypeName() return 'ezdatetime'; } - /** - * {@inheritdoc} - */ - protected function supportsLikeWildcard($value) + protected function supportsLikeWildcard($value): bool { - parent::supportsLikeWildcard($value); - return false; } diff --git a/tests/integration/Core/Repository/FieldType/DateIntegrationTest.php b/tests/integration/Core/Repository/FieldType/DateIntegrationTest.php index 2fc2508f44..105ffb1a86 100644 --- a/tests/integration/Core/Repository/FieldType/DateIntegrationTest.php +++ b/tests/integration/Core/Repository/FieldType/DateIntegrationTest.php @@ -31,13 +31,8 @@ public function getTypeName() return 'ezdate'; } - /** - * {@inheritdoc} - */ - protected function supportsLikeWildcard($value) + protected function supportsLikeWildcard($value): bool { - parent::supportsLikeWildcard($value); - return false; } diff --git a/tests/integration/Core/Repository/FieldType/RelationIntegrationTest.php b/tests/integration/Core/Repository/FieldType/RelationIntegrationTest.php index a47546c4a7..bd7d90cbec 100644 --- a/tests/integration/Core/Repository/FieldType/RelationIntegrationTest.php +++ b/tests/integration/Core/Repository/FieldType/RelationIntegrationTest.php @@ -33,13 +33,8 @@ public function getTypeName() return 'ezobjectrelation'; } - /** - * {@inheritdoc} - */ - protected function supportsLikeWildcard($value) + protected function supportsLikeWildcard($value): bool { - parent::supportsLikeWildcard($value); - return false; } diff --git a/tests/integration/Core/Repository/FieldType/RelationListIntegrationTest.php b/tests/integration/Core/Repository/FieldType/RelationListIntegrationTest.php index 6f9f861d1b..f10425a475 100644 --- a/tests/integration/Core/Repository/FieldType/RelationListIntegrationTest.php +++ b/tests/integration/Core/Repository/FieldType/RelationListIntegrationTest.php @@ -33,13 +33,8 @@ public function getTypeName() return 'ezobjectrelationlist'; } - /** - * {@inheritdoc} - */ - protected function supportsLikeWildcard($value) + protected function supportsLikeWildcard($value): bool { - parent::supportsLikeWildcard($value); - return false; } diff --git a/tests/integration/Core/Repository/FieldType/SelectionIntegrationTest.php b/tests/integration/Core/Repository/FieldType/SelectionIntegrationTest.php index a8395a6f0b..e3445159fd 100644 --- a/tests/integration/Core/Repository/FieldType/SelectionIntegrationTest.php +++ b/tests/integration/Core/Repository/FieldType/SelectionIntegrationTest.php @@ -34,10 +34,8 @@ public function getTypeName() * * If Selection is improved to be able to index + search for string also with LegacySearch, then adapt this too. */ - protected function supportsLikeWildcard($value) + protected function supportsLikeWildcard($value): bool { - parent::supportsLikeWildcard($value); - return false; } diff --git a/tests/integration/Core/Repository/FieldType/TimeIntegrationTest.php b/tests/integration/Core/Repository/FieldType/TimeIntegrationTest.php index 87132350bf..ec45506055 100644 --- a/tests/integration/Core/Repository/FieldType/TimeIntegrationTest.php +++ b/tests/integration/Core/Repository/FieldType/TimeIntegrationTest.php @@ -29,13 +29,8 @@ public function getTypeName() return 'eztime'; } - /** - * {@inheritdoc} - */ - protected function supportsLikeWildcard($value) + protected function supportsLikeWildcard($value): bool { - parent::supportsLikeWildcard($value); - return false; } diff --git a/tests/lib/MVC/Symfony/Component/Serializer/HostElementNormalizerTest.php b/tests/lib/MVC/Symfony/Component/Serializer/HostElementNormalizerTest.php index e409df5a27..f620b78337 100644 --- a/tests/lib/MVC/Symfony/Component/Serializer/HostElementNormalizerTest.php +++ b/tests/lib/MVC/Symfony/Component/Serializer/HostElementNormalizerTest.php @@ -17,6 +17,9 @@ final class HostElementNormalizerTest extends TestCase { + /** + * @throws \Symfony\Component\Serializer\Exception\ExceptionInterface + */ public function testNormalization(): void { $normalizer = new HostElementNormalizer(); @@ -25,9 +28,9 @@ public function testNormalization(): void $matcher = new HostElement(2); // Set request and invoke match to initialize HostElement::$hostElements $matcher->setRequest(SimplifiedRequest::fromUrl('http://ibexa.dev/foo/bar')); - $matcher->match(); + self::assertSame('dev', $matcher->match()); - $this->assertEquals( + self::assertEquals( [ 'elementNumber' => 2, 'hostElements' => [ @@ -43,8 +46,8 @@ public function testSupportsNormalization(): void { $normalizer = new HostElementNormalizer(); - $this->assertTrue($normalizer->supportsNormalization($this->createMock(HostElement::class))); - $this->assertFalse($normalizer->supportsNormalization($this->createMock(Matcher::class))); + self::assertTrue($normalizer->supportsNormalization($this->createMock(HostElement::class))); + self::assertFalse($normalizer->supportsNormalization($this->createMock(Matcher::class))); } } diff --git a/tests/lib/Repository/Service/Mock/ContentTest.php b/tests/lib/Repository/Service/Mock/ContentTest.php index 339d23b203..bc7ceb4dfe 100644 --- a/tests/lib/Repository/Service/Mock/ContentTest.php +++ b/tests/lib/Repository/Service/Mock/ContentTest.php @@ -89,6 +89,7 @@ public function testConstructor(): void 'remove_archived_versions_on_publish' => true, ]; + /** @phpstan-ignore new.resultUnused */ new ContentService( $repositoryMock, $persistenceHandlerMock, diff --git a/tests/lib/Repository/Service/Mock/UrlAliasTest.php b/tests/lib/Repository/Service/Mock/UrlAliasTest.php index cb06533ddb..21e5557c78 100644 --- a/tests/lib/Repository/Service/Mock/UrlAliasTest.php +++ b/tests/lib/Repository/Service/Mock/UrlAliasTest.php @@ -54,6 +54,7 @@ public function testConstructor() { $repositoryMock = $this->getRepositoryMock(); + /** @phpstan-ignore new.resultUnused */ new UrlALiasService( $repositoryMock, $this->urlAliasHandler,