1616use Symfony \Component \Console \Input \InputInterface ;
1717use Symfony \Component \Console \Input \InputOption ;
1818use Symfony \Component \Console \Output \OutputInterface ;
19+ use Symfony \Component \Console \Style \SymfonyStyle ;
1920use Webmozart \Assert \Assert ;
2021
2122final class ConsoleApplication extends Application
@@ -42,7 +43,7 @@ final class ConsoleApplication extends Application
4243 /**
4344 * @param Command[] $commands
4445 */
45- public function __construct (array $ commands )
46+ public function __construct (array $ commands, private readonly SymfonyStyle $ symfonyStyle )
4647 {
4748 parent ::__construct (self ::NAME , VersionResolver::PACKAGE_VERSION );
4849
@@ -91,7 +92,15 @@ public function doRun(InputInterface $input, OutputInterface $output): int
9192 $ tokens = array_merge (['process ' ], $ tokens );
9293 $ privatesAccessor ->setPrivateProperty ($ input , 'tokens ' , $ tokens );
9394 } elseif (! in_array ($ commandName , self ::ALLOWED_COMMANDS , true )) {
94- Assert::fileExists ($ commandName );
95+ $ this ->symfonyStyle ->error (
96+ sprintf (
97+ 'The following given path does not match any files or directories: %s%s ' ,
98+ "\n\n - " ,
99+ $ commandName
100+ )
101+ );
102+
103+ return ExitCode::FAILURE ;
95104 }
96105
97106 return parent ::doRun ($ input , $ output );
0 commit comments