Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DebugCommand.php

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\Command

Code

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;
}
RSS feed
Powered by Drupal