Skip to content

Commit

Permalink
Bump to PHPStan 1.12.5 and Fix deprecated ParametersAcceptorSelector:…
Browse files Browse the repository at this point in the history
…:selectSingle() (#6329)

* Fix deprecated ParametersAcceptorSelector::selectSingle() since PHPStan 1.12.5

* [ci-review] Rector Rectify

* bump phpstan

---------

Co-authored-by: GitHub Action <actions@github.com>
  • Loading branch information
samsonasik and actions-user committed Sep 26, 2024
1 parent 06622fe commit f619d86
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 17 deletions.
2 changes: 1 addition & 1 deletion build/target-repository/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"require": {
"php": "^7.2|^8.0",
"phpstan/phpstan": "^1.12.4"
"phpstan/phpstan": "^1.12.5"
},
"autoload": {
"files": [
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"ocramius/package-versions": "^2.9",
"ondram/ci-detector": "^4.2",
"phpstan/phpdoc-parser": "^1.32.0",
"phpstan/phpstan": "^1.12.4",
"phpstan/phpstan": "^1.12.5",
"react/event-loop": "^1.5",
"react/promise": "^3.2",
"react/socket": "^1.15",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ private function resolveExceptionArgumentPosition(Name $exceptionName): ?int
}

$extendedMethodReflection = $classReflection->getConstructor();
$parametersAcceptorWithPhpDocs = ParametersAcceptorSelector::selectSingle(
$parametersAcceptorWithPhpDocs = ParametersAcceptorSelector::combineAcceptors(
$extendedMethodReflection->getVariants()
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private function resolveMethodCallProvidingType(
$methodReflections = $this->getClassMethodReflections($classReflection);

foreach ($methodReflections as $methodReflection) {
$functionVariant = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants());
$functionVariant = ParametersAcceptorSelector::combineAcceptors($methodReflection->getVariants());
$returnType = $functionVariant->getReturnType();

if (! $this->isMatchingType($returnType, $objectType)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use PhpParser\Node\Stmt\ClassMethod;
use PHPStan\Reflection\MethodReflection;
use PHPStan\Reflection\ParametersAcceptorSelector;
use PHPStan\Reflection\ParametersAcceptorWithPhpDocs;
use PHPStan\Type\MixedType;
use PHPStan\Type\ObjectType;
use PHPStan\Type\Type;
Expand Down Expand Up @@ -135,11 +134,7 @@ private function getReturnTypeRecursive(ClassMethod $classMethod): ?Type
return null;
}

$parameterAcceptor = ParametersAcceptorSelector::selectSingle($parentMethodReflection->getVariants());

if (! $parameterAcceptor instanceof ParametersAcceptorWithPhpDocs) {
return null;
}
$parameterAcceptor = ParametersAcceptorSelector::combineAcceptors($parentMethodReflection->getVariants());

$parentReturnType = $parameterAcceptor->getNativeReturnType();
if (! $parentReturnType instanceof MixedType) {
Expand Down
2 changes: 1 addition & 1 deletion src/FamilyTree/NodeAnalyzer/ClassChildAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function resolveParentClassMethodReturnType(ClassReflection $classReflect
}

foreach ($parentClassMethods as $parentClassMethod) {
$parametersAcceptor = ParametersAcceptorSelector::selectSingle($parentClassMethod->getVariants());
$parametersAcceptor = ParametersAcceptorSelector::combineAcceptors($parentClassMethod->getVariants());
$nativeReturnType = $parametersAcceptor->getNativeReturnType();

if (! $nativeReturnType instanceof MixedType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ private function resolveClassContextType(
}

$extendedMethodReflection = $classReflection->getMethod(MethodName::CONSTRUCT, $scope);
$parametersAcceptorWithPhpDocs = ParametersAcceptorSelector::selectSingle(
$parametersAcceptorWithPhpDocs = ParametersAcceptorSelector::combineAcceptors(
$extendedMethodReflection->getVariants()
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ public static function select(
return ParametersAcceptorSelector::combineAcceptors($variants);
}

if ($node->isFirstClassCallable()) {
return ParametersAcceptorSelector::selectSingle($variants);
}

return ParametersAcceptorSelector::selectFromArgs($scope, $node->getArgs(), $variants);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private function resolveConstructorParameterReflections(ClassReflection $classRe
{
$extendedMethodReflection = $classReflection->getConstructor();

$parametersAcceptorWithPhpDocs = ParametersAcceptorSelector::selectSingle(
$parametersAcceptorWithPhpDocs = ParametersAcceptorSelector::combineAcceptors(
$extendedMethodReflection->getVariants()
);

Expand Down

0 comments on commit f619d86

Please sign in to comment.