From f1f6e492c2f6a774672eb141617820cb705a8bb6 Mon Sep 17 00:00:00 2001 From: Oliver Earl <77276885+stickeeoliver@users.noreply.github.com> Date: Fri, 19 Jul 2024 11:51:53 +0100 Subject: [PATCH] ci: Resolve issues with Laravel 11 and PHP 8.3 (#56) * ci: Limit to PHP 8.3. * chore(deps): Use Rector v3. * chore: Update Rector config. * chore(deps): Enforce 8.3 usage. * ci: Update workflow * chore: add pest artifact to gitignore * fix: wrong directory * chore: remove cache as we're not using it * chore: yaml and yml * style(ci): fix indentation * chore(deps): Update minimum required versions to the latest * ci: Don't need extensions --- .editorconfig | 2 +- .github/workflows/php.yaml | 32 ++++++++++---------------- .github/workflows/tests.yaml | 2 +- .gitignore | 1 + composer.json | 8 +++---- rector.php | 44 ++++++++++++++++-------------------- 6 files changed, 38 insertions(+), 51 deletions(-) diff --git a/.editorconfig b/.editorconfig index 1492202..3555c09 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,6 +11,6 @@ trim_trailing_whitespace = true [*.md] trim_trailing_whitespace = false -[*.yml] +[{*.yml,*.yaml}] indent_style = space indent_size = 2 diff --git a/.github/workflows/php.yaml b/.github/workflows/php.yaml index 3831014..7098c73 100644 --- a/.github/workflows/php.yaml +++ b/.github/workflows/php.yaml @@ -5,33 +5,25 @@ on: name: PHP jobs: - php-stan: - name: analyse + php: + name: canary runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - - name: Install dependencies - uses: php-actions/composer@v6 + - name: Setup PHP + uses: shivammathur/setup-php@v2 with: - php_version: "8.1" - - name: Run PHPStan - run: | - vendor/bin/phpstan analyse -c phpstan.ci.neon --error-format=github - php-cs-fixer: - name: fix - needs: php-stan - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Install PHP CS Fixer - uses: php-actions/composer@v6 - - name: Run PHP-CS-Fixer - run: vendor/bin/php-cs-fixer fix + php-version: "8.3" + - name: Install Canary + run: composer install + - name: Run Canary Analyse + run: ./canary analyse -- -c phpstan.ci.neon --error-format=github + - name: Run Canary Fix + run: ./canary fix - name: Commit changes uses: stefanzweifel/git-auto-commit-action@v5 with: - commit_message: "style: PHP CS Fixer" + commit_message: "style: Canary" file_pattern: "**/*.php" disable_globbing: true diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 7c9745d..b64763b 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -10,7 +10,7 @@ jobs: fail-fast: true matrix: os: [ ubuntu-latest ] - php: [ 8.1, 8.2, 8.3 ] + php: [ 8.3 ] name: PHP v${{ matrix.php }} - ${{ matrix.os }} diff --git a/.gitignore b/.gitignore index 0769b1b..b715c31 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ package-lock.json .php-cs-fixer.cache .phpunit.result.cache .env +test-results diff --git a/composer.json b/composer.json index 02f3374..96dc7bf 100644 --- a/composer.json +++ b/composer.json @@ -22,12 +22,12 @@ ], "require": { "composer-runtime-api": "^2.2.2", - "php": "^8.1", + "php": "^8.3", "laravel-zero/framework": "^11.0", "nunomaduro/termwind": "^2.0", - "stickee/larastan-config": "^2.0.1", - "stickee/php-cs-fixer-config": "^2.0", - "stickee/rector-config": "^2.0", + "stickee/larastan-config": "^2.1.1", + "stickee/php-cs-fixer-config": "^2.4.0", + "stickee/rector-config": "^3.0", "symfony/process": "^7.0" }, "require-dev": { diff --git a/rector.php b/rector.php index 5f19187..78472d5 100644 --- a/rector.php +++ b/rector.php @@ -2,34 +2,28 @@ declare(strict_types=1); +use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector; +use Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector; use Rector\Config\RectorConfig; +use Rector\Php80\Rector\FunctionLike\MixedTypeRector; use RectorLaravel\Set\LaravelSetList; use RectorLaravel\Set\LaravelLevelSetList; -use Rector\Set\ValueObject\SetList; -use Rector\Set\ValueObject\LevelSetList; -return static function (RectorConfig $rectorConfig): void { - $rectorConfig->paths([ - __DIR__ . '/app' - ]); - - $rectorConfig->sets([ - SetList::DEAD_CODE, - SetList::CODE_QUALITY, - SetList::CODING_STYLE, - SetList::TYPE_DECLARATION, - LevelSetList::UP_TO_PHP_81, +return RectorConfig::configure() + ->withPaths([__DIR__ . '/app']) + ->withPhpSets() + ->withPreparedSets( + deadCode: true, + codeQuality: true, + codingStyle: true, + typeDeclarations: true, + ) + ->withSets([ LaravelSetList::LARAVEL_CODE_QUALITY, - LaravelLevelSetList::UP_TO_LARAVEL_90, + LaravelLevelSetList::UP_TO_LARAVEL_110, + ]) + ->withSkip([ + EncapsedStringsToSprintfRector::class, // changes "th{$is}" to sprintf('th%s', 'is') + MixedTypeRector::class, // removes docblocks + PostIncDecToPreIncDecRector::class, // changes $i++ to ++$i ]); - - $rectorConfig->skip([ - // \Rector\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector::class, // Adds return types, which may conflict with Laravel built-ins. - \Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector::class, // Removes @param from docblocks. - \Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector::class, // Removes return from docblocks. - \Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector::class, // Changes $i++ to ++$i. - \Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector::class, // Changes "th{$is}" to sprintf('th%s', 'is'). - \Rector\Php80\Rector\FunctionLike\MixedTypeRector::class, // Removes docblocks. - ]); - -};