private function appendNamespace()
{
$inNamespace = true;
while ($inNamespace === true) {
$token = $this->tokens->current();
switch ($token[0]) {
case T_NAMESPACE:
$parent = $this->currentIterator->getParent();
if ($parent !== null) {
$this->currentIterator = $parent;
}
$this->currentIterator->appendNamespace($this->currentNamespace = new iterators\phpNamespace());
$this->currentIterator = $this->currentNamespace;
break;
case T_CONST:
$this->appendConstant();
break;
case T_FUNCTION:
$this->appendFunction();
break;
case T_FINAL:
case T_ABSTRACT:
case T_CLASS:
$this->appendClass();
break;
case T_INTERFACE:
$this->appendInterface();
break;
case ';':
$this->currentIterator = $this->currentIterator->getParent();
$inNamespace = false;
break;
case T_CLOSE_TAG:
if ($this->nextTokenIs(T_OPEN_TAG) === false) {
$this->currentIterator = $this->currentIterator->getParent();
$inNamespace = false;
}
break;
case '}':
$inNamespace = false;
break;
}
$this->currentIterator->append(new token($token[0], isset($token[1]) === false ? null : $token[1], isset($token[2]) === false ? null : $token[2]));
if ($token[0] === '}') {
$this->currentIterator = $this->currentIterator->getParent();
}
$this->tokens->next();
$inNamespace = $inNamespace && $this->tokens->valid();
}
return $this->tokens->valid() === false ? null : $this->tokens->current();
}