Skip to content

Commit

Permalink
ci: Resolve issues with Laravel 11 and PHP 8.3 (#56)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
stickeeoliver authored Jul 19, 2024
1 parent eed7373 commit f1f6e49
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false

[*.yml]
[{*.yml,*.yaml}]
indent_style = space
indent_size = 2
32 changes: 12 additions & 20 deletions .github/workflows/php.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ package-lock.json
.php-cs-fixer.cache
.phpunit.result.cache
.env
test-results
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
44 changes: 19 additions & 25 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
]);

};

0 comments on commit f1f6e49

Please sign in to comment.