From 29a52ff463f9d643be21bb522f14edade696d442 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 22 Jul 2021 12:57:55 +0200 Subject: [PATCH] Register ErrorHandler early to catch deprecation notices while the Application is being initialized --- bin/composer | 3 +++ src/Composer/Console/Application.php | 2 ++ 2 files changed, 5 insertions(+) diff --git a/bin/composer b/bin/composer index a4ca314db..62c18974d 100755 --- a/bin/composer +++ b/bin/composer @@ -11,6 +11,7 @@ require __DIR__.'/../src/bootstrap.php'; use Composer\Console\Application; use Composer\XdebugHandler\XdebugHandler; use Composer\Util\Platform; +use Composer\Util\ErrorHandler; error_reporting(-1); @@ -60,6 +61,8 @@ if (function_exists('ini_set')) { Platform::putEnv('COMPOSER_BINARY', realpath($_SERVER['argv'][0])); +ErrorHandler::register(); + // run the command application $application = new Application(); $application->run(); diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index 77f1ba85c..a87f40f8c 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -139,6 +139,8 @@ class Application extends BaseApplication $io = $this->io = new ConsoleIO($input, $output, new HelperSet(array( new QuestionHelper(), ))); + + // Register error handler again to pass it the IO instance ErrorHandler::register($io); if ($input->hasParameterOption('--no-cache')) {