protected function close_scope($pos, Lint\Node $node)
{
$token = $this->tokens[$pos];
if ($token[0] === T_SEMICOLON) {
if (!empty($this->scope)) {
// Nested scopes if not opened by `{` are
// terminated all at once.
while ($last = array_pop($this->scope)) {
if ($last[0] === T_BASIC_CURLY_OPEN) {
$this->scope[] = $last;
break;
}
$depth = count($this->scope) + $node->depth;
$this->debug(sprintf('Scope closed by `%s` line %d', $token[1], $token[2]), $depth, OPT_SCOPE_MAP, true);
$node->tokens[] = array(T_CLOSE_SCOPE, $token[1], $token[2]);
}
}
} else {
$depth = count($this->scope) + $node->depth;
$this->debug(sprintf('Scope closed by `%s` line %d', $token[1], $token[2]), $depth, OPT_SCOPE_MAP, true);
array_pop($this->scope);
$node->tokens[] = array(T_CLOSE_SCOPE, $token[1], $token[2]);
}
}