From 392bbe7be54b00fbe945fede6a8ef543216f3b9c Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Thu, 26 Sep 2024 10:20:38 +0200 Subject: [PATCH] Updates for PHPStan 2.0 changes --- .../TypeHintDeprecatedInClassMethodSignatureRule.php | 6 ++---- .../TypeHintDeprecatedInFunctionSignatureRule.php | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Rules/Deprecations/TypeHintDeprecatedInClassMethodSignatureRule.php b/src/Rules/Deprecations/TypeHintDeprecatedInClassMethodSignatureRule.php index 0051f02..cb747aa 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; @@ -39,10 +38,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()) { @@ -68,7 +66,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 854ba06..99f6e20 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; @@ -43,10 +42,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( @@ -60,7 +58,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',