Skip to content

Commit 3bd8464

Browse files
committed
Improve compatibility with nikic/php-parser 4.13.0
1 parent fb97c44 commit 3bd8464

4 files changed

+10
-10
lines changed

Diff for: src/Type/BeberleiAssert/AssertThatDynamicMethodReturnTypeExtension.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ public function isStaticMethodSupported(\PHPStan\Reflection\MethodReflection $me
2323

2424
public function getTypeFromStaticMethodCall(\PHPStan\Reflection\MethodReflection $methodReflection, \PhpParser\Node\Expr\StaticCall $methodCall, \PHPStan\Analyser\Scope $scope): \PHPStan\Type\Type
2525
{
26-
if (count($methodCall->args) === 0) {
26+
if (count($methodCall->getArgs()) === 0) {
2727
return ParametersAcceptorSelector::selectSingle(
2828
$methodReflection->getVariants()
2929
)->getReturnType();
3030
}
3131

32-
$valueExpr = $methodCall->args[0]->value;
32+
$valueExpr = $methodCall->getArgs()[0]->value;
3333
$type = new AssertThatType($valueExpr, $scope->getType($valueExpr));
3434
if ($methodReflection->getName() === 'thatNullOr') {
3535
return $type->toNullOr();

Diff for: src/Type/BeberleiAssert/AssertThatFunctionDynamicReturnTypeExtension.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ public function getTypeFromFunctionCall(
2626
Scope $scope
2727
): \PHPStan\Type\Type
2828
{
29-
if (count($functionCall->args) === 0) {
29+
if (count($functionCall->getArgs()) === 0) {
3030
return ParametersAcceptorSelector::selectSingle(
3131
$functionReflection->getVariants()
3232
)->getReturnType();
3333
}
3434

35-
$valueExpr = $functionCall->args[0]->value;
35+
$valueExpr = $functionCall->getArgs()[0]->value;
3636
$type = new AssertThatType($valueExpr, $scope->getType($valueExpr));
3737
if ($functionReflection->getName() === 'Assert\\thatNullOr') {
3838
return $type->toNullOr();

Diff for: src/Type/BeberleiAssert/AssertTypeSpecifyingExtension.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ public function isStaticMethodSupported(
4040
'allNotSame' => 2,
4141
];
4242
return array_key_exists($staticMethodReflection->getName(), $methods)
43-
&& count($node->args) >= $methods[$staticMethodReflection->getName()];
43+
&& count($node->getArgs()) >= $methods[$staticMethodReflection->getName()];
4444
}
4545

4646
$trimmedName = self::trimName($staticMethodReflection->getName());
47-
return AssertHelper::isSupported($trimmedName, $node->args);
47+
return AssertHelper::isSupported($trimmedName, $node->getArgs());
4848
}
4949

5050
private static function trimName(string $name): string
@@ -71,15 +71,15 @@ public function specifyTypes(
7171
$this->typeSpecifier,
7272
$scope,
7373
lcfirst(substr($staticMethodReflection->getName(), 3)),
74-
$node->args
74+
$node->getArgs()
7575
);
7676
}
7777

7878
$specifiedTypes = AssertHelper::specifyTypes(
7979
$this->typeSpecifier,
8080
$scope,
8181
self::trimName($staticMethodReflection->getName()),
82-
$node->args,
82+
$node->getArgs(),
8383
substr($staticMethodReflection->getName(), 0, 6) === 'nullOr'
8484
);
8585

Diff for: src/Type/BeberleiAssert/AssertionChainTypeSpecifyingExtension.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function isMethodSupported(
3636
$methodReflection->getName(),
3737
array_merge(
3838
[new \PhpParser\Node\Arg(new \PhpParser\Node\Scalar\LNumber(1))],
39-
$node->args
39+
$node->getArgs()
4040
)
4141
);
4242
}
@@ -58,7 +58,7 @@ public function specifyTypes(
5858

5959
$args = array_merge([
6060
new \PhpParser\Node\Arg($calledOnType->getValueExpr()),
61-
], $node->args);
61+
], $node->getArgs());
6262

6363
if (
6464
$calledOnType instanceof AssertThatAllType

0 commit comments

Comments
 (0)