Skip to content

Commit

Permalink
MethodCall with Expr name adds an implicit throw point
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Sep 13, 2021
1 parent 0b92888 commit 84b0934
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Analyser/NodeScopeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -1961,6 +1961,7 @@ function (MutatingScope $scope) use ($expr, $nodeCallback, $context): Expression
if ($expr->name instanceof Expr) {
$methodNameResult = $this->processExprNode($expr->name, $scope, $nodeCallback, $context->enterDeep());
$throwPoints = array_merge($throwPoints, $methodNameResult->getThrowPoints());
$throwPoints[] = ThrowPoint::createImplicit($scope, $expr);
$scope = $methodNameResult->getScope();
} else {
$calledOnType = $scope->getType($expr->var);
Expand Down
9 changes: 9 additions & 0 deletions tests/PHPStan/Rules/Exceptions/data/unthrown-exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -534,4 +534,13 @@ public function doFoo(\Exception $e)
}
}

public function doBar(string $s)
{
try {
$this->{'doFoo' . $s}();
} catch (\InvalidArgumentException $e) {

}
}

}

0 comments on commit 84b0934

Please sign in to comment.