77use Bref \Cli \Cli \Styles ;
88use ErrorException ;
99use Exception ;
10+ use Symfony \Component \Console \Command \Command ;
1011use Symfony \Component \Console \Input \InputInterface ;
1112use Symfony \Component \Console \Output \OutputInterface ;
1213use Symfony \Component \HttpClient \Exception \ClientException ;
@@ -20,15 +21,25 @@ public function __construct()
2021
2122 $ this ->turnWarningsIntoExceptions ();
2223
23- $ this ->add (new Commands \Login );
24- $ this ->add (new Commands \Deploy );
25- $ this ->add (new Commands \Info );
26- $ this ->add (new Commands \Remove );
27- $ this ->add (new Commands \Command );
28- $ this ->add (new Commands \Connect );
29- $ this ->add (new Commands \PreviousLogs );
30- $ this ->add (new Commands \Cloud );
31- $ this ->add (new Commands \Tinker );
24+ $ this ->safeAddCommand (new Commands \Login );
25+ $ this ->safeAddCommand (new Commands \Deploy );
26+ $ this ->safeAddCommand (new Commands \Info );
27+ $ this ->safeAddCommand (new Commands \Remove );
28+ $ this ->safeAddCommand (new Commands \Command );
29+ $ this ->safeAddCommand (new Commands \Connect );
30+ $ this ->safeAddCommand (new Commands \PreviousLogs );
31+ $ this ->safeAddCommand (new Commands \Cloud );
32+ $ this ->safeAddCommand (new Commands \Tinker );
33+ }
34+
35+ public function safeAddCommand (Command $ command ): ?Command
36+ {
37+ if (method_exists ($ this , 'addCommand ' )) {
38+ // addCommand() exists since 7.4 and add() has been deprecated.
39+ return $ this ->addCommand ($ command );
40+ }
41+
42+ return $ this ->add ($ command );
3243 }
3344
3445 public function doRun (InputInterface $ input , OutputInterface $ output ): int
0 commit comments