diff --git a/.changeset/few-bees-drum.md b/.changeset/few-bees-drum.md new file mode 100644 index 0000000..cb39292 --- /dev/null +++ b/.changeset/few-bees-drum.md @@ -0,0 +1,5 @@ +--- +"@cambis/silverstan": minor +--- + +PHPStan 2.2 upgrade diff --git a/build/composer-php-74.json b/build/composer-php-74.json index e13dd8b..11dc3f8 100644 --- a/build/composer-php-74.json +++ b/build/composer-php-74.json @@ -18,7 +18,7 @@ "php": "^7.4 || ^8.0", "ext-tokenizer": "*", "composer/class-map-generator": "^1.5", - "phpstan/phpstan": "^2.1.28", + "phpstan/phpstan": "^2.2.1", "silverstripe/config": "^1.4 || ^2.0 || ^3.0" }, "minimum-stability": "dev", diff --git a/composer.json b/composer.json index e6fcee0..659f0fd 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "php": "^8.3", "ext-tokenizer": "*", "composer/class-map-generator": "^1.5", - "phpstan/phpstan": "^2.1.28", + "phpstan/phpstan": "^2.2.1", "silverstripe/config": "^1.4 || ^2.0 || ^3.0" }, "require-dev": { diff --git a/src/ConfigurationResolver/ConfigurationResolver.php b/src/ConfigurationResolver/ConfigurationResolver.php index f6bea17..9895b9b 100644 --- a/src/ConfigurationResolver/ConfigurationResolver.php +++ b/src/ConfigurationResolver/ConfigurationResolver.php @@ -107,7 +107,11 @@ public function resolveExtensionClassName(string $extensionName): ?string return null; } - $resolved = $matches[1]; + $resolved = $matches[1] ?? null; + + if ($resolved === null || $resolved === '') { + return null; + } if (!$this->reflectionProvider->hasClass($resolved)) { return null; diff --git a/src/ReflectionResolver/ReflectionResolver/ExtensionMethodReflectionResolver.php b/src/ReflectionResolver/ReflectionResolver/ExtensionMethodReflectionResolver.php index 776cbf7..818d5e4 100644 --- a/src/ReflectionResolver/ReflectionResolver/ExtensionMethodReflectionResolver.php +++ b/src/ReflectionResolver/ReflectionResolver/ExtensionMethodReflectionResolver.php @@ -50,7 +50,7 @@ public function resolve(ClassReflection $classReflection): array } /** @var array $extensions */ - $extensions = array_unique($extensions); + $extensions = array_unique($extensions); // @phpstan-ignore argument.type foreach ($extensions as $extension) { if ($extension === null) { diff --git a/src/Rule/StaticCall/RequireInjectableCreateToMatchConstructorSignatureRule.php b/src/Rule/StaticCall/RequireInjectableCreateToMatchConstructorSignatureRule.php index b1c6de9..82c614a 100644 --- a/src/Rule/StaticCall/RequireInjectableCreateToMatchConstructorSignatureRule.php +++ b/src/Rule/StaticCall/RequireInjectableCreateToMatchConstructorSignatureRule.php @@ -102,6 +102,10 @@ public function processNode(Node $node, Scope $scope): array 'Return type of call to method ' . $methodName . ' contains unresolvable type.', '%s of method ' . $methodName . ' contains unresolvable type.', 'Method ' . $methodName . " invoked with %s, but it's not allowed because of @no-named-arguments.", + 'Constant %s is not allowed for %s of method ' . $methodName . ' constructor.', + 'Constants %s cannot be combined for %s of method ' . $methodName . ' constructor.', + 'Combining constants with | is not allowed for %s of method ' . $methodName . ' constructor.', + null, ); } }