class PHP_Token_INTERFACE

Hierarchy

Expanded class hierarchy of PHP_Token_INTERFACE

2 string references to 'PHP_Token_INTERFACE'
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 514

View source
class PHP_Token_INTERFACE extends PHP_TokenWithScopeAndVisibility {
  protected $interfaces;
  public function getName() {
    return (string) $this->tokenStream[$this->id + 2];
  }
  public function hasParent() {
    return $this->tokenStream[$this->id + 4] instanceof PHP_Token_EXTENDS;
  }
  public function getPackage() {
    $className = $this
      ->getName();
    $docComment = $this
      ->getDocblock();
    $result = array(
      'namespace' => '',
      'fullPackage' => '',
      'category' => '',
      'package' => '',
      'subpackage' => '',
    );
    for ($i = $this->id; $i; --$i) {
      if ($this->tokenStream[$i] instanceof PHP_Token_NAMESPACE) {
        $result['namespace'] = $this->tokenStream[$i]
          ->getName();
        break;
      }
    }
    if (preg_match('/@category[\\s]+([\\.\\w]+)/', $docComment, $matches)) {
      $result['category'] = $matches[1];
    }
    if (preg_match('/@package[\\s]+([\\.\\w]+)/', $docComment, $matches)) {
      $result['package'] = $matches[1];
      $result['fullPackage'] = $matches[1];
    }
    if (preg_match('/@subpackage[\\s]+([\\.\\w]+)/', $docComment, $matches)) {
      $result['subpackage'] = $matches[1];
      $result['fullPackage'] .= '.' . $matches[1];
    }
    if (empty($result['fullPackage'])) {
      $result['fullPackage'] = $this
        ->arrayToName(explode('_', str_replace('\\', '_', $className)), '.');
    }
    return $result;
  }
  protected function arrayToName(array $parts, $join = '\\') {
    $result = '';
    if (count($parts) > 1) {
      array_pop($parts);
      $result = join($join, $parts);
    }
    return $result;
  }
  public function getParent() {
    if (!$this
      ->hasParent()) {
      return FALSE;
    }
    $i = $this->id + 6;
    $tokens = $this->tokenStream
      ->tokens();
    $className = (string) $tokens[$i];
    while (isset($tokens[$i + 1]) && !$tokens[$i + 1] instanceof PHP_Token_WHITESPACE) {
      $className .= (string) $tokens[++$i];
    }
    return $className;
  }
  public function hasInterfaces() {
    return isset($this->tokenStream[$this->id + 4]) && $this->tokenStream[$this->id + 4] instanceof PHP_Token_IMPLEMENTS || isset($this->tokenStream[$this->id + 8]) && $this->tokenStream[$this->id + 8] instanceof PHP_Token_IMPLEMENTS;
  }
  public function getInterfaces() {
    if ($this->interfaces !== NULL) {
      return $this->interfaces;
    }
    if (!$this
      ->hasInterfaces()) {
      return $this->interfaces = FALSE;
    }
    if ($this->tokenStream[$this->id + 4] instanceof PHP_Token_IMPLEMENTS) {
      $i = $this->id + 3;
    }
    else {
      $i = $this->id + 7;
    }
    $tokens = $this->tokenStream
      ->tokens();
    while (!$tokens[$i + 1] instanceof PHP_Token_OPEN_CURLY) {
      $i++;
      if ($tokens[$i] instanceof PHP_Token_STRING) {
        $this->interfaces[] = (string) $tokens[$i];
      }
    }
    return $this->interfaces;
  }

}

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_INTERFACE::$interfaces protected property
PHP_Token_INTERFACE::arrayToName protected function
PHP_Token_INTERFACE::getInterfaces public function
PHP_Token_INTERFACE::getName public function
PHP_Token_INTERFACE::getPackage public function
PHP_Token_INTERFACE::getParent public function
PHP_Token_INTERFACE::hasInterfaces public function
PHP_Token_INTERFACE::hasParent public function