phpStanNodeScopeResolver = $phpStanNodeScopeResolver; $this->filePath = $filePath; $this->scopeFactory = $scopeFactory; } public function enterNode(Node $node) : ?Node { if (!$node instanceof StmtsAwareInterface && !$node instanceof ClassLike && !$node instanceof Declare_) { return null; } if ($node->stmts === null) { return null; } $isPassedUnreachableStmt = \false; $mutatingScope = $this->resolveScope($node->getAttribute(AttributeKey::SCOPE)); foreach ($node->stmts as $stmt) { $hasMutatingScope = $stmt->getAttribute(AttributeKey::SCOPE) instanceof MutatingScope; if (!$hasMutatingScope) { $stmt->setAttribute(AttributeKey::SCOPE, $mutatingScope); $this->phpStanNodeScopeResolver->processNodes([$stmt], $this->filePath, $mutatingScope); } if ($stmt->getAttribute(AttributeKey::IS_UNREACHABLE) === \true) { $isPassedUnreachableStmt = \true; continue; } if ($isPassedUnreachableStmt) { $stmt->setAttribute(AttributeKey::IS_UNREACHABLE, \true); } } return null; } private function resolveScope(?Scope $mutatingScope) : MutatingScope { return $mutatingScope instanceof MutatingScope ? $mutatingScope : $this->scopeFactory->createFromFile($this->filePath); } }