Phan\Analysis\AssignmentVisitor::analyzeSuperglobalDim PHP Method

analyzeSuperglobalDim() private method

May create a new variable in $this->context. TODO: Emit issues if the assignment is incompatible with the pre-existing type?
private analyzeSuperglobalDim ( ast\Node $node, string $variable_name ) : Context
$node ast\Node
$variable_name string
return Phan\Language\Context
    private function analyzeSuperglobalDim(Node $node, string $variable_name) : Context
    {
        $dim = $node->children['dim'];
        if ('GLOBALS' === $variable_name) {
            if (!is_string($dim)) {
                // You're not going to believe this, but I just
                // found a piece of code like $GLOBALS[mt_rand()].
                // Super weird, right?
                return $this->context;
            }
            // assert(is_string($dim), "dim is not a string");
            if (Variable::isSuperglobalVariableWithName($dim)) {
                // Don't override types of superglobals such as $_POST, $argv through $_GLOBALS['_POST'] = expr either. TODO: Warn.
                return $this->context;
            }
            $variable = new Variable($this->context, $dim, $this->right_type, $node->flags ?? 0);
            $this->context->addGlobalScopeVariable($variable);
        }
        // TODO: Assignment sanity checks.
        return $this->context;
    }