public function PHP_Token_Stream::getIncludes

Gets the names of all files that have been included using include(), include_once(), require() or require_once().

Parameter $categorize set to TRUE causing this function to return a multi-dimensional array with categories in the keys of the first dimension and constants and their values in the second dimension.

Parameter $category allow to filter following specific inclusion type

@since Method available since Release 1.1.0

Parameters

bool $categorize OPTIONAL:

string $category OPTIONAL Either 'require_once', 'require',: 'include_once', 'include'.

Return value

array

File

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

Class

PHP_Token_Stream
A stream of PHP tokens.

Code

public function getIncludes($categorize = FALSE, $category = NULL) {
  if ($this->includes === NULL) {
    $this->includes = array(
      'require_once' => array(),
      'require' => array(),
      'include_once' => array(),
      'include' => array(),
    );
    foreach ($this->tokens as $token) {
      switch (get_class($token)) {
        case 'PHP_Token_REQUIRE_ONCE':
        case 'PHP_Token_REQUIRE':
        case 'PHP_Token_INCLUDE_ONCE':
        case 'PHP_Token_INCLUDE':
          $this->includes[$token
            ->getType()][] = $token
            ->getName();
          break;
      }
    }
  }
  if (isset($this->includes[$category])) {
    $includes = $this->includes[$category];
  }
  else {
    if ($categorize === FALSE) {
      $includes = array_merge($this->includes['require_once'], $this->includes['require'], $this->includes['include_once'], $this->includes['include']);
    }
    else {
      $includes = $this->includes;
    }
  }
  return $includes;
}