Skip to content

Commit 8a11b6b

Browse files
committed
Init Rector
1 parent 80d981e commit 8a11b6b

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"require-dev": {
2525
"friendsofphp/php-cs-fixer": "^3.4",
2626
"phpunit/phpunit": "^8.5.13",
27-
"phpstan/phpstan": "^1.3"
27+
"phpstan/phpstan": "^1.3",
28+
"rector/rector": "^0.12.23"
2829
},
2930
"suggest": {
3031
"ext-exif": "Allows to read and keep images EXIF data"

rector.php

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
6+
use Rector\Config\RectorConfig;
7+
use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
8+
use Rector\Php74\Rector\Assign\NullCoalescingOperatorRector;
9+
use Rector\Php74\Rector\Property\TypedPropertyRector;
10+
use Rector\Set\ValueObject\LevelSetList;
11+
use Rector\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector;
12+
use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector;
13+
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector;
14+
use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector;
15+
use Rector\TypeDeclaration\Rector\Property\AddPropertyTypeDeclarationRector;
16+
17+
return static function(RectorConfig $rectorConfig): void {
18+
$rectorConfig->paths([
19+
__DIR__ . '/src'
20+
]);
21+
22+
// register a single rule
23+
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);
24+
$rectorConfig->rule(NullCoalescingOperatorRector::class);
25+
$rectorConfig->rule(RemoveExtraParametersRector::class);
26+
27+
$rectorConfig->rule(AddMethodCallBasedStrictParamTypeRector::class);
28+
$rectorConfig->rule(AddVoidReturnTypeWhereNoReturnRector::class);
29+
30+
$rectorConfig->ruleWithConfiguration(TypedPropertyRector::class, [
31+
TypedPropertyRector::INLINE_PUBLIC => true,
32+
]);
33+
34+
// define sets of rules
35+
$rectorConfig->sets([
36+
LevelSetList::UP_TO_PHP_80
37+
]);
38+
39+
$rectorConfig->phpstanConfig(__DIR__ . '/phpstan.neon');
40+
};

0 commit comments

Comments
 (0)