Skip to content

Commit 22c75d9

Browse files
committed
Updated PHPStan
1 parent 10efc47 commit 22c75d9

File tree

5 files changed

+13
-5
lines changed

5 files changed

+13
-5
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
},
1212
"require": {
1313
"php": "~7.1",
14-
"phpstan/phpstan": "^0.10"
14+
"phpstan/phpstan": "^0.10",
15+
"nikic/php-parser": "^4.0"
1516
},
1617
"require-dev": {
1718
"beberlei/assert": "^2.9.5",

src/Type/BeberleiAssert/AssertThatDynamicMethodReturnTypeExtension.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace PHPStan\Type\BeberleiAssert;
44

5+
use PHPStan\Reflection\ParametersAcceptorSelector;
6+
57
class AssertThatDynamicMethodReturnTypeExtension implements \PHPStan\Type\DynamicStaticMethodReturnTypeExtension
68
{
79

@@ -22,7 +24,9 @@ public function isStaticMethodSupported(\PHPStan\Reflection\MethodReflection $me
2224
public function getTypeFromStaticMethodCall(\PHPStan\Reflection\MethodReflection $methodReflection, \PhpParser\Node\Expr\StaticCall $methodCall, \PHPStan\Analyser\Scope $scope): \PHPStan\Type\Type
2325
{
2426
if (count($methodCall->args) === 0) {
25-
return $methodReflection->getReturnType();
27+
return ParametersAcceptorSelector::selectSingle(
28+
$methodReflection->getVariants()
29+
)->getReturnType();
2630
}
2731

2832
$valueExpr = $methodCall->args[0]->value;

src/Type/BeberleiAssert/AssertThatFunctionDynamicReturnTypeExtension.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use PHPStan\Analyser\Scope;
66
use PHPStan\Reflection\FunctionReflection;
7+
use PHPStan\Reflection\ParametersAcceptorSelector;
78

89
class AssertThatFunctionDynamicReturnTypeExtension implements \PHPStan\Type\DynamicFunctionReturnTypeExtension
910
{
@@ -26,7 +27,9 @@ public function getTypeFromFunctionCall(
2627
): \PHPStan\Type\Type
2728
{
2829
if (count($functionCall->args) === 0) {
29-
return $functionReflection->getReturnType();
30+
return ParametersAcceptorSelector::selectSingle(
31+
$functionReflection->getVariants()
32+
)->getReturnType();
3033
}
3134

3235
$valueExpr = $functionCall->args[0]->value;

tests/Type/BeberleiAssert/ImpossibleCheckTypeMethodCallRuleTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class ImpossibleCheckTypeMethodCallRuleTest extends \PHPStan\Testing\RuleTestCas
1010

1111
protected function getRule(): Rule
1212
{
13-
return new ImpossibleCheckTypeMethodCallRule(true);
13+
return new ImpossibleCheckTypeMethodCallRule($this->getTypeSpecifier(), true);
1414
}
1515

1616
/**

tests/Type/BeberleiAssert/ImpossibleCheckTypeStaticMethodCallRuleTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class ImpossibleCheckTypeStaticMethodCallRuleTest extends \PHPStan\Testing\RuleT
1010

1111
protected function getRule(): Rule
1212
{
13-
return new ImpossibleCheckTypeStaticMethodCallRule(true);
13+
return new ImpossibleCheckTypeStaticMethodCallRule($this->getTypeSpecifier(), true);
1414
}
1515

1616
/**

0 commit comments

Comments
 (0)