From 0ccccb19bfe6fa72f0129b903fd468dd566fc050 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Thu, 26 Sep 2024 10:20:38 +0200 Subject: [PATCH] `selectSingle()` is being deprecated --- composer.json | 2 +- .../TypeHintDeprecatedInClassMethodSignatureRule.php | 6 ++---- .../TypeHintDeprecatedInFunctionSignatureRule.php | 6 ++---- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index fb6ad0b..bd160c2 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ ], "require": { "php": "^7.2 || ^8.0", - "phpstan/phpstan": "^1.12" + "phpstan/phpstan": "^1.12.5" }, "require-dev": { "php-parallel-lint/php-parallel-lint": "^1.2", diff --git a/src/Rules/Deprecations/TypeHintDeprecatedInClassMethodSignatureRule.php b/src/Rules/Deprecations/TypeHintDeprecatedInClassMethodSignatureRule.php index 5bbcf13..3407ab0 100644 --- a/src/Rules/Deprecations/TypeHintDeprecatedInClassMethodSignatureRule.php +++ b/src/Rules/Deprecations/TypeHintDeprecatedInClassMethodSignatureRule.php @@ -5,7 +5,6 @@ use PhpParser\Node; use PHPStan\Analyser\Scope; use PHPStan\Node\InClassMethodNode; -use PHPStan\Reflection\ParametersAcceptorSelector; use PHPStan\Rules\Rule; use PHPStan\Rules\RuleErrorBuilder; use function sprintf; @@ -41,10 +40,9 @@ public function processNode(Node $node, Scope $scope): array } $method = $node->getMethodReflection(); - $methodSignature = ParametersAcceptorSelector::selectSingle($method->getVariants()); $errors = []; - foreach ($methodSignature->getParameters() as $parameter) { + foreach ($method->getParameters() as $parameter) { $deprecatedClasses = $this->deprecatedClassHelper->filterDeprecatedClasses($parameter->getType()->getReferencedClasses()); foreach ($deprecatedClasses as $deprecatedClass) { if ($method->getDeclaringClass()->isAnonymous()) { @@ -70,7 +68,7 @@ public function processNode(Node $node, Scope $scope): array } } - $deprecatedClasses = $this->deprecatedClassHelper->filterDeprecatedClasses($methodSignature->getReturnType()->getReferencedClasses()); + $deprecatedClasses = $this->deprecatedClassHelper->filterDeprecatedClasses($method->getReturnType()->getReferencedClasses()); foreach ($deprecatedClasses as $deprecatedClass) { if ($method->getDeclaringClass()->isAnonymous()) { $errors[] = RuleErrorBuilder::message(sprintf( diff --git a/src/Rules/Deprecations/TypeHintDeprecatedInFunctionSignatureRule.php b/src/Rules/Deprecations/TypeHintDeprecatedInFunctionSignatureRule.php index 9d39bf0..af595ab 100644 --- a/src/Rules/Deprecations/TypeHintDeprecatedInFunctionSignatureRule.php +++ b/src/Rules/Deprecations/TypeHintDeprecatedInFunctionSignatureRule.php @@ -5,7 +5,6 @@ use PhpParser\Node; use PHPStan\Analyser\Scope; use PHPStan\Node\InFunctionNode; -use PHPStan\Reflection\ParametersAcceptorSelector; use PHPStan\Rules\Rule; use PHPStan\Rules\RuleErrorBuilder; use PHPStan\ShouldNotHappenException; @@ -45,10 +44,9 @@ public function processNode(Node $node, Scope $scope): array if ($function === null) { throw new ShouldNotHappenException(); } - $functionSignature = ParametersAcceptorSelector::selectSingle($function->getVariants()); $errors = []; - foreach ($functionSignature->getParameters() as $parameter) { + foreach ($function->getParameters() as $parameter) { $deprecatedClasses = $this->deprecatedClassHelper->filterDeprecatedClasses($parameter->getType()->getReferencedClasses()); foreach ($deprecatedClasses as $deprecatedClass) { $errors[] = RuleErrorBuilder::message(sprintf( @@ -62,7 +60,7 @@ public function processNode(Node $node, Scope $scope): array } } - $deprecatedClasses = $this->deprecatedClassHelper->filterDeprecatedClasses($functionSignature->getReturnType()->getReferencedClasses()); + $deprecatedClasses = $this->deprecatedClassHelper->filterDeprecatedClasses($function->getReturnType()->getReferencedClasses()); foreach ($deprecatedClasses as $deprecatedClass) { $errors[] = RuleErrorBuilder::message(sprintf( 'Return type of function %s() has typehint with deprecated %s %s%s',