Skip to content

Commit 756fd83

Browse files
committed
Updated PHPStan
1 parent 8bfae17 commit 756fd83

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

src/Type/Symfony/ContainerInterfaceDynamicReturnTypeExtension.php

Lines changed: 2 additions & 1 deletion
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\Symfony\ServiceMap;
910
use PHPStan\Type\DynamicMethodReturnTypeExtension;
1011
use PHPStan\Type\ObjectType;
@@ -43,7 +44,7 @@ public function getTypeFromMethodCall(
4344
return new ObjectType($service['class'] ?? $service['id']);
4445
}
4546
}
46-
return $methodReflection->getReturnType();
47+
return ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
4748
}
4849

4950
}

src/Type/Symfony/ControllerDynamicReturnTypeExtension.php

Lines changed: 2 additions & 1 deletion
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\Symfony\ServiceMap;
910
use PHPStan\Type\DynamicMethodReturnTypeExtension;
1011
use PHPStan\Type\ObjectType;
@@ -43,7 +44,7 @@ public function getTypeFromMethodCall(
4344
return new ObjectType($service['class'] ?? $service['id']);
4445
}
4546
}
46-
return $methodReflection->getReturnType();
47+
return ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
4748
}
4849

4950
}

tests/Type/Symfony/ContainerInterfaceDynamicReturnTypeExtensionTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use PhpParser\Node\Scalar\String_;
99
use PHPStan\Analyser\Scope;
1010
use PHPStan\Reflection\MethodReflection;
11+
use PHPStan\Reflection\ParametersAcceptor;
1112
use PHPStan\Symfony\ServiceMap;
1213
use PHPStan\Type\DynamicMethodReturnTypeExtension;
1314
use PHPStan\Type\ObjectType;
@@ -71,8 +72,10 @@ public function getTypeFromMethodCallProvider(): array
7172
{
7273
$notFoundType = $this->createMock(Type::class);
7374

75+
$parametersAcceptorNotFound = $this->createMock(ParametersAcceptor::class);
76+
$parametersAcceptorNotFound->expects(self::once())->method('getReturnType')->willReturn($notFoundType);
7477
$methodReflectionNotFound = $this->createMock(MethodReflection::class);
75-
$methodReflectionNotFound->expects(self::once())->method('getReturnType')->willReturn($notFoundType);
78+
$methodReflectionNotFound->expects(self::once())->method('getVariants')->willReturn([$parametersAcceptorNotFound]);
7679

7780
return [
7881
'found' => [

tests/Type/Symfony/ControllerDynamicReturnTypeExtensionTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use PhpParser\Node\Scalar\String_;
99
use PHPStan\Analyser\Scope;
1010
use PHPStan\Reflection\MethodReflection;
11+
use PHPStan\Reflection\ParametersAcceptor;
1112
use PHPStan\Symfony\ServiceMap;
1213
use PHPStan\Type\DynamicMethodReturnTypeExtension;
1314
use PHPStan\Type\ObjectType;
@@ -71,8 +72,10 @@ public function getTypeFromMethodCallProvider(): array
7172
{
7273
$notFoundType = $this->createMock(Type::class);
7374

75+
$parametersAcceptorNotFound = $this->createMock(ParametersAcceptor::class);
76+
$parametersAcceptorNotFound->expects(self::once())->method('getReturnType')->willReturn($notFoundType);
7477
$methodReflectionNotFound = $this->createMock(MethodReflection::class);
75-
$methodReflectionNotFound->expects(self::once())->method('getReturnType')->willReturn($notFoundType);
78+
$methodReflectionNotFound->expects(self::once())->method('getVariants')->willReturn([$parametersAcceptorNotFound]);
7679

7780
return [
7881
'found' => [

0 commit comments

Comments
 (0)