Skip to content

Commit aeaf0f7

Browse files
phpstan-botclaude
andcommitted
Use ParametersAcceptorSelector instead of hardcoded getVariants()[0]
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7ab0567 commit aeaf0f7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Type/Php/ReflectionGetAttributesMethodReturnTypeExtension.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use PhpParser\Node\Expr\MethodCall;
66
use PHPStan\Analyser\Scope;
77
use PHPStan\Reflection\MethodReflection;
8+
use PHPStan\Reflection\ParametersAcceptorSelector;
89
use PHPStan\Type\Accessory\AccessoryArrayListType;
910
use PHPStan\Type\ArrayType;
1011
use PHPStan\Type\DynamicMethodReturnTypeExtension;
@@ -45,14 +46,14 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method
4546
$argType = $scope->getType($methodCall->getArgs()[0]->value);
4647
$classType = $argType->getClassStringObjectType();
4748

48-
$valueType = $this->resolveReflectionAttributeType($methodReflection, $classType);
49+
$variant = ParametersAcceptorSelector::selectFromArgs($scope, $methodCall->getArgs(), $methodReflection->getVariants());
50+
$valueType = $this->resolveReflectionAttributeType($variant->getReturnType(), $classType);
4951

5052
return new IntersectionType([new ArrayType(IntegerRangeType::createAllGreaterThanOrEqualTo(0), $valueType), new AccessoryArrayListType()]);
5153
}
5254

53-
private function resolveReflectionAttributeType(MethodReflection $methodReflection, Type $classType): Type
55+
private function resolveReflectionAttributeType(Type $returnType, Type $classType): Type
5456
{
55-
$returnType = $methodReflection->getVariants()[0]->getReturnType();
5657
$nativeReflectionAttributeType = new ObjectType(ReflectionAttribute::class);
5758

5859
$valueTypes = [];

0 commit comments

Comments
 (0)