Skip to content

Commit

Permalink
relative path
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Jan 29, 2024
1 parent 98dbcf8 commit 9c427d5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/Command/FindMultiClassesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Finder/MultipleClassInOneFileFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ public function __construct(

/**
* @param string[] $directories
* @return string[][]
* @return array<string, string[]>
*/
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);
Expand Down

0 comments on commit 9c427d5

Please sign in to comment.