You are here

public function PHP_TokenWithScope::getEndTokenId in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpunit/php-token-stream/src/Token.php \PHP_TokenWithScope::getEndTokenId()

Return value

integer

1 call to PHP_TokenWithScope::getEndTokenId()
PHP_Token_FUNCTION::getCCN in vendor/phpunit/php-token-stream/src/Token.php

File

vendor/phpunit/php-token-stream/src/Token.php, line 130

Class

PHP_TokenWithScope

Code

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++;
    }
    elseif ($tokens[$i] instanceof PHP_Token_CLOSE_CURLY) {
      $block--;
      if ($block === 0) {
        $this->endTokenId = $i;
      }
    }
    elseif (($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;
}