Skip to content

Commit 1d7920d

Browse files
authored
Merge pull request #4 from bakame-php/feature/using-rector
Feature/using rector
2 parents d9129ff + 82dd08d commit 1d7920d

File tree

3 files changed

+59
-3
lines changed

3 files changed

+59
-3
lines changed

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,12 @@ phpcs:
2222
test:
2323
@docker run --rm -it -v$(PWD):/app composer test
2424

25-
# test
25+
# downgrade
26+
downgrade:
27+
@docker run --rm -it -v$(PWD):/app --workdir=/app php:8.1-cli-alpine vendor/bin/rector process src
28+
29+
# sandbox
2630
sandbox:
2731
@docker run --rm -it -v$(PWD):/app php:8.1-cli-alpine php ./app/test.php
2832

29-
.PHONY: install update phpunit phpstan phpcs test
33+
.PHONY: install update phpunit phpstan phpcs test sandbox downgrade

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
"phpstan/phpstan-strict-rules": "^1.1",
3535
"phpstan/phpstan-phpunit": "^1.0",
3636
"phpstan/phpstan-deprecation-rules": "^1.0",
37-
"phpunit/phpunit": "^9.5.20"
37+
"phpunit/phpunit": "^9.5.20",
38+
"rector/rector": "~0.12.21"
3839
},
3940
"autoload": {
4041
"psr-4": {

rector.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Core\Configuration\Option;
6+
7+
use Rector\DowngradePhp80\Rector\Catch_\DowngradeNonCapturingCatchesRector;
8+
use Rector\DowngradePhp80\Rector\Class_\DowngradePropertyPromotionRector;
9+
use Rector\DowngradePhp80\Rector\ClassMethod\DowngradeStaticTypeDeclarationRector;
10+
use Rector\DowngradePhp80\Rector\ClassMethod\DowngradeTrailingCommasInParamUseRector;
11+
use Rector\DowngradePhp80\Rector\Expression\DowngradeMatchToSwitchRector;
12+
use Rector\DowngradePhp80\Rector\Expression\DowngradeThrowExprRector;
13+
use Rector\DowngradePhp80\Rector\FuncCall\DowngradeStrContainsRector;
14+
use Rector\DowngradePhp80\Rector\FunctionLike\DowngradeUnionTypeDeclarationRector;
15+
use Rector\DowngradePhp80\Rector\NullsafeMethodCall\DowngradeNullsafeToTernaryOperatorRector;
16+
use Rector\DowngradePhp80\Rector\Property\DowngradeUnionTypeTypedPropertyRector;
17+
18+
use Rector\DowngradePhp81\Rector\Array_\DowngradeArraySpreadStringKeyRector;
19+
use Rector\DowngradePhp81\Rector\FuncCall\DowngradeArrayIsListRector;
20+
use Rector\DowngradePhp81\Rector\FuncCall\DowngradeFirstClassCallableSyntaxRector;
21+
use Rector\DowngradePhp81\Rector\FunctionLike\DowngradeNewInInitializerRector;
22+
use Rector\DowngradePhp81\Rector\Property\DowngradeReadonlyPropertyRector;
23+
24+
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
25+
26+
return static function (ContainerConfigurator $containerConfigurator): void {
27+
28+
$parameters = $containerConfigurator->parameters();
29+
30+
$parameters->set(Option::PATHS, __DIR__.'/src');
31+
$parameters->set(Option::PHP_VERSION_FEATURES, 70400);
32+
33+
$services = $containerConfigurator->services();
34+
35+
$services->set(DowngradeMatchToSwitchRector::class);
36+
$services->set(DowngradeNonCapturingCatchesRector::class);
37+
$services->set(DowngradeNullsafeToTernaryOperatorRector::class);
38+
$services->set(DowngradePropertyPromotionRector::class);
39+
$services->set(DowngradeStaticTypeDeclarationRector::class);
40+
$services->set(DowngradeStrContainsRector::class);
41+
$services->set(DowngradeThrowExprRector::class);
42+
$services->set(DowngradeTrailingCommasInParamUseRector::class);
43+
$services->set(DowngradeUnionTypeDeclarationRector::class);
44+
$services->set(DowngradeUnionTypeTypedPropertyRector::class);
45+
46+
$services->set(DowngradeArrayIsListRector::class);
47+
$services->set(DowngradeArraySpreadStringKeyRector::class);
48+
$services->set(DowngradeFirstClassCallableSyntaxRector::class);
49+
$services->set(DowngradeNewInInitializerRector::class);
50+
$services->set(DowngradeReadonlyPropertyRector::class);
51+
};

0 commit comments

Comments
 (0)