function accountForCloseBrackets($name) { $scopeEnded = false; if ($name == "}") { $scopeEnded = $this->currentScope->popBracket(); } else { if ($name == ")") { $scopeEnded = $this->currentScope->popParens(); } } if ($scopeEnded == true) { if ($this->currentScope instanceof GlobalScope == false) { $poppedScope = $this->currentScope; $this->popCurrentScope(); //It was the last bracket for a function. if ($poppedScope instanceof FunctionScope) { $this->popCurrentScope(); //Also pop the function paramters scope. } } } }