Skip to content

Commit 2c05e08

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 3bfb674 commit 2c05e08

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
@@ -973,7 +973,6 @@ private function resolveType(string $exprString, Expr $node): Type
973973
!$node instanceof Variable
974974
&& !$node instanceof Expr\Closure
975975
&& !$node instanceof Expr\ArrowFunction
976-
&& !$this->expressionHasNewInChain($node)
977976
&& $this->hasExpressionType($node)->yes()
978977
) {
979978
return $this->expressionTypes[$exprString]->getType();
@@ -2733,6 +2732,10 @@ public function specifyExpressionType(Expr $expr, Type $type, Type $nativeType,
27332732
}
27342733
}
27352734

2735+
if ($this->expressionHasNewInChain($expr)) {
2736+
return $this;
2737+
}
2738+
27362739
$scope = $this;
27372740
if (
27382741
$expr instanceof Expr\ArrayDimFetch

0 commit comments

Comments
 (0)