You are here

protected function DrupalComponentTest::findPhpClasses in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Component/DrupalComponentTest.php \Drupal\Tests\Component\DrupalComponentTest::findPhpClasses()

Searches a directory recursively for PHP classes.

Parameters

string $dir: The full path to the directory that should be checked.

Return value

array An array of class paths.

2 calls to DrupalComponentTest::findPhpClasses()
DrupalComponentTest::testNoCoreInComponent in core/tests/Drupal/Tests/Component/DrupalComponentTest.php
Tests that classes in Component do not use any Core class.
DrupalComponentTest::testNoCoreInComponentTests in core/tests/Drupal/Tests/Component/DrupalComponentTest.php
Tests that classes in Component Tests do not use any Core class.

File

core/tests/Drupal/Tests/Component/DrupalComponentTest.php, line 49
Contains \Drupal\Tests\Component\DrupalComponentTest.

Class

DrupalComponentTest
General tests for \Drupal\Component that can't go anywhere else.

Namespace

Drupal\Tests\Component

Code

protected function findPhpClasses($dir) {
  $classes = array();
  foreach (new \DirectoryIterator($dir) as $file) {
    if ($file
      ->isDir() && !$file
      ->isDot()) {
      $classes = array_merge($classes, $this
        ->findPhpClasses($file
        ->getPathname()));
    }
    elseif ($file
      ->getExtension() == 'php') {
      $classes[] = $file
        ->getPathname();
    }
  }
  return $classes;
}