-
-
Notifications
You must be signed in to change notification settings - Fork 436
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rector: added dependency and basic rules (#4213)
* Added rector and basic rules * Fixes --------- Co-authored-by: Colin Mollenhour <colin@mollenhour.com>
- Loading branch information
1 parent
e7b47ab
commit 75cd467
Showing
24 changed files
with
174 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,6 +83,7 @@ jobs: | |
**phpcs** | ||
**php-cs-fixer** | ||
**phpstan** | ||
rector.php | ||
tests/ | ||
phpunit* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Rector | ||
|
||
on: | ||
workflow_call: | ||
# Allow manually triggering the workflow. | ||
workflow_dispatch: | ||
|
||
jobs: | ||
rector: | ||
name: Validation | ||
runs-on: [ubuntu-latest] | ||
|
||
steps: | ||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: 7.4 | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Get composer cache directory | ||
id: composer-cache | ||
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | ||
|
||
- name: Cache dependencies | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: ${{ runner.os }}-composer- | ||
|
||
- name: Install dependencies | ||
run: composer install --prefer-dist --no-progress --ignore-platform-req=ext-* | ||
|
||
- name: Rector | ||
run: php vendor/bin/rector process --dry-run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\CodeQuality\Rector as CodeQuality; | ||
use Rector\DeadCode\Rector as DeadCode; | ||
use Rector\Config\RectorConfig; | ||
use Rector\TypeDeclaration\Rector as TypeDeclaration; | ||
|
||
return RectorConfig::configure() | ||
->withPaths([ | ||
__DIR__ . '/app', | ||
__DIR__ . '/dev', | ||
__DIR__ . '/errors', | ||
__DIR__ . '/lib', | ||
__DIR__ . '/pub', | ||
__DIR__ . '/shell', | ||
__DIR__ . '/tests', | ||
]) | ||
->withSkipPath(__DIR__ . '/vendor') | ||
->withSkip([ | ||
__DIR__ . '/shell/translations.php', | ||
__DIR__ . '/shell/update-copyright.php.php' | ||
]) | ||
->withRules([ | ||
// CodeQuality\BooleanNot\SimplifyDeMorganBinaryRector::class, # wait for https://github.com/rectorphp/rector/issues/8781 | ||
CodeQuality\BooleanNot\ReplaceMultipleBooleanNotRector::class, | ||
CodeQuality\Foreach_\UnusedForeachValueToArrayKeysRector::class, | ||
CodeQuality\FuncCall\ChangeArrayPushToArrayAssignRector::class, | ||
CodeQuality\FuncCall\CompactToVariablesRector::class, | ||
CodeQuality\Identical\SimplifyArraySearchRector::class, | ||
CodeQuality\Identical\SimplifyConditionsRector::class, | ||
CodeQuality\Identical\StrlenZeroToIdenticalEmptyStringRector::class, | ||
// CodeQuality\If_\SimplifyIfReturnBoolRector::class, | ||
CodeQuality\NotEqual\CommonNotEqualRector::class, | ||
CodeQuality\LogicalAnd\LogicalToBooleanRector::class, | ||
CodeQuality\Ternary\SimplifyTautologyTernaryRector::class, | ||
DeadCode\ClassMethod\RemoveUselessParamTagRector::class, | ||
DeadCode\ClassMethod\RemoveUselessReturnTagRector::class, | ||
DeadCode\Property\RemoveUselessVarTagRector::class, | ||
TypeDeclaration\ClassMethod\ReturnNeverTypeRector::class, | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.