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
87
87
88
88
public function __construct (string $ name = 'Composer ' , string $ version = '' )
89
89
{
90
+ if (method_exists ($ this , 'setCatchErrors ' )) {
91
+ $ this ->setCatchErrors (true );
92
+ }
93
+
90
94
static $ shutdownRegistered = false ;
91
95
if ($ version === '' ) {
92
96
$ version = Composer::getVersion ();
@@ -395,9 +399,10 @@ function_exists('php_uname') ? php_uname('s') . ' / ' . php_uname('r') : 'Unknow
395
399
396
400
$ this ->hintCommonErrors ($ e , $ output );
397
401
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
399
403
// 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) {
401
406
if ($ output instanceof ConsoleOutputInterface) {
402
407
$ this ->renderThrowable ($ e , $ output ->getErrorOutput ());
403
408
} else {
Original file line number Diff line number Diff line change @@ -277,6 +277,9 @@ protected function doDispatch(Event $event)
277
277
278
278
$ app = new Application ();
279
279
$ app ->setCatchExceptions (false );
280
+ if (method_exists ($ app , 'setCatchErrors ' )) {
281
+ $ app ->setCatchErrors (false );
282
+ }
280
283
$ app ->setAutoExit (false );
281
284
$ cmd = new $ className ($ event ->getName ());
282
285
$ app ->add ($ cmd );
Original file line number Diff line number Diff line change @@ -53,6 +53,9 @@ public static function provideCommandCases(): \Generator
53
53
{
54
54
$ application = new Application ();
55
55
$ application ->setAutoExit (false );
56
+ if (method_exists ($ application , 'setCatchErrors ' )) {
57
+ $ application ->setCatchErrors (false );
58
+ }
56
59
$ application ->setCatchExceptions (false );
57
60
58
61
$ description = new ApplicationDescription ($ application );
Original file line number Diff line number Diff line change @@ -198,6 +198,9 @@ public function getApplicationTester(): ApplicationTester
198
198
$ application = new Application ();
199
199
$ application ->setAutoExit (false );
200
200
$ application ->setCatchExceptions (false );
201
+ if (method_exists ($ application , 'setCatchErrors ' )) {
202
+ $ application ->setCatchErrors (false );
203
+ }
201
204
202
205
return new ApplicationTester ($ application );
203
206
}
You can’t perform that action at this time.
0 commit comments