Skip to content

Commit 546a487

Browse files
phpstan-botclaude
andcommitted
Simulate MethodCall instead of calling MethodThrowPointHelper directly
Address review feedback: process a synthetic MethodCall expression through processExprNode() instead of directly calling MethodThrowPointHelper. This leverages the existing MethodCallHandler infrastructure for __toString() throw point tracking in echo statements. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 01f336d commit 546a487

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/Analyser/NodeScopeResolver.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -864,23 +864,22 @@ public function processStmtNode(
864864
$throwPoints = [];
865865
$isAlwaysTerminating = false;
866866
$phpVersion = $this->container->getByType(PhpVersion::class);
867-
$methodThrowPointHelper = $this->container->getByType(ExprHandler\Helper\MethodThrowPointHelper::class);
868867
foreach ($stmt->exprs as $echoExpr) {
869868
$result = $this->processExprNode($stmt, $echoExpr, $scope, $storage, $nodeCallback, ExpressionContext::createDeep());
870869
$throwPoints = array_merge($throwPoints, $result->getThrowPoints());
871870
if ($phpVersion->throwsOnStringCast()) {
872871
$exprType = $scope->getType($echoExpr);
873872
$toStringMethod = $scope->getMethodReflection($exprType, '__toString');
874873
if ($toStringMethod !== null) {
875-
$throwPoint = $methodThrowPointHelper->getThrowPoint(
876-
$toStringMethod,
877-
$toStringMethod->getOnlyVariant(),
874+
$toStringResult = $this->processExprNode(
875+
$stmt,
878876
new Expr\MethodCall($echoExpr, new Identifier('__toString')),
879877
$scope,
878+
new ExpressionResultStorage(),
879+
new NoopNodeCallback(),
880+
ExpressionContext::createDeep(),
880881
);
881-
if ($throwPoint !== null) {
882-
$throwPoints[] = $throwPoint;
883-
}
882+
$throwPoints = array_merge($throwPoints, $toStringResult->getThrowPoints());
884883
}
885884
}
886885
$scope = $result->getScope();

0 commit comments

Comments
 (0)