function DebugCommand::getResourcesByPath
1 call to DebugCommand::getResourcesByPath()
- DebugCommand::execute in vendor/
symfony/ validator/ Command/ DebugCommand.php - Executes the current command.
File
-
vendor/
symfony/ validator/ Command/ DebugCommand.php, line 218
Class
- DebugCommand
- A console command to debug Validators information.
Namespace
Symfony\Component\Validator\CommandCode
private function getResourcesByPath(string $path) : array {
$finder = new Finder();
$finder->files()
->in($path)
->name('*.php')
->sortByName(true);
$classes = [];
foreach ($finder as $file) {
$fileContent = file_get_contents($file->getRealPath());
preg_match('/namespace (.+);/', $fileContent, $matches);
$namespace = $matches[1] ?? null;
if (!preg_match('/class +([^{ ]+)/', $fileContent, $matches)) {
// no class found
continue;
}
$className = trim($matches[1]);
if (null !== $namespace) {
$classes[] = $namespace . '\\' . $className;
}
else {
$classes[] = $className;
}
}
return $classes;
}