/opt/cpanel/ea-wappspector/vendor/rector/rector/src/Application
Edit: /opt/cpanel/ea-wappspector/vendor/rector/rector/src/Application/ChangedNodeScopeRefresher.php (3388B)
phpStanNodeScopeResolver = $phpStanNodeScopeResolver;
$this->scopeAnalyzer = $scopeAnalyzer;
}
public function refresh(Node $node, string $filePath, ?MutatingScope $mutatingScope) : void
{
// nothing to refresh
if (!$this->scopeAnalyzer->isRefreshable($node)) {
return;
}
if (!$mutatingScope instanceof MutatingScope) {
$errorMessage = \sprintf('Node "%s" with is missing scope required for scope refresh', \get_class($node));
throw new ShouldNotHappenException($errorMessage);
}
$stmts = $this->resolveStmts($node);
$this->phpStanNodeScopeResolver->processNodes($stmts, $filePath, $mutatingScope);
}
public function reIndexNodeAttributes(Node $node) : void
{
if ($node instanceof FunctionLike) {
/** @var ClassMethod|Function_|Closure $node */
$node->params = \array_values($node->params);
if ($node instanceof Closure) {
$node->uses = \array_values($node->uses);
}
}
if ($node instanceof CallLike) {
/** @var FuncCall|MethodCall|New_|NullsafeMethodCall|StaticCall $node */
$node->args = \array_values($node->args);
}
if ($node instanceof If_) {
$node->elseifs = \array_values($node->elseifs);
}
if ($node instanceof TryCatch) {
$node->catches = \array_values($node->catches);
}
if ($node instanceof Switch_) {
$node->cases = \array_values($node->cases);
}
}
/**
* @return Stmt[]
*/
private function resolveStmts(Node $node) : array
{
if ($node instanceof Stmt) {
return [$node];
}
if ($node instanceof Expr) {
return [new Expression($node)];
}
$errorMessage = \sprintf('Complete parent node of "%s" be a stmt.', \get_class($node));
throw new ShouldNotHappenException($errorMessage);
}
}