diff --git a/src/Command/FindMultiClassesCommand.php b/src/Command/FindMultiClassesCommand.php index 8b838bf46..86601b6c7 100644 --- a/src/Command/FindMultiClassesCommand.php +++ b/src/Command/FindMultiClassesCommand.php @@ -45,8 +45,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int return self::SUCCESS; } - foreach ($multipleClassesByFile as $file => $classes) { - $message = sprintf('File "%s" has %d classes', $file, count($classes)); + foreach ($multipleClassesByFile as $filePath => $classes) { + // get relative path to getcwd() + $relativeFilePath = str_replace(getcwd() . '/', '', $filePath); + + $message = sprintf('File "%s" contains %d classes', $relativeFilePath, count($classes)); $this->symfonyStyle->section($message); $this->symfonyStyle->listing($classes); } diff --git a/src/Finder/MultipleClassInOneFileFinder.php b/src/Finder/MultipleClassInOneFileFinder.php index 164e50b1d..f81de6e1b 100644 --- a/src/Finder/MultipleClassInOneFileFinder.php +++ b/src/Finder/MultipleClassInOneFileFinder.php @@ -15,15 +15,15 @@ public function __construct( /** * @param string[] $directories - * @return string[][] + * @return array */ public function findInDirectories(array $directories): array { $fileByClasses = $this->phpClassLoader->load($directories); $classesByFile = []; - foreach ($fileByClasses as $class => $file) { - $classesByFile[$file][] = $class; + foreach ($fileByClasses as $class => $filePath) { + $classesByFile[$filePath][] = $class; } return array_filter($classesByFile, static fn (array $classes): bool => count($classes) >= 2);