Skip to content

Commit 84b0934

Browse files
committed
MethodCall with Expr name adds an implicit throw point
1 parent 0b92888 commit 84b0934

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/Analyser/NodeScopeResolver.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1961,6 +1961,7 @@ function (MutatingScope $scope) use ($expr, $nodeCallback, $context): Expression
19611961
if ($expr->name instanceof Expr) {
19621962
$methodNameResult = $this->processExprNode($expr->name, $scope, $nodeCallback, $context->enterDeep());
19631963
$throwPoints = array_merge($throwPoints, $methodNameResult->getThrowPoints());
1964+
$throwPoints[] = ThrowPoint::createImplicit($scope, $expr);
19641965
$scope = $methodNameResult->getScope();
19651966
} else {
19661967
$calledOnType = $scope->getType($expr->var);

tests/PHPStan/Rules/Exceptions/data/unthrown-exception.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,4 +534,13 @@ public function doFoo(\Exception $e)
534534
}
535535
}
536536

537+
public function doBar(string $s)
538+
{
539+
try {
540+
$this->{'doFoo' . $s}();
541+
} catch (\InvalidArgumentException $e) {
542+
543+
}
544+
}
545+
537546
}

0 commit comments

Comments
 (0)