Skip to content

Fatal error in some Composer commands due to transitive dependency #23

@astratagem

Description

@astratagem

Hello!

I've been running into a fatal error while running some Composer commands like composer outdated which I'm guessing do some sort of evaluation of code:

Fatal error: Declaration of Symfony\Component\Console\Input\ArrayInput::hasParameterOption(array|string $values, bool $onlyParams = false): bool must be compatible with Symfony\Component\Console\Input\InputInterface::hasParameterOption($values, bool $onlyParams = false) in /path/to/project/apps/wordpress/vendor/symfony/console/Input/ArrayInput.php on line 56

I managed to track the error down to a dependency of alleyinteractive/wp-caper and then this autoloader -- when I disable the autoloader plugin or remove wp-caper, the fatal error goes away.

This does not happen while running the more common commands like composer update, which is why I hadn't noticed it immediately. I've observed this error both in a ddev-provisioned container (via ddev composer) as well as using my local composer. Versions:

$ which php composer && php --version && composer --version
/etc/profiles/per-user/cdom/bin/php
/nix/store/30h8w7xydw1zb4sca6y3qmaz1xkxxwh6-devshell-dir/bin/composer
PHP 8.0.27 (cli) (built: Jan 29 2023 01:53:08) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.27, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.27, Copyright (c), by Zend Technologies
Composer version 2.5.1 2022-12-22 15:33:54

$ ddev php --version && composer --version
PHP 8.0.26 (cli) (built: Dec  5 2022 21:59:43) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.26, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.26, Copyright (c), by Zend Technologies
Composer version 2.5.1 2022-12-22 15:33:54

I'm guessing the fix might just be updating the problematic dependency, but that's just a guess.

Here's a demonstration of the console output – non-error output of composer outdated isn't relevant to this issue but I've left it intact for posterity:

$ composer outdated

Fatal error: Declaration of Symfony\Component\Console\Input\ArrayInput::hasParameterOption(array|string $values, bool $onlyParams = false): bool must be compatible with Symfony\Component\Console\Input\InputInterface::hasParameterOption($values, bool $onlyParams = false) in /Users/cdom/Developer/work/projects/logan-center/apps/wordpress/vendor/symfony/console/Input/ArrayInput.php on line 56

$ composer remove alleyinteractive/wp-caper
./composer.json has been updated
Running composer update alleyinteractive/wp-caper
Loading composer repositories with package information
Updating dependencies
Lock file operations: 0 installs, 0 updates, 3 removals
  - Removing alleyinteractive/composer-wordpress-autoloader (v1.0.0)
  - Removing alleyinteractive/wordpress-autoloader (v1.1.1)
  - Removing alleyinteractive/wp-caper (v2.0.1)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 0 updates, 3 removals
  - Removing alleyinteractive/wp-caper (v2.0.1)
  - Removing alleyinteractive/wordpress-autoloader (v1.1.1)
Removed WordPress autoloader.
  - Removing alleyinteractive/composer-wordpress-autoloader (v1.0.0)
Generating optimized autoload files
59 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
No security vulnerability advisories found

$ composer outdated
Color legend:
- patch or minor release available - update recommended
- major release available - update possible

Direct dependencies required in composer.json:
wp-graphql/wp-graphql-acf         v0.3.5  v0.6.1  Advanced Custom Fields bindings for wp-graphql
wpackagist-plugin/autodescription 4.2.7.1 4.2.8

Transitive dependencies not required in composer.json:
appsero/client                    v1.2.1  v1.2.2  Appsero Client
brick/math                        0.10.2  0.11.0  Arbitrary-precision arithmetic library
illuminate/conditionable          v9.52.4 v10.1.5 The Illuminate Conditionable package.
webonyx/graphql-php               v14.9.0 v15.2.0 A PHP port of GraphQL reference implementation

$ composer require alleyinteractive/wp-caper
./composer.json has been updated
Running composer update alleyinteractive/wp-caper
Loading composer repositories with package information
Updating dependencies
Lock file operations: 3 installs, 0 updates, 0 removals
  - Locking alleyinteractive/composer-wordpress-autoloader (v1.0.0)
  - Locking alleyinteractive/wordpress-autoloader (v1.1.1)
  - Locking alleyinteractive/wp-caper (v2.0.1)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 3 installs, 0 updates, 0 removals
  - Installing alleyinteractive/wordpress-autoloader (v1.1.1): Extracting archive
  - Installing alleyinteractive/composer-wordpress-autoloader (v1.0.0): Extracting archive
  - Installing alleyinteractive/wp-caper (v2.0.1): Extracting archive
Generating optimized autoload files
🎉 WordPress autoloader generated
59 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
No security vulnerability advisories found
Using version ^2.0 for alleyinteractive/wp-caper

$ composer outdated

Fatal error: Declaration of Symfony\Component\Console\Input\ArrayInput::hasParameterOption(array|string $values, bool $onlyParams = false): bool must be compatible with Symfony\Component\Console\Input\InputInterface::hasParameterOption($values, bool $onlyParams = false) in /Users/cdom/Developer/work/projects/logan-center/apps/wordpress/vendor/symfony/console/Input/ArrayInput.php on line 56

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions