public function PHP_Token_FUNCTION::getName

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

File

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

Class

PHP_Token_FUNCTION

Code

public function getName() {
  if ($this->name !== NULL) {
    return $this->name;
  }
  $tokens = $this->tokenStream
    ->tokens();
  if ($tokens[$this->id + 2] instanceof PHP_Token_STRING) {
    $this->name = (string) $tokens[$this->id + 2];
  }
  else {
    if ($tokens[$this->id + 2] instanceof PHP_Token_AMPERSAND && $tokens[$this->id + 3] instanceof PHP_Token_STRING) {
      $this->name = (string) $tokens[$this->id + 3];
    }
    else {
      $this->name = 'anonymous function';
    }
  }
  if ($this->name != 'anonymous function') {
    for ($i = $this->id; $i; --$i) {
      if ($tokens[$i] instanceof PHP_Token_NAMESPACE) {
        $this->name = $tokens[$i]
          ->getName() . '\\' . $this->name;
        break;
      }
      if ($tokens[$i] instanceof PHP_Token_INTERFACE) {
        break;
      }
    }
  }
  return $this->name;
}