diff --git a/.github/workflows/grumphp.yml b/.github/workflows/grumphp.yml index f3d802008..9373afd67 100644 --- a/.github/workflows/grumphp.yml +++ b/.github/workflows/grumphp.yml @@ -45,10 +45,14 @@ jobs: restore-keys: ${{ runner.os }}-composer- - name: Install dependencies (highest) if: matrix.composer-deps == 'highest' - run: composer update --prefer-dist --no-progress --no-suggest + run: | + composer config platform.php ${{ matrix.php-versions }} + composer update --prefer-dist --no-progress --no-suggest --ignore-platform-req=php+ - name: Install dependencies (lowest) if: matrix.composer-deps == 'lowest' - run: composer update --prefer-dist --no-progress --no-suggest --prefer-lowest + run: | + composer config platform.php ${{ matrix.php-versions }} + composer update --prefer-dist --no-progress --no-suggest --prefer-lowest --ignore-platform-req=php+ - name: Install dependencies (lock) if: matrix.composer-deps == 'lock' run: | diff --git a/src/Configuration/LoaderFactory.php b/src/Configuration/LoaderFactory.php index 5012f411c..6a54333ae 100644 --- a/src/Configuration/LoaderFactory.php +++ b/src/Configuration/LoaderFactory.php @@ -26,16 +26,22 @@ final class LoaderFactory public static function createLoader(ContainerBuilder $container, array $paths = []): DelegatingLoader { $locator = new FileLocator($paths); - $resolver = new LoaderResolver([ - $xmlLoader = new XmlFileLoader($container, $locator, self::ENV), + + /** @Deprecated - Remove in a future version of PHP where SF > 7.4 */ + $xmlLoader = class_exists(XmlFileLoader::class) + ? new XmlFileLoader($container, $locator, self::ENV) + : null; + + $resolver = new LoaderResolver(array_filter([ + $xmlLoader, $yamlLoader = new YamlFileLoader($container, $locator, self::ENV), $iniLoader = new IniFileLoader($container, $locator, self::ENV), new GlobFileLoader($container, $locator, self::ENV), new DirectoryLoader($container, $locator, self::ENV), - new DistFileLoader($xmlLoader), + $xmlLoader ? new DistFileLoader($xmlLoader) : null, new DistFileLoader($yamlLoader), new DistFileLoader($iniLoader), - ]); + ])); return new DelegatingLoader($resolver); } diff --git a/src/Console/Command/ConfigureCommand.php b/src/Console/Command/ConfigureCommand.php index 85d3fec8a..43a63ac06 100644 --- a/src/Console/Command/ConfigureCommand.php +++ b/src/Console/Command/ConfigureCommand.php @@ -8,6 +8,7 @@ use GrumPHP\Configuration\Resolver\TaskConfigResolver; use GrumPHP\Util\Filesystem; use GrumPHP\Util\Paths; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputInterface; @@ -17,10 +18,9 @@ use Symfony\Component\Console\Question\ConfirmationQuestion; use Symfony\Component\Yaml\Yaml; +#[AsCommand(name: 'configure', description: 'Create a grumphp configuration file')] class ConfigureCommand extends Command { - const COMMAND_NAME = 'configure'; - /** * @var TaskConfigResolver */ @@ -51,11 +51,6 @@ public function __construct(TaskConfigResolver $taskConfigResolver, Filesystem $ $this->paths = $paths; } - public static function getDefaultName(): string - { - return self::COMMAND_NAME; - } - protected function configure(): void { $this->addOption( diff --git a/src/Console/Command/Git/CommitMsgCommand.php b/src/Console/Command/Git/CommitMsgCommand.php index 23ade74a0..1f907fa82 100644 --- a/src/Console/Command/Git/CommitMsgCommand.php +++ b/src/Console/Command/Git/CommitMsgCommand.php @@ -6,7 +6,6 @@ use GrumPHP\Collection\FilesCollection; use GrumPHP\Collection\TestSuiteCollection; -use GrumPHP\IO\IOFactory; use GrumPHP\IO\IOInterface; use GrumPHP\Locator\ChangedFiles; use GrumPHP\Locator\StdInFiles; @@ -16,6 +15,7 @@ use GrumPHP\Util\Filesystem; use GrumPHP\Util\Paths; use SplFileInfo; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -25,9 +25,9 @@ /** * This command runs the git commit-msg hook. */ +#[AsCommand(name: 'git:commit-msg', description: 'Executed by the commit-msg commit hook')] class CommitMsgCommand extends Command { - const COMMAND_NAME = 'git:commit-msg'; const EXIT_CODE_OK = 0; const EXIT_CODE_NOK = 1; @@ -83,14 +83,8 @@ public function __construct( $this->io = $io; } - public static function getDefaultName(): string - { - return self::COMMAND_NAME; - } - protected function configure(): void { - $this->setDescription('Executed by the commit-msg commit hook'); $this->addOption('git-user', null, InputOption::VALUE_REQUIRED, 'The configured git user name.', ''); $this->addOption('git-email', null, InputOption::VALUE_REQUIRED, 'The configured git email.', ''); $this->addArgument('commit-msg-file', InputArgument::REQUIRED, 'The configured commit message file.'); diff --git a/src/Console/Command/Git/DeInitCommand.php b/src/Console/Command/Git/DeInitCommand.php index ea77d1426..ce8b5e760 100644 --- a/src/Console/Command/Git/DeInitCommand.php +++ b/src/Console/Command/Git/DeInitCommand.php @@ -6,6 +6,7 @@ use GrumPHP\Util\Filesystem; use GrumPHP\Util\Paths; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -13,10 +14,9 @@ /** * This command is responsible for removing all the configured hooks. */ +#[AsCommand(name: 'git:deinit', description: 'Removes the commit hooks')] class DeInitCommand extends Command { - const COMMAND_NAME = 'git:deinit'; - /** * @var array */ @@ -35,11 +35,6 @@ class DeInitCommand extends Command */ private $paths; - public static function getDefaultName(): string - { - return self::COMMAND_NAME; - } - public function __construct( Filesystem $filesystem, Paths $paths @@ -50,10 +45,6 @@ public function __construct( $this->paths = $paths; } - protected function configure(): void - { - $this->setDescription('Removes the commit hooks'); - } public function execute(InputInterface $input, OutputInterface $output): int { diff --git a/src/Console/Command/Git/InitCommand.php b/src/Console/Command/Git/InitCommand.php index 1aadf49bd..a0de7dd2a 100644 --- a/src/Console/Command/Git/InitCommand.php +++ b/src/Console/Command/Git/InitCommand.php @@ -11,6 +11,7 @@ use GrumPHP\Util\Filesystem; use GrumPHP\Util\Paths; use RuntimeException; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -18,10 +19,9 @@ /** * This command is responsible for enabling all the configured hooks. */ +#[AsCommand(name: 'git:init', description: 'Registers the Git hooks')] class InitCommand extends Command { - const COMMAND_NAME = 'git:init'; - /** * @var array */ @@ -70,16 +70,6 @@ public function __construct( $this->paths = $paths; } - public static function getDefaultName(): string - { - return self::COMMAND_NAME; - } - - protected function configure(): void - { - $this->setDescription('Registers the Git hooks'); - } - public function execute(InputInterface $input, OutputInterface $output): int { $this->input = $input; diff --git a/src/Console/Command/Git/PreCommitCommand.php b/src/Console/Command/Git/PreCommitCommand.php index a3aed64fe..2e00bba15 100644 --- a/src/Console/Command/Git/PreCommitCommand.php +++ b/src/Console/Command/Git/PreCommitCommand.php @@ -6,13 +6,13 @@ use GrumPHP\Collection\FilesCollection; use GrumPHP\Collection\TestSuiteCollection; -use GrumPHP\IO\IOFactory; use GrumPHP\IO\IOInterface; use GrumPHP\Locator\ChangedFiles; use GrumPHP\Locator\StdInFiles; use GrumPHP\Runner\TaskRunner; use GrumPHP\Runner\TaskRunnerContext; use GrumPHP\Task\Context\GitPreCommitContext; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -21,9 +21,9 @@ /** * This command runs the git pre-commit hook. */ +#[AsCommand(name: 'git:pre-commit', description: 'Executed by the pre-commit hook')] class PreCommitCommand extends Command { - const COMMAND_NAME = 'git:pre-commit'; const EXIT_CODE_OK = 0; const EXIT_CODE_NOK = 1; @@ -65,14 +65,8 @@ public function __construct( $this->io = $io; } - public static function getDefaultName(): string - { - return self::COMMAND_NAME; - } - protected function configure(): void { - $this->setDescription('Executed by the pre-commit hook'); $this->addOption( 'skip-success-output', null, diff --git a/src/Console/Command/RunCommand.php b/src/Console/Command/RunCommand.php index fc0792a1c..e65ade451 100644 --- a/src/Console/Command/RunCommand.php +++ b/src/Console/Command/RunCommand.php @@ -6,7 +6,6 @@ use GrumPHP\Collection\FilesCollection; use GrumPHP\Collection\TestSuiteCollection; -use GrumPHP\IO\IOFactory; use GrumPHP\IO\IOInterface; use GrumPHP\Locator\RegisteredFiles; use GrumPHP\Locator\StdInFiles; @@ -14,14 +13,15 @@ use GrumPHP\Runner\TaskRunnerContext; use GrumPHP\Task\Context\RunContext; use GrumPHP\Util\Str; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +#[AsCommand(name: 'run', description: 'Run configured tasks')] class RunCommand extends Command { - const COMMAND_NAME = 'run'; const EXIT_CODE_OK = 0; const EXIT_CODE_NOK = 1; @@ -63,11 +63,6 @@ public function __construct( $this->io = $io; } - public static function getDefaultName(): string - { - return self::COMMAND_NAME; - } - protected function configure(): void { $this->addOption(