Skip to content

Commit d0d1966

Browse files
phpstan-botclaude
authored andcommitted
Skip storing expression types with new in chain instead of skipping at resolve time
Move the expressionHasNewInChain check from resolveType() to specifyExpressionType() so that expressions based on new are never remembered in the first place, rather than being stored and then ignored at lookup time. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5e2127c commit d0d1966

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/Analyser/MutatingScope.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,6 @@ private function resolveType(string $exprString, Expr $node): Type
971971
!$node instanceof Variable
972972
&& !$node instanceof Expr\Closure
973973
&& !$node instanceof Expr\ArrowFunction
974-
&& !$this->expressionHasNewInChain($node)
975974
&& $this->hasExpressionType($node)->yes()
976975
) {
977976
return $this->expressionTypes[$exprString]->getType();
@@ -2731,6 +2730,10 @@ public function specifyExpressionType(Expr $expr, Type $type, Type $nativeType,
27312730
}
27322731
}
27332732

2733+
if ($this->expressionHasNewInChain($expr)) {
2734+
return $this;
2735+
}
2736+
27342737
$scope = $this;
27352738
if (
27362739
$expr instanceof Expr\ArrayDimFetch

0 commit comments

Comments
 (0)