public function getEndTokenId() {
$block = 0;
$i = $this->id;
$tokens = $this->tokenStream
->tokens();
while ($this->endTokenId === NULL && isset($tokens[$i])) {
if ($tokens[$i] instanceof PHP_Token_OPEN_CURLY || $tokens[$i] instanceof PHP_Token_CURLY_OPEN) {
$block++;
}
else {
if ($tokens[$i] instanceof PHP_Token_CLOSE_CURLY) {
$block--;
if ($block === 0) {
$this->endTokenId = $i;
}
}
else {
if (($this instanceof PHP_Token_FUNCTION || $this instanceof PHP_Token_NAMESPACE) && $tokens[$i] instanceof PHP_Token_SEMICOLON) {
if ($block === 0) {
$this->endTokenId = $i;
}
}
}
}
$i++;
}
if ($this->endTokenId === NULL) {
$this->endTokenId = $this->id;
}
return $this->endTokenId;
}