File tree Expand file tree Collapse file tree 4 files changed +16
-2
lines changed
Expand file tree Collapse file tree 4 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -87,6 +87,10 @@ class Application extends BaseApplication
8787
8888 public function __construct (string $ name = 'Composer ' , string $ version = '' )
8989 {
90+ if (method_exists ($ this , 'setCatchErrors ' )) {
91+ $ this ->setCatchErrors (true );
92+ }
93+
9094 static $ shutdownRegistered = false ;
9195 if ($ version === '' ) {
9296 $ version = Composer::getVersion ();
@@ -395,9 +399,10 @@ function_exists('php_uname') ? php_uname('s') . ' / ' . php_uname('r') : 'Unknow
395399
396400 $ this ->hintCommonErrors ($ e , $ output );
397401
398- // symfony/console does not handle \Error subtypes so we have to renderThrowable ourselves
402+ // symfony/console <6.4 does not handle \Error subtypes so we have to renderThrowable ourselves
399403 // instead of rethrowing those for consumption by the parent class
400- if (!$ e instanceof \Exception) {
404+ // can be removed when Composer supports PHP 8.1+
405+ if (!method_exists ($ this , 'setCatchErrors ' ) && !$ e instanceof \Exception) {
401406 if ($ output instanceof ConsoleOutputInterface) {
402407 $ this ->renderThrowable ($ e , $ output ->getErrorOutput ());
403408 } else {
Original file line number Diff line number Diff line change @@ -277,6 +277,9 @@ protected function doDispatch(Event $event)
277277
278278 $ app = new Application ();
279279 $ app ->setCatchExceptions (false );
280+ if (method_exists ($ app , 'setCatchErrors ' )) {
281+ $ app ->setCatchErrors (false );
282+ }
280283 $ app ->setAutoExit (false );
281284 $ cmd = new $ className ($ event ->getName ());
282285 $ app ->add ($ cmd );
Original file line number Diff line number Diff line change @@ -53,6 +53,9 @@ public static function provideCommandCases(): \Generator
5353 {
5454 $ application = new Application ();
5555 $ application ->setAutoExit (false );
56+ if (method_exists ($ application , 'setCatchErrors ' )) {
57+ $ application ->setCatchErrors (false );
58+ }
5659 $ application ->setCatchExceptions (false );
5760
5861 $ description = new ApplicationDescription ($ application );
Original file line number Diff line number Diff line change @@ -198,6 +198,9 @@ public function getApplicationTester(): ApplicationTester
198198 $ application = new Application ();
199199 $ application ->setAutoExit (false );
200200 $ application ->setCatchExceptions (false );
201+ if (method_exists ($ application , 'setCatchErrors ' )) {
202+ $ application ->setCatchErrors (false );
203+ }
201204
202205 return new ApplicationTester ($ application );
203206 }
You can’t perform that action at this time.
0 commit comments