Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecation notice printed to stdout on PHP 8.1 [Composer 1.10.23] #10345

Closed
dzuelke opened this issue Dec 8, 2021 · 7 comments
Closed

Deprecation notice printed to stdout on PHP 8.1 [Composer 1.10.23] #10345

dzuelke opened this issue Dec 8, 2021 · 7 comments
Labels
Milestone

Comments

@dzuelke
Copy link
Contributor

dzuelke commented Dec 8, 2021

I know the branch is more or less EOL, but... for people running Composer 1 projects, it's still necessary to install them using Composer 1 if there are plugins involved, so...

~ $ PHP_INI_SCAN_DIR= COMPOSER_AUTH= composer --version 2>/dev/null

Deprecated: Return type of Symfony\Component\Console\Helper\HelperSet::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///app/.heroku/php/bin/composer/vendor/symfony/console/Helper/HelperSet.php on line 112
Composer version 1.10.23 2021-10-05 09:44:27

This obviously breaks programmatic use cases where e.g. the Composer version, config, whatever, is determined by code.

Running without 2>/dev/null shows that that deprecation notice is different from the others that get printed (which are also ANSI colored); is this a sub-process or something?

~ $ PHP_INI_SCAN_DIR= COMPOSER_AUTH= composer --version        
PHP Deprecated:  Return type of Symfony\Component\Console\Helper\HelperSet::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///app/.heroku/php/bin/composer/vendor/symfony/console/Helper/HelperSet.php on line 112

Deprecated: Return type of Symfony\Component\Console\Helper\HelperSet::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///app/.heroku/php/bin/composer/vendor/symfony/console/Helper/HelperSet.php on line 112
Deprecation Notice: Return type of Composer\Repository\ArrayRepository::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///app/.heroku/php/bin/composer/src/Composer/Repository/ArrayRepository.php:206
Deprecation Notice: Return type of Composer\Repository\ArrayRepository::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///app/.heroku/php/bin/composer/src/Composer/Repository/ArrayRepository.php:206
Deprecation Notice: Return type of Composer\Repository\ArrayRepository::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///app/.heroku/php/bin/composer/src/Composer/Repository/ArrayRepository.php:206
Composer version 1.10.23 2021-10-05 09:44:27
@Seldaek
Copy link
Member

Seldaek commented Dec 8, 2021

I believe these occur without formatting because they are happening at parsing time and our error handler isn't registered yet.. maybe? Anyway AFAIK it's fixed in 2.x so should be able to backport, although I was hoping I wouldn't have to do that ;)

@Seldaek Seldaek added this to the 1.10 milestone Dec 8, 2021
@Seldaek Seldaek added the Bug label Dec 8, 2021
@dzuelke
Copy link
Contributor Author

dzuelke commented Dec 8, 2021

So is the error_reporting level changed by Composer on startup? I have error_reporting set to exclude E_DEPRECATED, and it's still happening...

@Seldaek
Copy link
Member

Seldaek commented Dec 8, 2021

Yeah there's a gap here between error_reporting set and registering the error handler.. not sure exactly why it'd already load HelperSet nor ArrayRepository before ErrorHandler is registered though

composer/bin/composer

Lines 16 to 70 in 0dbc736

error_reporting(-1);
// Restart without Xdebug
$xdebug = new XdebugHandler('Composer');
$xdebug->check();
unset($xdebug);
if (defined('HHVM_VERSION') && version_compare(HHVM_VERSION, '4.0', '>=')) {
echo 'HHVM 4.0 has dropped support for Composer, please use PHP instead. Aborting.'.PHP_EOL;
exit(1);
}
if (!extension_loaded('iconv') && !extension_loaded('mbstring')) {
echo 'The iconv OR mbstring extension is required and both are missing.'
.PHP_EOL.'Install either of them or recompile php without --disable-iconv.'
.PHP_EOL.'Aborting.'.PHP_EOL;
exit(1);
}
if (function_exists('ini_set')) {
@ini_set('display_errors', '1');
// Set user defined memory limit
if ($memoryLimit = getenv('COMPOSER_MEMORY_LIMIT')) {
@ini_set('memory_limit', $memoryLimit);
} else {
$memoryInBytes = function ($value) {
$unit = strtolower(substr($value, -1, 1));
$value = (int) $value;
switch($unit) {
case 'g':
$value *= 1024;
// no break (cumulative multiplier)
case 'm':
$value *= 1024;
// no break (cumulative multiplier)
case 'k':
$value *= 1024;
}
return $value;
};
$memoryLimit = trim(ini_get('memory_limit'));
// Increase memory_limit if it is lower than 1.5GB
if ($memoryLimit != -1 && $memoryInBytes($memoryLimit) < 1024 * 1024 * 1536) {
@ini_set('memory_limit', '1536M');
}
unset($memoryInBytes);
}
unset($memoryLimit);
}
Platform::putEnv('COMPOSER_BINARY', realpath($_SERVER['argv'][0]));
ErrorHandler::register();

Oh but I see, that's from main branch.

1.10 does it later, that explains things:

ErrorHandler::register($io);

@Seldaek
Copy link
Member

Seldaek commented Dec 8, 2021

if you want to send a PR to 1.10 moving error handler registration to match main branch + also backport the changes in ErrorHandler itself to ignore the 8.1 stuff that'd be great.

if (preg_match('{^Return type of Symfony\\\\.*ReturnTypeWillChange}is', $message)) {
return true;
}
if (strpos(strtr($file, '\\', '/'), 'vendor/symfony/') !== false) {
return true;
}

Probably should apply the Return type of ... filter to Composer namespace too, not worth fixing this stuff properly in 1.x anymore IMO.

@dzuelke
Copy link
Contributor Author

dzuelke commented Dec 8, 2021

okay I'll have a look ASAP; hope I can fix this tonight still (it's blocking my ability to roll out 8.1 on Heroku at the moment, so it's easy to justify :))

@Seldaek
Copy link
Member

Seldaek commented Dec 8, 2021

Don't expect a release until tomorrow tho, but if you can PR by then it increases the chances it gets resolved tomorrow that's for sure :)

@dzuelke
Copy link
Contributor Author

dzuelke commented Dec 9, 2021

PR in #10346!

@Seldaek Seldaek closed this as completed Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants