Skip to content

Commit fe4edd2

Browse files
committed
Introduce rector
1 parent 3b14ecd commit fe4edd2

29 files changed

+344
-235
lines changed

api/composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"ext-pdo_mysql": "*",
1818
"ext-xml": "*",
1919
"ext-xmlreader": "*",
20-
"doctrine/doctrine-bundle": "^2.16.2",
20+
"doctrine/doctrine-bundle": "^2.17.2",
2121
"doctrine/doctrine-migrations-bundle": "^3.4.2",
2222
"doctrine/orm": "^3.5.2",
2323
"simplepie/simplepie": "^1.9.0",
@@ -45,14 +45,15 @@
4545
"fakerphp/faker": "^1.24.1",
4646
"malukenho/mcbumpface": "^1.2.0",
4747
"phpstan/extension-installer": "^1.4.3",
48-
"phpstan/phpstan": "^2.1.30",
48+
"phpstan/phpstan": "^2.1.31",
4949
"phpstan/phpstan-deprecation-rules": "^2.0.3",
5050
"phpstan/phpstan-doctrine": "^2.0.10",
5151
"phpstan/phpstan-phpunit": "^2.0.7",
5252
"phpstan/phpstan-symfony": "^2.0.8",
53-
"phpunit/phpunit": "^12.4.0",
53+
"phpunit/phpunit": "^12.4.1",
5454
"pierres/doctrine-migrations-test": "^2.4.0",
5555
"pierres/symfony-database-test": "^2.3.0",
56+
"rector/rector": "^2.2.2",
5657
"squizlabs/php_codesniffer": "^3.13.4",
5758
"symfony/phpunit-bridge": "^7.3.4"
5859
},

api/composer.lock

Lines changed: 92 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/migrations/Version20190101125607.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@ public function up(Schema $schema): void
1919
$this->addSql('ALTER TABLE item ADD CONSTRAINT FK_1F1B251E6FAD93B FOREIGN KEY (feed_url) REFERENCES feed (url) ON DELETE CASCADE');
2020
}
2121

22+
#[\Override]
2223
public function down(Schema $schema): void
2324
{
2425
$this->addSql('ALTER TABLE item DROP FOREIGN KEY FK_1F1B251E6FAD93B');
2526
$this->addSql('DROP TABLE item');
2627
$this->addSql('DROP TABLE feed');
2728
}
2829

30+
#[\Override]
2931
public function isTransactional(): bool
3032
{
3133
return false;

api/migrations/Version20191217125634.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public function up(Schema $schema): void
1616
$this->addSql('ALTER TABLE item ADD PRIMARY KEY (link)');
1717
}
1818

19+
#[\Override]
1920
public function down(Schema $schema): void
2021
{
2122
$this->addSql('ALTER TABLE item DROP PRIMARY KEY');
@@ -25,6 +26,7 @@ public function down(Schema $schema): void
2526
$this->addSql('ALTER TABLE item ADD PRIMARY KEY (public_id, feed_url)');
2627
}
2728

29+
#[\Override]
2830
public function isTransactional(): bool
2931
{
3032
return false;

api/migrations/Version20220122121022.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public function up(Schema $schema): void
1414
$this->addSql('ALTER TABLE item CHANGE feed_url feed_url VARCHAR(191) NOT NULL');
1515
}
1616

17+
#[\Override]
1718
public function down(Schema $schema): void
1819
{
1920
$this->addSql('ALTER TABLE item DROP FOREIGN KEY FK_1F1B251E6FAD93B');
@@ -23,6 +24,7 @@ public function down(Schema $schema): void
2324
$this->addSql('ALTER TABLE item ADD CONSTRAINT FK_1F1B251E6FAD93B FOREIGN KEY (feed_url) REFERENCES feed (url) ON DELETE CASCADE');
2425
}
2526

27+
#[\Override]
2628
public function isTransactional(): bool
2729
{
2830
return false;

api/rector.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector;
6+
use Rector\CodeQuality\Rector\FuncCall\SimplifyRegexPatternRector;
7+
use Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector;
8+
use Rector\Config\RectorConfig;
9+
use Rector\DeadCode\Rector\FunctionLike\NarrowTooWideReturnTypeRector;
10+
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
11+
use Rector\Renaming\Rector\Name\RenameClassRector;
12+
use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector;
13+
use Rector\Symfony\Bridge\Symfony\Routing\SymfonyRoutesProvider;
14+
use Rector\Symfony\Contract\Bridge\Symfony\Routing\SymfonyRoutesProviderInterface;
15+
16+
return RectorConfig::configure()
17+
->withPaths([
18+
__DIR__ . '/migrations',
19+
__DIR__ . '/src',
20+
__DIR__ . '/tests',
21+
])
22+
->withRootFiles()
23+
->withPhpSets()
24+
->withComposerBased(twig: true, doctrine: true, phpunit: true, symfony: true)
25+
->withAttributesSets()
26+
->withSymfonyContainerPhp(__DIR__ . '/tests/symfony-container.php')
27+
->registerService(SymfonyRoutesProvider::class, SymfonyRoutesProviderInterface::class)
28+
->withPreparedSets(deadCode: true, codeQuality: true, typeDeclarations: true)
29+
->withImportNames(importShortClasses: false, removeUnusedImports: true)
30+
->withSkip([
31+
ClassPropertyAssignToConstructorPromotionRector::class,
32+
RenameClassRector::class,
33+
ExplicitBoolCompareRector::class,
34+
DisallowedEmptyRuleFixerRector::class,
35+
SimplifyEmptyCheckOnEmptyArrayRector::class,
36+
// want to replace [0-9] with \d which is not the same though
37+
SimplifyRegexPatternRector::class,
38+
NarrowTooWideReturnTypeRector::class => [
39+
__DIR__ . '/tests/Entity/Packages/Relations/LibraryRelationTraitTest.php',
40+
],
41+
]);

0 commit comments

Comments
 (0)