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;
}