Skip to content

Commit 22ccaf4

Browse files
authored
Merge pull request #560 from kenjis/fix-rector-config
chore: update rector.php
2 parents eeebfc8 + 23c2527 commit 22ccaf4

15 files changed

+42
-27
lines changed

.github/workflows/rector.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,5 @@ jobs:
6363
6464
- name: Analyze for refactoring
6565
run: |
66-
composer global require --dev rector/rector:^0.13.3
66+
composer global require --dev rector/rector:^0.15.1
6767
rector process --dry-run --no-progress-bar

.php-cs-fixer.dist.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
__DIR__ . '/tests/',
1414
])
1515
->exclude('build')
16-
->append([__FILE__]);
16+
->append([
17+
__FILE__,
18+
__DIR__ . '/rector.php',
19+
]);
1720

1821
$overrides = [
1922
'declare_strict_types' => true,

rector.php

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
use Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector;
6+
use Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector;
47
use Rector\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector;
58
use Rector\CodeQuality\Rector\For_\ForToForeachRector;
69
use Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector;
@@ -30,15 +33,23 @@
3033
use Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector;
3134
use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector;
3235
use Rector\Php73\Rector\FuncCall\StringifyStrNeedlesRector;
33-
use Rector\Php74\Rector\Property\TypedPropertyRector;
36+
use Rector\PHPUnit\Rector\Class_\AnnotationWithValueToAttributeRector;
3437
use Rector\PHPUnit\Set\PHPUnitSetList;
38+
use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector;
3539
use Rector\PSR4\Rector\FileWithoutNamespace\NormalizeNamespaceByPSR4ComposerAutoloadRector;
3640
use Rector\Set\ValueObject\LevelSetList;
3741
use Rector\Set\ValueObject\SetList;
3842

3943
return static function (RectorConfig $rectorConfig): void {
40-
$rectorConfig->sets([SetList::DEAD_CODE, LevelSetList::UP_TO_PHP_74, PHPUnitSetList::PHPUNIT_SPECIFIC_METHOD, PHPUnitSetList::PHPUNIT_80]);
44+
$rectorConfig->sets([
45+
SetList::DEAD_CODE,
46+
LevelSetList::UP_TO_PHP_74,
47+
PHPUnitSetList::PHPUNIT_SPECIFIC_METHOD,
48+
PHPUnitSetList::PHPUNIT_100,
49+
]);
50+
4151
$rectorConfig->parallel();
52+
4253
// The paths to refactor (can also be supplied with CLI arguments)
4354
$rectorConfig->paths([
4455
__DIR__ . '/src/',
@@ -74,6 +85,7 @@
7485

7586
// Note: requires php 8
7687
RemoveUnusedPromotedPropertyRector::class,
88+
AnnotationWithValueToAttributeRector::class,
7789

7890
// Ignore tests that might make calls without a result
7991
RemoveEmptyMethodCallRector::class => [
@@ -97,6 +109,9 @@
97109
__DIR__ . '/src/Models/UserModel.php',
98110
],
99111
]);
112+
// auto import fully qualified class names
113+
$rectorConfig->importNames();
114+
100115
$rectorConfig->rule(SimplifyUselessVariableRector::class);
101116
$rectorConfig->rule(RemoveAlwaysElseRector::class);
102117
$rectorConfig->rule(CountArrayToEmptyArrayComparisonRector::class);
@@ -119,8 +134,7 @@
119134
$rectorConfig->rule(MakeInheritedMethodVisibilitySameAsParentRector::class);
120135
$rectorConfig->rule(SimplifyEmptyArrayCheckRector::class);
121136
$rectorConfig->rule(NormalizeNamespaceByPSR4ComposerAutoloadRector::class);
122-
$rectorConfig
123-
->ruleWithConfiguration(TypedPropertyRector::class, [
124-
TypedPropertyRector::INLINE_PUBLIC => false,
125-
]);
137+
$rectorConfig->rule(StringClassNameToClassConstantRector::class);
138+
$rectorConfig->rule(PrivatizeFinalClassPropertyRector::class);
139+
$rectorConfig->rule(CompleteDynamicPropertiesRector::class);
126140
};

tests/Authentication/AuthenticationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
final class AuthenticationTest extends DatabaseTestCase
1818
{
19-
protected Authentication $auth;
19+
private Authentication $auth;
2020

2121
protected function setUp(): void
2222
{

tests/Authentication/Authenticators/AccessTokenAuthenticatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
final class AccessTokenAuthenticatorTest extends DatabaseTestCase
2424
{
25-
protected AccessTokens $auth;
25+
private AccessTokens $auth;
2626

2727
protected function setUp(): void
2828
{

tests/Authentication/Authenticators/SessionAuthenticatorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ final class SessionAuthenticatorTest extends TestCase
2727
use DatabaseTestTrait;
2828
use FakeUser;
2929

30-
protected Session $auth;
30+
private Session $auth;
3131
protected $namespace;
32-
protected $events;
32+
private MockEvents $events;
3333

3434
protected function setUp(): void
3535
{

tests/Authentication/Filters/AbstractFilterTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ abstract class AbstractFilterTest extends TestCase
1818
use FeatureTestTrait;
1919
use AuthenticationTesting;
2020

21+
protected string $routeFilter;
2122
protected $namespace;
2223
protected string $alias;
2324
protected string $classname;

tests/Authentication/HasAccessTokensTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
final class HasAccessTokensTest extends DatabaseTestCase
1717
{
18-
protected User $user;
18+
private User $user;
1919

2020
protected function setUp(): void
2121
{

tests/Authorization/AuthorizableTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,11 @@ final class AuthorizableTest extends TestCase
2323

2424
protected $refresh = true;
2525
protected $namespace;
26-
protected UserModel $model;
2726

2827
protected function setUp(): void
2928
{
3029
parent::setUp();
3130

32-
$this->model = new UserModel();
33-
3431
// Refresh should take care of this....
3532
db_connect()->table('auth_groups_users')->truncate();
3633
db_connect()->table('auth_permissions_users')->truncate();

tests/Language/AbstractTranslationTestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,12 +305,12 @@ final public function testAllConfiguredLanguageKeysAreInOrder(string $locale): v
305305
/**
306306
* @return string[][]
307307
*/
308-
final public function localesProvider(): iterable
308+
final public static function localesProvider(): iterable
309309
{
310310
$locale = self::$locales[static::class] ?? null;
311311

312312
if (null === $locale) {
313-
$this->fail('The locale code should be defined in the $locales property.');
313+
static::fail('The locale code should be defined in the $locales property.');
314314
}
315315

316316
return [$locale => [$locale]];

0 commit comments

Comments
 (0)