Skip to content

Commit d9a262f

Browse files
committed
cleanup
1 parent f40fa2c commit d9a262f

File tree

1 file changed

+8
-31
lines changed

1 file changed

+8
-31
lines changed

src/DependencyInjection/ContainerFactory.php

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
namespace Behastan\DependencyInjection;
66

7+
use Behastan\Command\DuplicatedDefinitionsCommand;
8+
use Behastan\Command\UnusedDefinitionsCommand;
79
use Illuminate\Container\Container;
810
use PhpParser\Parser;
911
use PhpParser\ParserFactory;
1012
use Symfony\Component\Console\Application;
1113
use Symfony\Component\Console\Input\ArrayInput;
1214
use Symfony\Component\Console\Output\ConsoleOutput;
1315
use Symfony\Component\Console\Style\SymfonyStyle;
14-
use Symfony\Component\Finder\Finder;
15-
use Webmozart\Assert\Assert;
1616

1717
final class ContainerFactory
1818
{
@@ -27,10 +27,8 @@ public function create(): Container
2727
$container->singleton(Application::class, function (Container $container): Application {
2828
$application = new Application('Behastan');
2929

30-
$commandClasses = $this->findCommandClasses();
31-
3230
// register commands
33-
foreach ($commandClasses as $commandClass) {
31+
foreach ([DuplicatedDefinitionsCommand::class, UnusedDefinitionsCommand::class] as $commandClass) {
3432
$command = $container->make($commandClass);
3533
$application->add($command);
3634
}
@@ -58,33 +56,12 @@ public function create(): Container
5856
public function hideDefaultCommands(Application $application): void
5957
{
6058
$application->get('list')
61-
->setHidden(true);
62-
$application->get('completion')
63-
->setHidden(true);
64-
$application->get('help')
65-
->setHidden(true);
66-
}
67-
68-
/**
69-
* @return string[]
70-
*/
71-
private function findCommandClasses(): array
72-
{
73-
$commandFinder = Finder::create()
74-
->files()
75-
->name('*Command.php')
76-
->in(__DIR__ . '/../Command');
77-
78-
$commandClasses = [];
79-
foreach ($commandFinder as $commandFile) {
80-
$commandClass = 'Behastan\\Command\\' . $commandFile->getBasename('.php');
59+
->setHidden();
8160

82-
// make sure it exists
83-
Assert::classExists($commandClass);
84-
85-
$commandClasses[] = $commandClass;
86-
}
61+
$application->get('completion')
62+
->setHidden();
8763

88-
return $commandClasses;
64+
$application->get('help')
65+
->setHidden();
8966
}
9067
}

0 commit comments

Comments
 (0)