44
55namespace Behastan \DependencyInjection ;
66
7+ use Behastan \Command \DuplicatedDefinitionsCommand ;
8+ use Behastan \Command \UnusedDefinitionsCommand ;
79use Illuminate \Container \Container ;
810use PhpParser \Parser ;
911use PhpParser \ParserFactory ;
1012use Symfony \Component \Console \Application ;
1113use Symfony \Component \Console \Input \ArrayInput ;
1214use Symfony \Component \Console \Output \ConsoleOutput ;
1315use Symfony \Component \Console \Style \SymfonyStyle ;
14- use Symfony \Component \Finder \Finder ;
15- use Webmozart \Assert \Assert ;
1616
1717final 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