Skip to content

Commit 83de825

Browse files
phpstan-botclaude
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 d2f6cce commit 83de825

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();
@@ -2728,6 +2727,10 @@ public function specifyExpressionType(Expr $expr, Type $type, Type $nativeType,
27282727
}
27292728
}
27302729

2730+
if ($this->expressionHasNewInChain($expr)) {
2731+
return $this;
2732+
}
2733+
27312734
$scope = $this;
27322735
if (
27332736
$expr instanceof Expr\ArrayDimFetch

0 commit comments

Comments
 (0)