From 4dd179322b902164fdad7ee1ef7b6453d8ef7a6e Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Wed, 29 Oct 2025 18:23:09 +0100 Subject: [PATCH 1/6] add custom rector to cleanup command usages --- config/rector/sets/cakephp60.php | 3 + ...placeCommandArgsIoWithPropertiesRector.php | 126 ++++++++++++++++++ .../src/Command/TestCommand.php | 8 ++ .../src/Command/TestCommand.php | 12 +- 4 files changed, 147 insertions(+), 2 deletions(-) create mode 100644 src/Rector/Rector/MethodCall/ReplaceCommandArgsIoWithPropertiesRector.php diff --git a/config/rector/sets/cakephp60.php b/config/rector/sets/cakephp60.php index 0aff07bd..9eaf2ea8 100644 --- a/config/rector/sets/cakephp60.php +++ b/config/rector/sets/cakephp60.php @@ -1,6 +1,7 @@ rule(ReplaceCommandArgsIoWithPropertiesRector::class); + // Changes related to the accessible => patchable rename $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [ new MethodCallRename('Cake\ORM\Entity', 'setAccess', 'setPatchable'), diff --git a/src/Rector/Rector/MethodCall/ReplaceCommandArgsIoWithPropertiesRector.php b/src/Rector/Rector/MethodCall/ReplaceCommandArgsIoWithPropertiesRector.php new file mode 100644 index 00000000..f72d2aba --- /dev/null +++ b/src/Rector/Rector/MethodCall/ReplaceCommandArgsIoWithPropertiesRector.php @@ -0,0 +1,126 @@ +args` and `$this->io`', + [ + new CodeSample( + <<<'CODE_SAMPLE' +class TestCommand extends Command +{ + public function execute(Arguments $args, ConsoleIo $io) + { + $io->out('Hello'); + $this->someMethod($args, $io); + } + + protected function someMethod(Arguments $args, ConsoleIo $io): void + { + $someArg = $args->getArgument('some'); + $io->warning('Warn'); + } +} +CODE_SAMPLE, + <<<'CODE_SAMPLE' +class TestCommand extends Command +{ + public function execute() + { + $this->io->out('Hello'); + $this->someMethod(); + } + + protected function someMethod(): void + { + $someArg = $this->args->getArgument('some'); + $this->io->warning('Warn'); + } +} +CODE_SAMPLE, + ), + ], + ); + } + + public function getNodeTypes(): array + { + return [ClassMethod::class]; + } + + public function refactor(Node $node): ?Node + { + if (! $node instanceof ClassMethod) { + return null; + } + + // Skip if class doesn't extend Command (you can expand to check parent name) + $class = $this->betterNodeFinder->findFirstInstanceOf($node, Class_::class); + if (! $this->isObjectType($class, new ObjectType('Cake\Command\Command'))) { + return null; + } + + // Find if params are $args and/or $io + $argsParam = $this->findParam($node, 'args'); + $ioParam = $this->findParam($node, 'io'); + + if (! $argsParam && ! $ioParam) { + return null; + } + + // Replace all `$args` and `$io` usages inside the method body + $this->traverseNodesWithCallable($node->stmts ?? [], function (Node $innerNode) use ($argsParam, $ioParam) { + if ($innerNode instanceof Variable) { + if ($argsParam && $innerNode->name === 'args') { + return new PropertyFetch(new Variable('this'), 'args'); + } + + if ($ioParam && $innerNode->name === 'io') { + return new PropertyFetch(new Variable('this'), 'io'); + } + } + + return null; + }); + + // Remove the params + $node->params = array_filter($node->params, function (Param $param) { + return !in_array($this->getName($param), ['args', 'io'], true); + }); + + return $node; + } + + private function findParam(ClassMethod $method, string $name): ?Param + { + foreach ($method->params as $param) { + if ($this->getName($param) === $name) { + return $param; + } + } + + return null; + } +} diff --git a/tests/test_apps/original/RectorCommand-testApply60/src/Command/TestCommand.php b/tests/test_apps/original/RectorCommand-testApply60/src/Command/TestCommand.php index d307acac..91b64269 100644 --- a/tests/test_apps/original/RectorCommand-testApply60/src/Command/TestCommand.php +++ b/tests/test_apps/original/RectorCommand-testApply60/src/Command/TestCommand.php @@ -13,6 +13,14 @@ public function execute(Arguments $args, ConsoleIo $io) { $io->out('Hello World'); + $this->someMethod($args, $io); + return static::CODE_SUCCESS; } + + protected function someMethod(Arguments $args, ConsoleIo $io): void + { + $someArg = $args->getArgument('some'); + $io->warning('Warning'); + } } diff --git a/tests/test_apps/upgraded/RectorCommand-testApply60/src/Command/TestCommand.php b/tests/test_apps/upgraded/RectorCommand-testApply60/src/Command/TestCommand.php index 164a76fa..00fa4548 100644 --- a/tests/test_apps/upgraded/RectorCommand-testApply60/src/Command/TestCommand.php +++ b/tests/test_apps/upgraded/RectorCommand-testApply60/src/Command/TestCommand.php @@ -9,10 +9,18 @@ class TestCommand extends Command { - public function execute(Arguments $args, \Cake\Console\ConsoleIoInterface $io) + public function execute() { - $io->out('Hello World'); + $this->io->out('Hello World'); + + $this->someMethod(); return static::CODE_SUCCESS; } + + protected function someMethod(): void + { + $someArg = $this->args->getArgument('some'); + $this->io->warning('Warning'); + } } From 7cbf0eaf441ca9d8d8c57a2a2756ad56406b0def Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Wed, 29 Oct 2025 19:07:25 +0100 Subject: [PATCH 2/6] test with disabled custom rector --- config/rector/sets/cakephp60.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/rector/sets/cakephp60.php b/config/rector/sets/cakephp60.php index 9eaf2ea8..547e17e5 100644 --- a/config/rector/sets/cakephp60.php +++ b/config/rector/sets/cakephp60.php @@ -18,7 +18,7 @@ # @see https://book.cakephp.org/6/en/appendices/6-0-migration-guide.html return static function (RectorConfig $rectorConfig): void { - $rectorConfig->rule(ReplaceCommandArgsIoWithPropertiesRector::class); +// $rectorConfig->rule(ReplaceCommandArgsIoWithPropertiesRector::class); // Changes related to the accessible => patchable rename $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [ From 671cda41e90ac45e3f19a4752cde876d5c670af6 Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Sat, 1 Nov 2025 19:48:42 +0100 Subject: [PATCH 3/6] add unit tests --- config/rector/sets/cakephp60.php | 2 +- ...placeCommandArgsIoWithPropertiesRector.php | 36 ++++++++++++-- .../Fixture/fixture.php.inc | 49 +++++++++++++++++++ ...eCommandArgsIoWithPropertiesRectorTest.php | 28 +++++++++++ .../config/configured_rule.php | 9 ++++ .../src/Command/TestCommand.php | 2 - .../src/Command/TestCommand.php | 2 - 7 files changed, 118 insertions(+), 10 deletions(-) create mode 100644 tests/TestCase/Rector/MethodCall/ReplaceCommandArgsIoWithPorpertiesRector/Fixture/fixture.php.inc create mode 100644 tests/TestCase/Rector/MethodCall/ReplaceCommandArgsIoWithPorpertiesRector/ReplaceCommandArgsIoWithPropertiesRectorTest.php create mode 100644 tests/TestCase/Rector/MethodCall/ReplaceCommandArgsIoWithPorpertiesRector/config/configured_rule.php diff --git a/config/rector/sets/cakephp60.php b/config/rector/sets/cakephp60.php index 547e17e5..9eaf2ea8 100644 --- a/config/rector/sets/cakephp60.php +++ b/config/rector/sets/cakephp60.php @@ -18,7 +18,7 @@ # @see https://book.cakephp.org/6/en/appendices/6-0-migration-guide.html return static function (RectorConfig $rectorConfig): void { -// $rectorConfig->rule(ReplaceCommandArgsIoWithPropertiesRector::class); + $rectorConfig->rule(ReplaceCommandArgsIoWithPropertiesRector::class); // Changes related to the accessible => patchable rename $rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [ diff --git a/src/Rector/Rector/MethodCall/ReplaceCommandArgsIoWithPropertiesRector.php b/src/Rector/Rector/MethodCall/ReplaceCommandArgsIoWithPropertiesRector.php index f72d2aba..b447ac4e 100644 --- a/src/Rector/Rector/MethodCall/ReplaceCommandArgsIoWithPropertiesRector.php +++ b/src/Rector/Rector/MethodCall/ReplaceCommandArgsIoWithPropertiesRector.php @@ -3,14 +3,16 @@ namespace Cake\Upgrade\Rector\Rector\MethodCall; +use Cake\Command\Command; use PhpParser\Node; +use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Expr\PropertyFetch; use PhpParser\Node\Expr\Variable; use PhpParser\Node\Param; -use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\ClassMethod; -use PHPStan\Type\ObjectType; +use PHPStan\Reflection\ReflectionProvider; use Rector\PhpParser\Node\BetterNodeFinder; +use Rector\PHPStan\ScopeFetcher; use Rector\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; @@ -19,6 +21,7 @@ final class ReplaceCommandArgsIoWithPropertiesRector extends AbstractRector { public function __construct( protected BetterNodeFinder $betterNodeFinder, + protected ReflectionProvider $reflectionProvider, ) { } @@ -76,9 +79,16 @@ public function refactor(Node $node): ?Node return null; } + // Make sure we are in a class + $scope = ScopeFetcher::fetch($node); + if (!$scope->isInClass()) { + return null; + } + $class = $scope->getClassReflection(); + // Skip if class doesn't extend Command (you can expand to check parent name) - $class = $this->betterNodeFinder->findFirstInstanceOf($node, Class_::class); - if (! $this->isObjectType($class, new ObjectType('Cake\Command\Command'))) { + $baseCommandClass = $this->reflectionProvider->getClass(Command::class); + if ($class->getName() === Command::class || $class->isSubclassOfClass($baseCommandClass) === false) { return null; } @@ -92,6 +102,7 @@ public function refactor(Node $node): ?Node // Replace all `$args` and `$io` usages inside the method body $this->traverseNodesWithCallable($node->stmts ?? [], function (Node $innerNode) use ($argsParam, $ioParam) { + // Replace `$args` and `$io` variables if ($innerNode instanceof Variable) { if ($argsParam && $innerNode->name === 'args') { return new PropertyFetch(new Variable('this'), 'args'); @@ -102,10 +113,25 @@ public function refactor(Node $node): ?Node } } + // Remove `$args` / `$io` from method calls on `$this` + if ( + $innerNode instanceof MethodCall + && $innerNode->var instanceof Variable + && $innerNode->var->name === 'this' + ) { + $innerNode->args = array_values(array_filter( + $innerNode->args, + fn(Node\Arg $arg) => !($arg->value instanceof Variable && + in_array($arg->value->name, ['args', 'io'], true)), + )); + + return $innerNode; + } + return null; }); - // Remove the params + // Remove the parameters themselves $node->params = array_filter($node->params, function (Param $param) { return !in_array($this->getName($param), ['args', 'io'], true); }); diff --git a/tests/TestCase/Rector/MethodCall/ReplaceCommandArgsIoWithPorpertiesRector/Fixture/fixture.php.inc b/tests/TestCase/Rector/MethodCall/ReplaceCommandArgsIoWithPorpertiesRector/Fixture/fixture.php.inc new file mode 100644 index 00000000..40928ced --- /dev/null +++ b/tests/TestCase/Rector/MethodCall/ReplaceCommandArgsIoWithPorpertiesRector/Fixture/fixture.php.inc @@ -0,0 +1,49 @@ +out('Hello World'); + $this->someMethod($args, $io); + return static::CODE_SUCCESS; + } + + protected function someMethod(Arguments $args, ConsoleIo $io): void + { + $someArg = $args->getArgument('some'); + $io->warning('Warning'); + } +} +?> +----- +io->out('Hello World'); + $this->someMethod(); + return static::CODE_SUCCESS; + } + + protected function someMethod(): void + { + $someArg = $this->args->getArgument('some'); + $this->io->warning('Warning'); + } +} +?> diff --git a/tests/TestCase/Rector/MethodCall/ReplaceCommandArgsIoWithPorpertiesRector/ReplaceCommandArgsIoWithPropertiesRectorTest.php b/tests/TestCase/Rector/MethodCall/ReplaceCommandArgsIoWithPorpertiesRector/ReplaceCommandArgsIoWithPropertiesRectorTest.php new file mode 100644 index 00000000..24b1fe95 --- /dev/null +++ b/tests/TestCase/Rector/MethodCall/ReplaceCommandArgsIoWithPorpertiesRector/ReplaceCommandArgsIoWithPropertiesRectorTest.php @@ -0,0 +1,28 @@ +doTestFile($filePath); + } + + public static function provideData(): Iterator + { + return self::yieldFilesFromDirectory(__DIR__ . '/Fixture'); + } + + public function provideConfigFilePath(): string + { + return __DIR__ . '/config/configured_rule.php'; + } +} diff --git a/tests/TestCase/Rector/MethodCall/ReplaceCommandArgsIoWithPorpertiesRector/config/configured_rule.php b/tests/TestCase/Rector/MethodCall/ReplaceCommandArgsIoWithPorpertiesRector/config/configured_rule.php new file mode 100644 index 00000000..f492ea49 --- /dev/null +++ b/tests/TestCase/Rector/MethodCall/ReplaceCommandArgsIoWithPorpertiesRector/config/configured_rule.php @@ -0,0 +1,9 @@ +rule(ReplaceCommandArgsIoWithPropertiesRector::class); +}; diff --git a/tests/test_apps/original/RectorCommand-testApply60/src/Command/TestCommand.php b/tests/test_apps/original/RectorCommand-testApply60/src/Command/TestCommand.php index 91b64269..d4708c52 100644 --- a/tests/test_apps/original/RectorCommand-testApply60/src/Command/TestCommand.php +++ b/tests/test_apps/original/RectorCommand-testApply60/src/Command/TestCommand.php @@ -12,9 +12,7 @@ class TestCommand extends Command public function execute(Arguments $args, ConsoleIo $io) { $io->out('Hello World'); - $this->someMethod($args, $io); - return static::CODE_SUCCESS; } diff --git a/tests/test_apps/upgraded/RectorCommand-testApply60/src/Command/TestCommand.php b/tests/test_apps/upgraded/RectorCommand-testApply60/src/Command/TestCommand.php index 00fa4548..d29ffb01 100644 --- a/tests/test_apps/upgraded/RectorCommand-testApply60/src/Command/TestCommand.php +++ b/tests/test_apps/upgraded/RectorCommand-testApply60/src/Command/TestCommand.php @@ -12,9 +12,7 @@ class TestCommand extends Command public function execute() { $this->io->out('Hello World'); - $this->someMethod(); - return static::CODE_SUCCESS; } From 701cbc5b46826702cb74d2c4b6e6b17aa5d1f539 Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Sat, 1 Nov 2025 19:59:04 +0100 Subject: [PATCH 4/6] adjust CI --- .github/workflows/ci.yml | 150 +++++++++++++++++---------------------- 1 file changed, 67 insertions(+), 83 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 022fa37b..af086c7b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,13 +2,9 @@ name: CI on: push: - branches: - - 3.x - - 4.x - - 5.x + branches: [3.x, 4.x, 5.x] pull_request: - branches: - - '*' + branches: ['*'] workflow_dispatch: jobs: @@ -17,92 +13,80 @@ jobs: strategy: fail-fast: false matrix: - php-version: ['8.1'] + php-version: ['8.1', '8.2', '8.3', '8.4'] prefer-lowest: [''] include: - php-version: '8.1' prefer-lowest: 'prefer-lowest' steps: - - uses: actions/checkout@v5 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-version }} - extensions: mbstring, intl - coverage: pcov - - - name: Get composer cache directory - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - - name: Get date part for cache key - id: key-date - run: echo "::set-output name=date::$(date +'%Y-%m')" - - - name: Cache composer dependencies - uses: actions/cache@v4 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }} - - - name: Composer Install - run: | - if ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then - make install-dev-lowest - elif ${{ matrix.php-version == '8.1' }}; then - make install-dev-ignore-reqs - else - make install-dev - fi - - - name: Setup problem matchers for PHPUnit - if: matrix.php-version == '8.1' - run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - - - name: Run PHPUnit - run: | - if [[ ${{ matrix.php-version }} == '8.1' ]]; then - export CODECOVERAGE=1 && vendor/bin/phpunit --display-incomplete --display-skipped --coverage-clover=coverage.xml - else - vendor/bin/phpunit - fi - - - name: Submit code coverage - if: matrix.php-version == '8.1' - uses: codecov/codecov-action@v5 + - uses: actions/checkout@v5 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: mbstring, intl + coverage: pcov + + - name: Cache composer dependencies + id: composer-cache + uses: actions/cache@v4 + with: + path: ~/.composer/cache + key: ${{ runner.os }}-composer-${{ matrix.php-version }}-${{ matrix.prefer-lowest }}-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer-${{ matrix.php-version }}-${{ matrix.prefer-lowest }}- + + - name: Composer install + run: | + if [[ "${{ matrix.prefer-lowest }}" == "prefer-lowest" ]]; then + make install-dev-lowest + elif [[ "${{ matrix.php-version }}" == "8.1" ]]; then + make install-dev-ignore-reqs + else + make install-dev + fi + + - name: Setup problem matchers for PHPUnit + if: matrix.php-version == '8.1' + run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - name: Run PHPUnit + run: | + if [[ "${{ matrix.php-version }}" == "8.1" && "${{ matrix.prefer-lowest }}" != "prefer-lowest" ]]; then + export CODECOVERAGE=1 + vendor/bin/phpunit --display-incomplete --display-skipped --coverage-clover=coverage.xml + else + vendor/bin/phpunit + fi + + - name: Submit code coverage + if: matrix.php-version == '8.1' && matrix.prefer-lowest != 'prefer-lowest' + uses: codecov/codecov-action@v5 cs-stan: name: Coding Standard & Static Analysis runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v5 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.1' - extensions: mbstring, intl - coverage: none - - - name: Get composer cache directory - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - - name: Get date part for cache key - id: key-date - run: echo "::set-output name=date::$(date +'%Y-%m')" - - - name: Cache composer dependencies - uses: actions/cache@v4 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }} - - - name: Composer install - run: make install-dev - - - name: Run PHP CodeSniffer - run: vendor/bin/phpcs --report=checkstyle + - uses: actions/checkout@v5 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.1' + extensions: mbstring, intl + coverage: none + + - name: Cache composer dependencies + uses: actions/cache@v4 + with: + path: ~/.composer/cache + key: ${{ runner.os }}-composer-8.1-${{ hashFiles('**/composer.lock') }} + + - name: Composer install + run: make install-dev + + - name: Run PHP CodeSniffer + run: vendor/bin/phpcs --report=checkstyle From d68f12bf1aafd40ff875fd94252d444f86998a26 Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Sat, 1 Nov 2025 20:01:50 +0100 Subject: [PATCH 5/6] adjust composer.json --- .github/workflows/ci.yml | 16 ++++++++-------- composer.json | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index af086c7b..f346700d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,10 +13,10 @@ jobs: strategy: fail-fast: false matrix: - php-version: ['8.1', '8.2', '8.3', '8.4'] + php-version: ['8.2', '8.3', '8.4'] prefer-lowest: [''] include: - - php-version: '8.1' + - php-version: '8.2' prefer-lowest: 'prefer-lowest' steps: @@ -42,19 +42,19 @@ jobs: run: | if [[ "${{ matrix.prefer-lowest }}" == "prefer-lowest" ]]; then make install-dev-lowest - elif [[ "${{ matrix.php-version }}" == "8.1" ]]; then + elif [[ "${{ matrix.php-version }}" == "8.2" ]]; then make install-dev-ignore-reqs else make install-dev fi - name: Setup problem matchers for PHPUnit - if: matrix.php-version == '8.1' + if: matrix.php-version == '8.2' run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - name: Run PHPUnit run: | - if [[ "${{ matrix.php-version }}" == "8.1" && "${{ matrix.prefer-lowest }}" != "prefer-lowest" ]]; then + if [[ "${{ matrix.php-version }}" == "8.2" && "${{ matrix.prefer-lowest }}" != "prefer-lowest" ]]; then export CODECOVERAGE=1 vendor/bin/phpunit --display-incomplete --display-skipped --coverage-clover=coverage.xml else @@ -62,7 +62,7 @@ jobs: fi - name: Submit code coverage - if: matrix.php-version == '8.1' && matrix.prefer-lowest != 'prefer-lowest' + if: matrix.php-version == '8.2' && matrix.prefer-lowest != 'prefer-lowest' uses: codecov/codecov-action@v5 cs-stan: @@ -75,7 +75,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.1' + php-version: '8.2' extensions: mbstring, intl coverage: none @@ -83,7 +83,7 @@ jobs: uses: actions/cache@v4 with: path: ~/.composer/cache - key: ${{ runner.os }}-composer-8.1-${{ hashFiles('**/composer.lock') }} + key: ${{ runner.os }}-composer-8.2-${{ hashFiles('**/composer.lock') }} - name: Composer install run: make install-dev diff --git a/composer.json b/composer.json index 9f42ee59..e3c24786 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "homepage": "https://cakephp.org", "license": "MIT", "require": { - "php": "^8.1", + "php": "^8.2", "cakephp/console": "^5.1.5", "nette/utils": "^4.0", "rector/rector": "~2.2.3", From 3f1ce70d5b512ba493f740624fa3d29bd94bfddf Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Sat, 1 Nov 2025 20:04:41 +0100 Subject: [PATCH 6/6] Revert "adjust composer.json" This reverts commit d68f12bf1aafd40ff875fd94252d444f86998a26. --- .github/workflows/ci.yml | 16 ++++++++-------- composer.json | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f346700d..af086c7b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,10 +13,10 @@ jobs: strategy: fail-fast: false matrix: - php-version: ['8.2', '8.3', '8.4'] + php-version: ['8.1', '8.2', '8.3', '8.4'] prefer-lowest: [''] include: - - php-version: '8.2' + - php-version: '8.1' prefer-lowest: 'prefer-lowest' steps: @@ -42,19 +42,19 @@ jobs: run: | if [[ "${{ matrix.prefer-lowest }}" == "prefer-lowest" ]]; then make install-dev-lowest - elif [[ "${{ matrix.php-version }}" == "8.2" ]]; then + elif [[ "${{ matrix.php-version }}" == "8.1" ]]; then make install-dev-ignore-reqs else make install-dev fi - name: Setup problem matchers for PHPUnit - if: matrix.php-version == '8.2' + if: matrix.php-version == '8.1' run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - name: Run PHPUnit run: | - if [[ "${{ matrix.php-version }}" == "8.2" && "${{ matrix.prefer-lowest }}" != "prefer-lowest" ]]; then + if [[ "${{ matrix.php-version }}" == "8.1" && "${{ matrix.prefer-lowest }}" != "prefer-lowest" ]]; then export CODECOVERAGE=1 vendor/bin/phpunit --display-incomplete --display-skipped --coverage-clover=coverage.xml else @@ -62,7 +62,7 @@ jobs: fi - name: Submit code coverage - if: matrix.php-version == '8.2' && matrix.prefer-lowest != 'prefer-lowest' + if: matrix.php-version == '8.1' && matrix.prefer-lowest != 'prefer-lowest' uses: codecov/codecov-action@v5 cs-stan: @@ -75,7 +75,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.2' + php-version: '8.1' extensions: mbstring, intl coverage: none @@ -83,7 +83,7 @@ jobs: uses: actions/cache@v4 with: path: ~/.composer/cache - key: ${{ runner.os }}-composer-8.2-${{ hashFiles('**/composer.lock') }} + key: ${{ runner.os }}-composer-8.1-${{ hashFiles('**/composer.lock') }} - name: Composer install run: make install-dev diff --git a/composer.json b/composer.json index e3c24786..9f42ee59 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "homepage": "https://cakephp.org", "license": "MIT", "require": { - "php": "^8.2", + "php": "^8.1", "cakephp/console": "^5.1.5", "nette/utils": "^4.0", "rector/rector": "~2.2.3",