Fatal error: Declaration of Illuminate\Console\Application::add (WP CLI)

Hi there.
I’v got this error after upgrade packages. Seems this is related with symfony/console v7+.

I use wp cli with php-stubs/wp-cli-stubs package

public function boot(): void
{
if (defined(‘WP_CLI’) && WP_CLI) {
WP_CLI::add_command(‘elastic’, $this);
}
}

Any ways to avoid error after updating? Thanks :slight_smile:

1 Like

Elaborate and provide reproduction steps

  1. composer update
  2. add new provider
use Roots\Acorn\Sage\SageServiceProvider;
use WP_CLI;

class MyCoolProvider extends SageServiceProvider
{
        public function boot(): void {        
            if (defined('WP_CLI') && WP_CLI) {
                WP_CLI::add_command('my_command_name', $this);
            }
        }
        public function test_command() {
            WP_CLI::log('its me');
        }
}

run wp my_command_name test_command