composer: Fatal error: Uncaught ArgumentCountError: array_merge() does not accept unknown named parameters

Using PHP 8.0.0-dev (e3d06fc79db5af5dba3f4a65bd24b3712711f1ae), I run into the following problem:

PHP 8.0 and Composer 1.10.9

$ php-80 ./tools/composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)

Fatal error: Uncaught ArgumentCountError: array_merge() does not accept unknown named parameters in phar:///usr/local/src/phpunit/tools/composer/src/Composer/DependencyResolver/DefaultPolicy.php:84
Stack trace:
#0 [internal function]: array_merge(phpunit/phpunit: Array)
#1 phar:///usr/local/src/phpunit/tools/composer/src/Composer/DependencyResolver/DefaultPolicy.php(84): call_user_func_array('array_merge', Array)
#2 phar:///usr/local/src/phpunit/tools/composer/src/Composer/DependencyResolver/Solver.php(387): Composer\DependencyResolver\DefaultPolicy->selectPreferredPackages(Object(Composer\DependencyResolver\Pool), Array, Array, 'phpunit/phpunit')
#3 phar:///usr/local/src/phpunit/tools/composer/src/Composer/DependencyResolver/Solver.php(740): Composer\DependencyResolver\Solver->selectAndInstall(1, Array, Array, Object(Composer\DependencyResolver\GenericRule))
#4 phar:///usr/local/src/phpunit/tools/composer/src/Composer/DependencyResolver/Solver.php(231): Composer\DependencyResolver\Solver->runSat(Array)
#5 phar:///usr/local/src/phpunit/tools/composer/src/Composer/Installer.php(489): Composer\DependencyResolver\Solver->solve(Object(Composer\DependencyResolver\Request), false)
#6 phar:///usr/local/src/phpunit/tools/composer/src/Composer/Installer.php(232): Composer\Installer->doInstall(Object(Composer\Repository\InstalledFilesystemRepository), Object(Composer\Repository\CompositeRepository), Object(Composer\Repository\PlatformRepository), Array)
#7 phar:///usr/local/src/phpunit/tools/composer/src/Composer/Command/InstallCommand.php(122): Composer\Installer->run()
#8 phar:///usr/local/src/phpunit/tools/composer/vendor/symfony/console/Command/Command.php(245): Composer\Command\InstallCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 phar:///usr/local/src/phpunit/tools/composer/vendor/symfony/console/Application.php(835): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 phar:///usr/local/src/phpunit/tools/composer/vendor/symfony/console/Application.php(185): Symfony\Component\Console\Application->doRunCommand(Object(Composer\Command\InstallCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 phar:///usr/local/src/phpunit/tools/composer/src/Composer/Console/Application.php(281): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 phar:///usr/local/src/phpunit/tools/composer/vendor/symfony/console/Application.php(117): Composer\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 phar:///usr/local/src/phpunit/tools/composer/src/Composer/Console/Application.php(113): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 phar:///usr/local/src/phpunit/tools/composer/bin/composer(61): Composer\Console\Application->run()
#15 /usr/local/src/phpunit/tools/composer(24): require('phar:///usr/loc...')
#16 {main}
  thrown in phar:///usr/local/src/phpunit/tools/composer/src/Composer/DependencyResolver/DefaultPolicy.php on line 84

PHP 8.0 and Composer 2.0.0-alpha2

$ php-80 ./tools/composer install
No lock file found. Updating dependencies instead of installing from lock file. Use composer update over composer install if you do not have a lock file.
Loading composer repositories with package information
Updating dependencies

