From ebfd066f45757469fc72d022165b58f392b10786 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Costa=20Silva?= <1574795+joaocsilva@users.noreply.github.com> Date: Mon, 28 Oct 2024 14:37:39 +0100 Subject: [PATCH] DQA-10274: Fix classMap namespace on SanitiseClass (#789) --- src/TaskRunner/Commands/DrupalSanitiseCommands.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/TaskRunner/Commands/DrupalSanitiseCommands.php b/src/TaskRunner/Commands/DrupalSanitiseCommands.php index 96ad55746..5fec59d25 100644 --- a/src/TaskRunner/Commands/DrupalSanitiseCommands.php +++ b/src/TaskRunner/Commands/DrupalSanitiseCommands.php @@ -266,13 +266,14 @@ private function createClassMap(string $directory): array $classes = []; $iterator = new \RecursiveDirectoryIterator($directory); foreach (new \RecursiveIteratorIterator($iterator) as $file) { - if (!$file->isDir() && $file->getExtension() === 'php' && strpos($file->getPathname(), 'src')) { - $filePath = $file->getPathname(); + if (!$file->isDir() && $file->getExtension() === 'php' && str_contains($file->getPathname(), 'src')) { + $path = $file->getPathname(); $className = str_replace('.php', '', $file->getFilename()); - $ns = dirname(substr($filePath, (strpos($filePath, 'src') + 4))); - $module = basename(strstr($filePath, 'src', true)); - $namespace = 'Drupal\\' . $module . '\\' . $ns; - $classes[$namespace . '\\' . $className] = realpath($filePath); + $ns = dirname(substr($path, (strpos($path, 'src') + 4))); + $ns = str_replace('/', '\\', $ns); + $module = basename(strstr($path, 'src', true)); + $class = 'Drupal\\' . $module . '\\' . $ns . '\\' . $className; + $classes[$class] = realpath($path); } } return $classes;