class PHP_Token_FUNCTION

Hierarchy

Expanded class hierarchy of PHP_Token_FUNCTION

2 string references to 'PHP_Token_FUNCTION'
PHP_CodeCoverage_Util::getLinesToBeIgnored in drupal/core/vendor/phpunit/php-code-coverage/PHP/CodeCoverage/Util.php
Returns the lines of a source file that should be ignored.
PHP_Token_Stream::parse in drupal/core/vendor/phpunit/php-token-stream/PHP/Token/Stream.php

File

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

View source
class PHP_Token_FUNCTION extends PHP_TokenWithScopeAndVisibility {
  protected $arguments;
  protected $ccn;
  protected $name;
  protected $signature;
  public function getArguments() {
    if ($this->arguments !== NULL) {
      return $this->arguments;
    }
    $this->arguments = array();
    $i = $this->id + 3;
    $tokens = $this->tokenStream
      ->tokens();
    $typeHint = NULL;
    while (!$tokens[$i] instanceof PHP_Token_CLOSE_BRACKET) {
      if ($tokens[$i] instanceof PHP_Token_STRING) {
        $typeHint = (string) $tokens[$i];
      }
      else {
        if ($tokens[$i] instanceof PHP_Token_VARIABLE) {
          $this->arguments[(string) $tokens[$i]] = $typeHint;
          $typeHint = NULL;
        }
      }
      $i++;
    }
    return $this->arguments;
  }
  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;
  }
  public function getCCN() {
    if ($this->ccn !== NULL) {
      return $this->ccn;
    }
    $this->ccn = 1;
    $end = $this
      ->getEndTokenId();
    $tokens = $this->tokenStream
      ->tokens();
    for ($i = $this->id; $i <= $end; $i++) {
      switch (get_class($tokens[$i])) {
        case 'PHP_Token_IF':
        case 'PHP_Token_ELSEIF':
        case 'PHP_Token_FOR':
        case 'PHP_Token_FOREACH':
        case 'PHP_Token_WHILE':
        case 'PHP_Token_CASE':
        case 'PHP_Token_CATCH':
        case 'PHP_Token_BOOLEAN_AND':
        case 'PHP_Token_LOGICAL_AND':
        case 'PHP_Token_BOOLEAN_OR':
        case 'PHP_Token_LOGICAL_OR':
        case 'PHP_Token_QUESTION_MARK':
          $this->ccn++;
          break;
      }
    }
    return $this->ccn;
  }
  public function getSignature() {
    if ($this->signature !== NULL) {
      return $this->signature;
    }
    if ($this
      ->getName() == 'anonymous function') {
      $this->signature = 'anonymous function';
      $i = $this->id + 1;
    }
    else {
      $this->signature = '';
      $i = $this->id + 2;
    }
    $tokens = $this->tokenStream
      ->tokens();
    while (!$tokens[$i] instanceof PHP_Token_CLOSE_BRACKET) {
      $this->signature .= $tokens[$i++];
    }
    $this->signature .= ')';
    return $this->signature;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PHP_Token::$id protected property
PHP_Token::$line protected property
PHP_Token::$text protected property
PHP_Token::$tokenStream protected property
PHP_Token::getLine public function
PHP_Token::__construct public function Constructor.
PHP_Token::__toString public function
PHP_TokenWithScope::$endTokenId protected property
PHP_TokenWithScope::getDocblock public function Get the docblock for this token
PHP_TokenWithScope::getEndLine public function
PHP_TokenWithScope::getEndTokenId public function
PHP_TokenWithScopeAndVisibility::getKeywords public function
PHP_TokenWithScopeAndVisibility::getVisibility public function
PHP_Token_FUNCTION::$arguments protected property
PHP_Token_FUNCTION::$ccn protected property
PHP_Token_FUNCTION::$name protected property
PHP_Token_FUNCTION::$signature protected property
PHP_Token_FUNCTION::getArguments public function
PHP_Token_FUNCTION::getCCN public function
PHP_Token_FUNCTION::getName public function
PHP_Token_FUNCTION::getSignature public function