private function BasicIntegrityTest::includeAllRecursivePsr4 in X Autoload 7.4
Same name and namespace in other branches
- 7.5 tests/src/BasicIntegrityTest.php \Drupal\xautoload\Tests\BasicIntegrityTest::includeAllRecursivePsr4()
Parameters
string $dir:
string $namespace:
array $skip:
Throws
\Exception
1 call to BasicIntegrityTest::includeAllRecursivePsr4()
- BasicIntegrityTest::testIncludeAll in tests/
lib/ BasicIntegrityTest.php - Tests that all classes in the lib/ folder can be included without conflict.
File
- tests/
lib/ BasicIntegrityTest.php, line 29
Class
- BasicIntegrityTest
- A test class to verify that all class files work well across PHP versions.
Namespace
Drupal\xautoload\TestsCode
private function includeAllRecursivePsr4($dir, $namespace, array $skip) {
foreach (scandir($dir) as $candidate) {
if ('.' === $candidate || '..' === $candidate) {
continue;
}
$path = $dir . '/' . $candidate;
if (in_array($path, $skip)) {
continue;
}
if (is_dir($path)) {
$this
->includeAllRecursivePsr4($dir . '/' . $candidate, $namespace . '\\' . $candidate, $skip);
}
elseif (is_file($path)) {
if ('.php' === substr($candidate, -4)) {
$class = $namespace . '\\' . substr($candidate, 0, -4);
if (class_exists($class)) {
continue;
}
if (interface_exists($class)) {
continue;
}
if (function_exists('trait_exists') && trait_exists($class)) {
continue;
}
throw new \Exception("Non-existing class, trait or interface '{$class}'.");
}
}
}
}