Skip to content

Commit aaa75bb

Browse files
committed
Updated PHPStan
1 parent b5b772c commit aaa75bb

3 files changed

+10
-3
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"php": "~7.1",
1414
"phpstan/phpstan": "^0.10",
1515
"doctrine/common": "^2.7",
16-
"doctrine/orm": "^2.5"
16+
"doctrine/orm": "^2.5",
17+
"nikic/php-parser": "^4.0"
1718
},
1819
"require-dev": {
1920
"consistence/coding-standard": "^3.0.1",

src/Type/Doctrine/EntityManagerGetRepositoryDynamicReturnTypeExtension.php

Lines changed: 4 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\Type\Constant\ConstantStringType;
910
use PHPStan\Type\MixedType;
1011
use PHPStan\Type\Type;
@@ -37,7 +38,9 @@ public function getTypeFromMethodCall(
3738
): Type
3839
{
3940
if (count($methodCall->args) === 0) {
40-
return $methodReflection->getReturnType();
41+
return ParametersAcceptorSelector::selectSingle(
42+
$methodReflection->getVariants()
43+
)->getReturnType();
4144
}
4245
$argType = $scope->getType($methodCall->args[0]->value);
4346
if (!$argType instanceof ConstantStringType) {

src/Type/Doctrine/ObjectManagerMergeDynamicReturnTypeExtension.php

Lines changed: 4 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\Type\Type;
910

1011
class ObjectManagerMergeDynamicReturnTypeExtension implements \PHPStan\Type\DynamicMethodReturnTypeExtension
@@ -27,7 +28,9 @@ public function getTypeFromMethodCall(
2728
): Type
2829
{
2930
if (count($methodCall->args) === 0) {
30-
return $methodReflection->getReturnType();
31+
return ParametersAcceptorSelector::selectSingle(
32+
$methodReflection->getVariants()
33+
)->getReturnType();
3134
}
3235

3336
return $scope->getType($methodCall->args[0]->value);

0 commit comments

Comments
 (0)