1
0
Fork 0

Merge pull request #10346 from dzuelke/errorhandler-php81-compat

ErrorHandler PHP 8.1 compatibility
pull/10446/head
Jordi Boggiano 2021-12-09 10:36:59 +01:00 committed by GitHub
commit da4d93759e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 0 deletions

View File

@ -10,6 +10,7 @@ require __DIR__.'/../src/bootstrap.php';
use Composer\Console\Application;
use Composer\XdebugHandler\XdebugHandler;
use Composer\Util\ErrorHandler;
error_reporting(-1);
@ -57,6 +58,8 @@ if (function_exists('ini_set')) {
putenv('COMPOSER_BINARY='.realpath($_SERVER['argv'][0]));
ErrorHandler::register();
// run the command application
$application = new Application();
$application->run();

View File

@ -127,6 +127,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')) {

View File

@ -52,6 +52,15 @@ class ErrorHandler
}
if (self::$io) {
// ignore symfony/* deprecation warnings about return types
// also ignore them from the Composer namespace, as 1.x won't get all that fixed anymore
if (preg_match('{^Return type of (Symfony|Composer)\\\\.*ReturnTypeWillChange}is', $message)) {
return true;
}
if (strpos(strtr($file, '\\', '/'), 'vendor/symfony/') !== false) {
return true;
}
self::$io->writeError('<warning>Deprecation Notice: '.$message.' in '.$file.':'.$line.'</warning>');
if (self::$io->isVerbose()) {
self::$io->writeError('<warning>Stack trace:</warning>');