Skip to content

Compatibility issue with symfony/console >= 7: CompileCommand::execute() missing return type : int #28

@pminf

Description

@pminf

When using a command like compile, compile:list or compile:watch with Drupal 11, Composer fails with a fatal error due to an incompatible method signature.

Error message:

PHP Fatal error: Declaration of Civi\CompilePlugin\Command\CompileCommand::execute(Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output) must be compatible with Symfony\Component\Console\Command\Command::execute(Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output): int in /var/www/[...]/vendor/civicrm/composer-compile-plugin/src/Command/CompileCommand.php on line 54

This happens because Drupal 11 is using symfony/console in version 7.x, which requires the execute() method in console commands to declare a return type (: int), but the plugin currently doesn’t.

Steps to reproduce:

  1. Install CiviCRM with drupal/core >= 11.2 including symfony/console >= 7.0
  2. Include civicrm/composer-compile-plugin (latest release, e.g. v0.21).
  3. Run any Composer command that triggers the plugin command.

Suggested fix:

Update Civi\CompilePlugin\Command\CompileCommand::execute() to:

protected function execute(InputInterface $input, OutputInterface $output): int
{
    // existing code ...
    return Command::SUCCESS;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions