parentScopeFinder = $parentScopeFinder; $this->nodeUsageFinder = $nodeUsageFinder; $this->justReadExprAnalyzer = $justReadExprAnalyzer; } /** * @param \PhpParser\Node $node */ public function supports($node) : bool { return $node instanceof \PhpParser\Node\Expr\Variable; } /** * @param \PhpParser\Node $node */ public function isRead($node) : bool { $parentScope = $this->parentScopeFinder->find($node); if ($parentScope === null) { return \false; } $variableUsages = $this->nodeUsageFinder->findVariableUsages((array) $parentScope->stmts, $node); foreach ($variableUsages as $variableUsage) { if ($this->justReadExprAnalyzer->isReadContext($variableUsage)) { return \true; } } return \false; } }