44
55namespace Safe \Commands ;
66
7+ use Safe \Domain \MethodDefinition ;
8+ use Safe \XmlDocParser \Method ;
79use Safe \XmlDocParser \Scanner ;
810use Safe \XmlDocParser \DocPage ;
911use Symfony \Component \Console \Command \Command ;
1012use Symfony \Component \Console \Input \InputInterface ;
1113use Symfony \Component \Console \Output \OutputInterface ;
14+ use Symfony \Component \Console \Style \SymfonyStyle ;
1215
1316class ScanObjectsCommand extends Command
1417{
18+ private SymfonyStyle $ io ;
19+ private Scanner $ scanner ;
20+
1521 protected function configure (): void
1622 {
1723 $ this
@@ -20,20 +26,26 @@ protected function configure(): void
2026 ;
2127 }
2228
23- protected function execute (InputInterface $ input , OutputInterface $ output ): int
29+ public function initialize (InputInterface $ input , OutputInterface $ output ): void
2430 {
25- $ scanner = new Scanner (DocPage::referenceDir ());
31+ $ this ->io = new SymfonyStyle ($ input , $ output );
32+ $ this ->scanner = new Scanner (DocPage::referenceDir ());
33+ }
2634
27- $ paths = $ scanner ->getMethodsPaths ();
35+ protected function execute (InputInterface $ input , OutputInterface $ output ): int
36+ {
37+ $ this ->io ->title ($ this ->getDescription ());
2838
29- $ res = $ scanner ->getMethods ($ paths , [], $ output );
39+ $ result = $ this -> scanner ->getMethods ($ this -> scanner -> getMethodsPaths () , [], $ output );
3040
31- foreach ($ res ->methods as $ function ) {
32- $ name = $ function ->getFunctionName ();
33- $ output ->writeln ('Found method ' .$ name );
34- }
41+ $ this ->io ->table (
42+ ['Method ' , 'Error Type ' , 'Safe ' ],
43+ \array_merge (
44+ \array_map (static fn (Method $ method ) => [$ method ->getFunctionName (), $ method ->getErrorType ()->name , '✅ ' ], $ result ->methods ),
45+ \array_map (static fn (MethodDefinition $ method ) => [$ method ->name , $ method ->errorType ->name , '❌ ' ], $ result ->overloadedFunctions ),
46+ ),
47+ );
3548
36- $ output ->writeln ('These methods are overloaded: ' .\implode (', ' , $ res ->overloadedFunctions ));
37- return 0 ;
49+ return self ::SUCCESS ;
3850 }
3951}
0 commit comments