diff --git a/src/Analyser/MutatingScope.php b/src/Analyser/MutatingScope.php index c78ce49de8..d7e6a6f513 100644 --- a/src/Analyser/MutatingScope.php +++ b/src/Analyser/MutatingScope.php @@ -3525,12 +3525,8 @@ public function restoreThis(self $restoreThisScope): self $nativeExpressionTypes = $this->nativeExpressionTypes; if ($restoreThisScope->isInClass()) { - $nodeFinder = new NodeFinder(); - $cb = static fn ($expr) => $expr instanceof Variable && $expr->name === 'this'; foreach ($restoreThisScope->expressionTypes as $exprString => $expressionTypeHolder) { - $expr = $expressionTypeHolder->getExpr(); - $thisExpr = $nodeFinder->findFirst([$expr], $cb); - if ($thisExpr === null) { + if (!str_starts_with($exprString, '$this')) { continue; } @@ -3538,9 +3534,7 @@ public function restoreThis(self $restoreThisScope): self } foreach ($restoreThisScope->nativeExpressionTypes as $exprString => $expressionTypeHolder) { - $expr = $expressionTypeHolder->getExpr(); - $thisExpr = $nodeFinder->findFirst([$expr], $cb); - if ($thisExpr === null) { + if (!str_starts_with($exprString, '$this')) { continue; }