Skip to content

Commit

Permalink
misc
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Dec 3, 2024
1 parent ee3b308 commit 2ebba8a
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/Reporting/UnusedClassReporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,26 @@ public function reportResult(UnusedClassesResult $unusedClassesResult, bool $isJ

// separate with and without parent, as first one can be removed more easily
if ($unusedClassesResult->getWithParentsFileWithClasses() !== []) {
$this->symfonyStyle->section('Classes with a parent/interface - possibly used by type');
$this->reportFileWithClasses($unusedClassesResult->getWithParentsFileWithClasses());
$this->printLineWIthClasses(
'Classes with a parent/interface',
$unusedClassesResult->getWithParentsFileWithClasses()
);
}

if ($unusedClassesResult->getParentLessFileWithClasses() !== []) {
$this->symfonyStyle->newLine();
$this->symfonyStyle->section('Classes without any parent/interface - easier to remove');

$this->reportFileWithClasses($unusedClassesResult->getParentLessFileWithClasses());
$this->printLineWIthClasses(
'Classes without any parent/interface - easier to remove',
$unusedClassesResult->getParentLessFileWithClasses()
);
}

// @todo traits - the easier to remove as hardly used anywhere
if ($unusedClassesResult->getTraits() !== []) {
$this->symfonyStyle->newLine();
$this->symfonyStyle->section('Traits without any use - the easiest to remove');

$this->reportFileWithClasses($unusedClassesResult->getTraits());
$this->printLineWIthClasses('Unused traits - the easiest to remove', $unusedClassesResult->getTraits());
}

$this->symfonyStyle->newLine();
$this->symfonyStyle->error(sprintf(
'Found %d unused classes. Check and remove them or skip them using "--skip-type" option',
'Found %d unused classes. Remove them or skip them using "--skip-type" option',
$unusedClassesResult->getCount()
));

Expand All @@ -75,8 +73,11 @@ public function reportResult(UnusedClassesResult $unusedClassesResult, bool $isJ
/**
* @param FileWithClass[] $fileWithClasses
*/
private function reportFileWithClasses(array $fileWithClasses): void
private function printLineWIthClasses(string $title, array $fileWithClasses): void
{
$this->symfonyStyle->newLine();
$this->symfonyStyle->section($title);

foreach ($fileWithClasses as $fileWithClass) {
$this->symfonyStyle->writeln($fileWithClass->getFilePath());
$this->symfonyStyle->newLine();
Expand Down

0 comments on commit 2ebba8a

Please sign in to comment.