diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 51df014..2d1d273 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,14 +26,15 @@ jobs: # Test active version - php-version: '8.3' phpunit-version: 9 - symfony-version: '^7' - php-version: '8.4' phpunit-version: 9 - symfony-version: '^7' + - php-version: '8.5' + phpunit-version: 9 + symfony-version: '^8' # Test latest unreleased versions - php-version: '8.5' phpunit-version: 9 - symfony-version: '^7' + symfony-version: '^8' stability: 'dev' name: PHP ${{ matrix.php-version }} Test on Symfony ${{ matrix.symfony-version }} ${{ matrix.dependencies}} ${{ matrix.stability }} ${{ matrix.composer-flag }} steps: diff --git a/composer.json b/composer.json index 62ad74d..917f5d5 100644 --- a/composer.json +++ b/composer.json @@ -22,9 +22,9 @@ "require": { "ext-json": "*", "php": "^7.4|^8.0", - "symfony/console": "^5.0|^6.0|^7.0", - "symfony/yaml": "^5.0|^6.0|^7.0", - "symfony/process": "^5.0|^6.0|^7.0", + "symfony/console": "^5.0|^6.0|^7.0|^8.0", + "symfony/yaml": "^5.0|^6.0|^7.0|^8.0", + "symfony/process": "^5.0|^6.0|^7.0|^8.0", "composer/semver": "^3.4" }, "autoload": { @@ -41,7 +41,7 @@ }, "extra": { "branch-alias": { - "dev-master": "1.3-dev" + "dev-main": "1.8-dev" } } } diff --git a/src/Liip/RMT/Application.php b/src/Liip/RMT/Application.php index 080ab12..bf6e2e2 100644 --- a/src/Liip/RMT/Application.php +++ b/src/Liip/RMT/Application.php @@ -19,6 +19,7 @@ use Liip\RMT\Command\ConfigCommand; use Liip\RMT\Command\InitCommand; use Liip\RMT\Output\Output; +use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Application as BaseApplication; @@ -47,13 +48,13 @@ public function __construct() // Add all command, in a controlled way and render exception if any try { // Add the default command - $this->add(new InitCommand()); + $this->bcAddCommand(new InitCommand()); // Add command that require the config file if (file_exists($this->getConfigFilePath())) { - $this->add(new ReleaseCommand()); - $this->add(new CurrentCommand()); - $this->add(new ChangesCommand()); - $this->add(new ConfigCommand()); + $this->bcAddCommand(new ReleaseCommand()); + $this->bcAddCommand(new CurrentCommand()); + $this->bcAddCommand(new ChangesCommand()); + $this->bcAddCommand(new ConfigCommand()); } } catch (\Exception $e) { $output = new Output(); @@ -183,4 +184,27 @@ public function asText($namespace = null, $raw = false) return implode(PHP_EOL, $messages); } + + /** + * Can be removed when we remove support for Symfony console < 7.4. + * + * When removing, change the calls to bcAddCommand to addCommand. + * + * @param callable|Command $command + */ + private function bcAddCommand($command): void + { + /* @phpstan-ignore function.alreadyNarrowedType */ + if (method_exists($this, 'addCommand')) { + $this->addCommand($command); + + return; + } + + if (!$command instanceof Command) { + throw new \InvalidArgumentException('Until we remove support for symfony console < 7.4, all commands must extend the base class'); + } + + $this->add($command); + } }