public function PHP_TokenWithScope::getEndTokenId

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

File

drupal/core/vendor/phpunit/php-token-stream/PHP/Token.php, line 158

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++;
    }
    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;
}