From 08ace380f01ba93806fa94f77a2fe9967ccfca33 Mon Sep 17 00:00:00 2001 From: Bartek Wajda Date: Tue, 23 Sep 2025 09:59:38 +0200 Subject: [PATCH 1/6] [CI] Fixed PHPStan issues --- phpstan-baseline.neon | 84 +++++++++++++++++-- .../SiteAccessGroupConfigResolver.php | 16 ++++ .../StaticSiteAccessConfigResolver.php | 9 ++ 3 files changed, 103 insertions(+), 6 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index a49ab96840..6b08a18e76 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -8316,6 +8316,12 @@ parameters: count: 1 path: src/contracts/Repository/Values/Content/Location.php + - + message: '#^Property Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Location\:\:\$pathString \(string\) on left side of \?\? is not nullable\.$#' + identifier: nullCoalesce.property + count: 1 + path: src/contracts/Repository/Values/Content/Location.php + - message: '#^Class Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\LocationList implements generic interface IteratorAggregate but does not specify its types\: TKey, TValue$#' identifier: missingType.generics @@ -24414,6 +24420,18 @@ parameters: count: 1 path: src/lib/Repository/LocationService.php + - + message: '#^Property Ibexa\\Contracts\\Core\\Repository\\Values\\ContentType\\ContentType\:\:\$defaultSortField \(int\) on left side of \?\? is not nullable\.$#' + identifier: nullCoalesce.property + count: 1 + path: src/lib/Repository/LocationService.php + + - + message: '#^Property Ibexa\\Contracts\\Core\\Repository\\Values\\ContentType\\ContentType\:\:\$defaultSortOrder \(int\) on left side of \?\? is not nullable\.$#' + identifier: nullCoalesce.property + count: 1 + path: src/lib/Repository/LocationService.php + - message: '#^Property Ibexa\\Core\\Repository\\LocationService\:\:\$repository \(Ibexa\\Core\\Repository\\Repository\) does not accept Ibexa\\Contracts\\Core\\Repository\\Repository\.$#' identifier: assign.propertyType @@ -25884,12 +25902,6 @@ parameters: count: 1 path: src/lib/Repository/Values/Content/Content.php - - - message: '#^Cannot access offset mixed on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Field\.$#' - identifier: offsetAccess.nonOffsetAccessible - count: 1 - path: src/lib/Repository/Values/Content/Content.php - - message: '#^Method Ibexa\\Core\\Repository\\Values\\Content\\Content\:\:__construct\(\) has parameter \$data with no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -74178,12 +74190,24 @@ parameters: count: 1 path: tests/lib/Repository/Values/Content/LocationTest.php + - + message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertTrue\(\) with true will always evaluate to true\.$#' + identifier: staticMethod.alreadyNarrowedType + count: 1 + path: tests/lib/Repository/Values/Content/LocationTest.php + - message: '#^Method Ibexa\\Tests\\Core\\Repository\\Values\\Content\\LocationTest\:\:assertPropertiesCorrect\(\) has no return type specified\.$#' identifier: missingType.return count: 1 path: tests/lib/Repository/Values/Content/LocationTest.php + - + message: '#^Property Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Location\:\:\$id \(int\) in isset\(\) is not nullable\.$#' + identifier: isset.property + count: 1 + path: tests/lib/Repository/Values/Content/LocationTest.php + - message: '#^Method Ibexa\\Tests\\Core\\Repository\\Values\\Content\\Query\\Aggregation\\RangeTest\:\:dataProviderForTestToString\(\) return type has no value type specified in iterable type iterable\.$#' identifier: missingType.iterableValue @@ -74244,6 +74268,12 @@ parameters: count: 1 path: tests/lib/Repository/Values/Content/TrashItemTest.php + - + message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertTrue\(\) with true will always evaluate to true\.$#' + identifier: staticMethod.alreadyNarrowedType + count: 1 + path: tests/lib/Repository/Values/Content/TrashItemTest.php + - message: '#^Method Ibexa\\Tests\\Core\\Repository\\Values\\Content\\TrashItemTest\:\:assertPropertiesCorrect\(\) has no return type specified\.$#' identifier: missingType.return @@ -74280,6 +74310,12 @@ parameters: count: 1 path: tests/lib/Repository/Values/Content/TrashItemTest.php + - + message: '#^Property Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Location\:\:\$id \(int\) in isset\(\) is not nullable\.$#' + identifier: isset.property + count: 1 + path: tests/lib/Repository/Values/Content/TrashItemTest.php + - message: '#^Method Ibexa\\Tests\\Core\\Repository\\Values\\ContentType\\ContentTypeDraftTest\:\:testObjectProperties\(\) has no return type specified\.$#' identifier: missingType.return @@ -74358,6 +74394,12 @@ parameters: count: 1 path: tests/lib/Repository/Values/ObjectState/ObjectStateGroupTest.php + - + message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertTrue\(\) with true will always evaluate to true\.$#' + identifier: staticMethod.alreadyNarrowedType + count: 1 + path: tests/lib/Repository/Values/ObjectState/ObjectStateGroupTest.php + - message: '#^Method Ibexa\\Tests\\Core\\Repository\\Values\\ObjectState\\ObjectStateGroupTest\:\:assertPropertiesCorrect\(\) has no return type specified\.$#' identifier: missingType.return @@ -74418,6 +74460,12 @@ parameters: count: 1 path: tests/lib/Repository/Values/ObjectState/ObjectStateGroupTest.php + - + message: '#^Property Ibexa\\Core\\Repository\\Values\\ObjectState\\ObjectStateGroup\:\:\$defaultLanguageCode \(string\) in isset\(\) is not nullable\.$#' + identifier: isset.property + count: 1 + path: tests/lib/Repository/Values/ObjectState/ObjectStateGroupTest.php + - message: '#^Access to an undefined property Ibexa\\Core\\Repository\\Values\\ObjectState\\ObjectState\:\:\$notDefined\.$#' identifier: property.notFound @@ -74532,6 +74580,12 @@ parameters: count: 1 path: tests/lib/Repository/Values/User/RoleTest.php + - + message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertTrue\(\) with true will always evaluate to true\.$#' + identifier: staticMethod.alreadyNarrowedType + count: 1 + path: tests/lib/Repository/Values/User/RoleTest.php + - message: '#^Method Ibexa\\Tests\\Core\\Repository\\Values\\User\\RoleTest\:\:assertPropertiesCorrect\(\) has no return type specified\.$#' identifier: missingType.return @@ -74568,6 +74622,12 @@ parameters: count: 1 path: tests/lib/Repository/Values/User/RoleTest.php + - + message: '#^Property Ibexa\\Contracts\\Core\\Repository\\Values\\User\\Role\:\:\$id \(int\) in isset\(\) is not nullable\.$#' + identifier: isset.property + count: 1 + path: tests/lib/Repository/Values/User/RoleTest.php + - message: '#^Access to an undefined property Ibexa\\Core\\Repository\\Values\\User\\UserGroup\:\:\$notDefined\.$#' identifier: property.notFound @@ -74628,6 +74688,12 @@ parameters: count: 1 path: tests/lib/Repository/Values/User/UserTest.php + - + message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertTrue\(\) with true will always evaluate to true\.$#' + identifier: staticMethod.alreadyNarrowedType + count: 1 + path: tests/lib/Repository/Values/User/UserTest.php + - message: '#^Method Ibexa\\Tests\\Core\\Repository\\Values\\User\\UserTest\:\:assertPropertiesCorrect\(\) has no return type specified\.$#' identifier: missingType.return @@ -74676,6 +74742,12 @@ parameters: count: 1 path: tests/lib/Repository/Values/User/UserTest.php + - + message: '#^Property Ibexa\\Contracts\\Core\\Repository\\Values\\User\\User\:\:\$login \(string\) in isset\(\) is not nullable\.$#' + identifier: isset.property + count: 1 + path: tests/lib/Repository/Values/User/UserTest.php + - message: '#^Method Ibexa\\Tests\\Core\\Search\\Common\\FieldValueMapper\\RemoteIdentifierMapperTest\:\:getDataForTestCanMap\(\) return type has no value type specified in iterable type iterable\.$#' identifier: missingType.iterableValue diff --git a/src/bundle/Core/DependencyInjection/Configuration/ConfigResolver/SiteAccessGroupConfigResolver.php b/src/bundle/Core/DependencyInjection/Configuration/ConfigResolver/SiteAccessGroupConfigResolver.php index f763914a19..3f9a6e601b 100644 --- a/src/bundle/Core/DependencyInjection/Configuration/ConfigResolver/SiteAccessGroupConfigResolver.php +++ b/src/bundle/Core/DependencyInjection/Configuration/ConfigResolver/SiteAccessGroupConfigResolver.php @@ -58,6 +58,10 @@ final public function getParameter(string $paramName, ?string $namespace = null, protected function resolverHasParameter(SiteAccess $siteAccess, string $paramName, string $namespace): bool { + if ($this->container === null) { + return false; + } + foreach ($siteAccess->groups as $group) { $groupScopeParamName = $this->resolveScopeRelativeParamName($paramName, $namespace, $group->getName()); if ($this->container->hasParameter($groupScopeParamName)) { @@ -70,6 +74,10 @@ protected function resolverHasParameter(SiteAccess $siteAccess, string $paramNam protected function resolverHasParameterForGroup(SiteAccessGroup $siteAccessGroup, string $paramName, string $namespace): bool { + if ($this->container === null) { + return false; + } + $groupScopeParamName = $this->resolveScopeRelativeParamName($paramName, $namespace, $siteAccessGroup->getName()); return $this->container->hasParameter($groupScopeParamName); @@ -77,6 +85,10 @@ protected function resolverHasParameterForGroup(SiteAccessGroup $siteAccessGroup protected function getParameterFromResolver(SiteAccess $siteAccess, string $paramName, string $namespace) { + if ($this->container === null) { + throw new ParameterNotFoundException($paramName, $namespace, []); + } + $triedScopes = []; foreach ($siteAccess->groups as $group) { @@ -93,6 +105,10 @@ protected function getParameterFromResolver(SiteAccess $siteAccess, string $para protected function getParameterFromResolverForGroup(SiteAccessGroup $siteAccessGroup, string $paramName, string $namespace) { + if ($this->container === null) { + throw new ParameterNotFoundException($paramName, $namespace, [$siteAccessGroup]); + } + $groupScopeParamName = $this->resolveScopeRelativeParamName($paramName, $namespace, $siteAccessGroup->getName()); if (!$this->container->hasParameter($groupScopeParamName)) { diff --git a/src/bundle/Core/DependencyInjection/Configuration/ConfigResolver/StaticSiteAccessConfigResolver.php b/src/bundle/Core/DependencyInjection/Configuration/ConfigResolver/StaticSiteAccessConfigResolver.php index ea39515a54..c399658c64 100644 --- a/src/bundle/Core/DependencyInjection/Configuration/ConfigResolver/StaticSiteAccessConfigResolver.php +++ b/src/bundle/Core/DependencyInjection/Configuration/ConfigResolver/StaticSiteAccessConfigResolver.php @@ -24,6 +24,10 @@ class StaticSiteAccessConfigResolver extends SiteAccessConfigResolver protected function resolverHasParameter(SiteAccess $siteAccess, string $paramName, string $namespace): bool { + if ($this->container === null) { + return false; + } + return $this->container->hasParameter( $this->resolveScopeRelativeParamName($paramName, $namespace, $siteAccess->name) ); @@ -32,6 +36,11 @@ protected function resolverHasParameter(SiteAccess $siteAccess, string $paramNam protected function getParameterFromResolver(SiteAccess $siteAccess, string $paramName, string $namespace) { $scopeRelativeParamName = $this->getScopeRelativeParamName($paramName, $namespace, $siteAccess->name); + + if ($this->container === null) { + throw new ParameterNotFoundException($scopeRelativeParamName, $namespace, []); + } + if ($this->container->hasParameter($scopeRelativeParamName)) { return $this->container->getParameter($scopeRelativeParamName); } From b9120880cf984b154597250a6930986e25e67a1e Mon Sep 17 00:00:00 2001 From: Bartek Wajda Date: Tue, 23 Sep 2025 10:06:30 +0200 Subject: [PATCH 2/6] [CI] Baseline --- phpstan-baseline.neon | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 6b08a18e76..183634646d 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -10692,6 +10692,12 @@ parameters: count: 1 path: src/lib/FieldType/BinaryBase/Type.php + - + message: '#^Property Ibexa\\Core\\FieldType\\BinaryBase\\Value\:\:\$id \(string\) in isset\(\) is not nullable\.$#' + identifier: isset.property + count: 1 + path: src/lib/FieldType/BinaryBase/Type.php + - message: '#^Method Ibexa\\Core\\FieldType\\BinaryBase\\Value\:\:__construct\(\) has parameter \$fileData with no value type specified in iterable type array\.$#' identifier: missingType.iterableValue From 35239215b27de1a6497ccf29c01e559f99f275b7 Mon Sep 17 00:00:00 2001 From: Bartek Wajda Date: Tue, 23 Sep 2025 10:46:50 +0200 Subject: [PATCH 3/6] [CI] Baseline --- phpstan-baseline.neon | 6 ------ src/lib/FieldType/BinaryBase/Value.php | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 183634646d..6b08a18e76 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -10692,12 +10692,6 @@ parameters: count: 1 path: src/lib/FieldType/BinaryBase/Type.php - - - message: '#^Property Ibexa\\Core\\FieldType\\BinaryBase\\Value\:\:\$id \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 1 - path: src/lib/FieldType/BinaryBase/Type.php - - message: '#^Method Ibexa\\Core\\FieldType\\BinaryBase\\Value\:\:__construct\(\) has parameter \$fileData with no value type specified in iterable type array\.$#' identifier: missingType.iterableValue diff --git a/src/lib/FieldType/BinaryBase/Value.php b/src/lib/FieldType/BinaryBase/Value.php index e3b1608e9f..f3a1a69b6b 100644 --- a/src/lib/FieldType/BinaryBase/Value.php +++ b/src/lib/FieldType/BinaryBase/Value.php @@ -12,7 +12,7 @@ * Base value for binary field types. * * @property string $path Used for BC with 5.0 (EZP-20948). Equivalent to $id. - * @property-read string $id Unique file ID, set by storage. Read only since 5.3 (EZP-22808). + * @property-read string|null $id Unique file ID, set by storage. Read only since 5.3 (EZP-22808). */ abstract class Value extends BaseValue { From c084151115354fabed7fb3bc2fd0ca623e2f9afd Mon Sep 17 00:00:00 2001 From: Bartek Wajda Date: Tue, 23 Sep 2025 10:48:18 +0200 Subject: [PATCH 4/6] [CI] Review remarks --- .../ConfigResolver/SiteAccessGroupConfigResolver.php | 5 +++-- .../ConfigResolver/StaticSiteAccessConfigResolver.php | 9 +++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/bundle/Core/DependencyInjection/Configuration/ConfigResolver/SiteAccessGroupConfigResolver.php b/src/bundle/Core/DependencyInjection/Configuration/ConfigResolver/SiteAccessGroupConfigResolver.php index 3f9a6e601b..aa143faccb 100644 --- a/src/bundle/Core/DependencyInjection/Configuration/ConfigResolver/SiteAccessGroupConfigResolver.php +++ b/src/bundle/Core/DependencyInjection/Configuration/ConfigResolver/SiteAccessGroupConfigResolver.php @@ -11,6 +11,7 @@ use Ibexa\Core\MVC\Exception\ParameterNotFoundException; use Ibexa\Core\MVC\Symfony\SiteAccess; use Ibexa\Core\MVC\Symfony\SiteAccessGroup; +use LogicException; use Symfony\Component\DependencyInjection\ContainerAwareTrait; /** @@ -59,7 +60,7 @@ final public function getParameter(string $paramName, ?string $namespace = null, protected function resolverHasParameter(SiteAccess $siteAccess, string $paramName, string $namespace): bool { if ($this->container === null) { - return false; + throw new LogicException('Container is not set.'); } foreach ($siteAccess->groups as $group) { @@ -86,7 +87,7 @@ protected function resolverHasParameterForGroup(SiteAccessGroup $siteAccessGroup protected function getParameterFromResolver(SiteAccess $siteAccess, string $paramName, string $namespace) { if ($this->container === null) { - throw new ParameterNotFoundException($paramName, $namespace, []); + throw new LogicException('Container is not set.'); } $triedScopes = []; diff --git a/src/bundle/Core/DependencyInjection/Configuration/ConfigResolver/StaticSiteAccessConfigResolver.php b/src/bundle/Core/DependencyInjection/Configuration/ConfigResolver/StaticSiteAccessConfigResolver.php index c399658c64..6c377999e9 100644 --- a/src/bundle/Core/DependencyInjection/Configuration/ConfigResolver/StaticSiteAccessConfigResolver.php +++ b/src/bundle/Core/DependencyInjection/Configuration/ConfigResolver/StaticSiteAccessConfigResolver.php @@ -11,6 +11,7 @@ use Ibexa\Core\MVC\Exception\ParameterNotFoundException; use Ibexa\Core\MVC\Symfony\SiteAccess; use Ibexa\Core\MVC\Symfony\SiteAccess\Provider\StaticSiteAccessProvider; +use LogicException; use Symfony\Component\DependencyInjection\ContainerAwareTrait; /** @@ -25,7 +26,7 @@ class StaticSiteAccessConfigResolver extends SiteAccessConfigResolver protected function resolverHasParameter(SiteAccess $siteAccess, string $paramName, string $namespace): bool { if ($this->container === null) { - return false; + throw new LogicException('Container is not set.'); } return $this->container->hasParameter( @@ -35,12 +36,12 @@ protected function resolverHasParameter(SiteAccess $siteAccess, string $paramNam protected function getParameterFromResolver(SiteAccess $siteAccess, string $paramName, string $namespace) { - $scopeRelativeParamName = $this->getScopeRelativeParamName($paramName, $namespace, $siteAccess->name); - if ($this->container === null) { - throw new ParameterNotFoundException($scopeRelativeParamName, $namespace, []); + throw new LogicException('Container is not set.'); } + $scopeRelativeParamName = $this->getScopeRelativeParamName($paramName, $namespace, $siteAccess->name); + if ($this->container->hasParameter($scopeRelativeParamName)) { return $this->container->getParameter($scopeRelativeParamName); } From b94ddc81a29721aef66e7beb02ef413d70e1a1a5 Mon Sep 17 00:00:00 2001 From: Bartek Wajda Date: Tue, 23 Sep 2025 10:51:14 +0200 Subject: [PATCH 5/6] [CI] CS --- .../ConfigResolver/StaticSiteAccessConfigResolver.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/bundle/Core/DependencyInjection/Configuration/ConfigResolver/StaticSiteAccessConfigResolver.php b/src/bundle/Core/DependencyInjection/Configuration/ConfigResolver/StaticSiteAccessConfigResolver.php index 6c377999e9..95cb51c281 100644 --- a/src/bundle/Core/DependencyInjection/Configuration/ConfigResolver/StaticSiteAccessConfigResolver.php +++ b/src/bundle/Core/DependencyInjection/Configuration/ConfigResolver/StaticSiteAccessConfigResolver.php @@ -41,7 +41,6 @@ protected function getParameterFromResolver(SiteAccess $siteAccess, string $para } $scopeRelativeParamName = $this->getScopeRelativeParamName($paramName, $namespace, $siteAccess->name); - if ($this->container->hasParameter($scopeRelativeParamName)) { return $this->container->getParameter($scopeRelativeParamName); } From 39281af2ea8a4b1a33b113e27781f05497676cc7 Mon Sep 17 00:00:00 2001 From: Bartek Wajda Date: Tue, 23 Sep 2025 10:54:53 +0200 Subject: [PATCH 6/6] [CI] CS --- .../ConfigResolver/SiteAccessGroupConfigResolver.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bundle/Core/DependencyInjection/Configuration/ConfigResolver/SiteAccessGroupConfigResolver.php b/src/bundle/Core/DependencyInjection/Configuration/ConfigResolver/SiteAccessGroupConfigResolver.php index aa143faccb..bb481f7eca 100644 --- a/src/bundle/Core/DependencyInjection/Configuration/ConfigResolver/SiteAccessGroupConfigResolver.php +++ b/src/bundle/Core/DependencyInjection/Configuration/ConfigResolver/SiteAccessGroupConfigResolver.php @@ -76,7 +76,7 @@ protected function resolverHasParameter(SiteAccess $siteAccess, string $paramNam protected function resolverHasParameterForGroup(SiteAccessGroup $siteAccessGroup, string $paramName, string $namespace): bool { if ($this->container === null) { - return false; + throw new LogicException('Container is not set.'); } $groupScopeParamName = $this->resolveScopeRelativeParamName($paramName, $namespace, $siteAccessGroup->getName()); @@ -107,7 +107,7 @@ protected function getParameterFromResolver(SiteAccess $siteAccess, string $para protected function getParameterFromResolverForGroup(SiteAccessGroup $siteAccessGroup, string $paramName, string $namespace) { if ($this->container === null) { - throw new ParameterNotFoundException($paramName, $namespace, [$siteAccessGroup]); + throw new LogicException('Container is not set.'); } $groupScopeParamName = $this->resolveScopeRelativeParamName($paramName, $namespace, $siteAccessGroup->getName());