Fatal error: Uncaught ArgumentCountError: array_merge() does not accept unknown named parameters in phar:///usr/local/src/phpunit/tools/composer/src/Composer/DependencyResolver/DefaultPolicy.php:63
Stack trace:
#0 phar:///usr/local/src/phpunit/tools/composer/src/Composer/DependencyResolver/DefaultPolicy.php(63): array_merge(doctrine/instantiator: Array)
#1 phar:///usr/local/src/phpunit/tools/composer/src/Composer/DependencyResolver/Solver.php(354): Composer\DependencyResolver\DefaultPolicy->selectPreferredPackages(Object(Composer\DependencyResolver\Pool), Array, 'doctrine/instan...')
#2 phar:///usr/local/src/phpunit/tools/composer/src/Composer/DependencyResolver/Solver.php(664): Composer\DependencyResolver\Solver->selectAndInstall(1, Array, Object(Composer\DependencyResolver\GenericRule))
#3 phar:///usr/local/src/phpunit/tools/composer/src/Composer/DependencyResolver/Solver.php(209): Composer\DependencyResolver\Solver->runSat()
#4 phar:///usr/local/src/phpunit/tools/composer/src/Composer/Installer.php(411): Composer\DependencyResolver\Solver->solve(Object(Composer\DependencyResolver\Request), false)
#5 phar:///usr/local/src/phpunit/tools/composer/src/Composer/Installer.php(249): Composer\Installer->doUpdate(Object(Composer\Repository\InstalledFilesystemRepository), true)
#6 phar:///usr/local/src/phpunit/tools/composer/src/Composer/Command/InstallCommand.php(129): Composer\Installer->run()
#7 phar:///usr/local/src/phpunit/tools/composer/vendor/symfony/console/Command/Command.php(245): Composer\Command\InstallCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 phar:///usr/local/src/phpunit/tools/composer/vendor/symfony/console/Application.php(835): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 phar:///usr/local/src/phpunit/tools/composer/vendor/symfony/console/Application.php(185): Symfony\Component\Console\Application->doRunCommand(Object(Composer\Command\InstallCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 phar:///usr/local/src/phpunit/tools/composer/src/Composer/Console/Application.php(287): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 phar:///usr/local/src/phpunit/tools/composer/vendor/symfony/console/Application.php(117): Composer\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 phar:///usr/local/src/phpunit/tools/composer/src/Composer/Console/Application.php(113): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 phar:///usr/local/src/phpunit/tools/composer/bin/composer(61): Composer\Console\Application->run()
#14 /usr/local/src/phpunit/tools/composer(24): require('phar:///usr/loc...')
#15 {main}
  thrown in phar:///usr/local/src/phpunit/tools/composer/src/Composer/DependencyResolver/DefaultPolicy.php on line 63

The line in question is https://github.com/composer/composer/blob/1.10.9/src/Composer/DependencyResolver/DefaultPolicy.php#L84 or https://github.com/composer/composer/blob/2.0.0-alpha2/src/Composer/DependencyResolver/DefaultPolicy.php#L63, respectively.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 22 (4 by maintainers)

Most upvoted comments

I fixe the like this:

  1. sudo apt install wget php-cli php-zip unzip 2. php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
  2. php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
  3. HASH="$(wget -q -O - https://composer.github.io/installer.sig)"
  4. php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" Out put: Installer verified
  5. sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer Out put: All settings correct for using Composer Downloading… Composer (version 2.0.14) successfully installed to: /usr/local/bin/composer Use it: php /usr/local/bin/composer

It’s Okay.

You can try to tape composer. Diadieuf

Issue is present in V2.0.12, running PHP 8.0 and Ubuntu 20.04 with all packages up to date. Trying to set up Cachet 2.3.9 and running the command composer install --no-dev -o produces this error.

@ahmedatef00 Could you please try upgrading to the latest Composer 1.x version, 1.10.20 and then test again ? You should be able to do so with composer self-update --1

I updated composer, from version 1.6 to 2.0 and everything fixed.

This has already been fixed in #9076. It’s (the only) expected breakage from named parameters.

updating composer solved the issue for me.

@jrfnl
Screenshot from 2021-01-29 20-55-41 it always gives me this error and the documentation is so confusing about this

Thank you, Nikita! Somehow #9076 did not show up in my search.

Solved it with the following commands

curl -sS https://getcomposer.org/installer | php sudo mv composer.phar /usr/bin/composer composer --version

I upgraded my composer by running the following script on my Laravel Forge server (ie: made this a Recipe):

apt-get remove composer
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '906a84df04cea2aa72f40b5f787e49f22d4c2f19492ac310e8cba5b96ac8b64115ac402c8cd292b8a03482574915d1a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
mv composer.phar /usr/local/bin/composer