Skip to content

Commit 9fce389

Browse files
phpstan-botclaude
authored andcommitted
Remove expressionHasNewInChain from MutatingScope
The TypeSpecifier side-effect checks now handle the new-in-chain case: expressionHasSideEffects() treats New_ as impure, preventing narrowed types from being stored for any expression with new in its chain. The MutatingScope check is no longer needed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 667d56b commit 9fce389

1 file changed

Lines changed: 0 additions & 22 deletions

File tree

src/Analyser/MutatingScope.php

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,6 @@ private function resolveType(string $exprString, Expr $node): Type
974974
&& !$node instanceof Expr\Closure
975975
&& !$node instanceof Expr\ArrowFunction
976976
&& $this->hasExpressionType($node)->yes()
977-
&& (!$this->expressionHasNewInChain($node) || $this->expressionTypes[$exprString]->getExpr() === $node)
978977
) {
979978
return $this->expressionTypes[$exprString]->getType();
980979
}
@@ -991,27 +990,6 @@ private function resolveType(string $exprString, Expr $node): Type
991990
return new MixedType();
992991
}
993992

994-
private function expressionHasNewInChain(Expr $expr): bool
995-
{
996-
if (
997-
$expr instanceof MethodCall ||
998-
$expr instanceof Expr\NullsafeMethodCall ||
999-
$expr instanceof Expr\ArrayDimFetch ||
1000-
$expr instanceof PropertyFetch ||
1001-
$expr instanceof Expr\NullsafePropertyFetch
1002-
) {
1003-
return $expr->var instanceof Expr\New_ || $this->expressionHasNewInChain($expr->var);
1004-
}
1005-
if (
1006-
$expr instanceof Expr\StaticCall
1007-
|| $expr instanceof Expr\StaticPropertyFetch
1008-
) {
1009-
return $expr->class instanceof Expr\New_ || ($expr->class instanceof Expr && $this->expressionHasNewInChain($expr->class));
1010-
}
1011-
1012-
return false;
1013-
}
1014-
1015993
/**
1016994
* @param callable(Type): ?bool $typeCallback
1017995
*/

0 commit comments

Comments
 (0)