function DrupalComponentTest::findPhpClasses

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Component/DrupalComponentTest.php \Drupal\Tests\Component\DrupalComponentTest::findPhpClasses()
  2. 10 core/tests/Drupal/Tests/Component/DrupalComponentTest.php \Drupal\Tests\Component\DrupalComponentTest::findPhpClasses()
  3. 11.x 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 74

Class

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

Namespace

Drupal\Tests\Component

Code

protected function findPhpClasses($dir) {
    $classes = [];
    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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.