Skip to content

Commit 290c520

Browse files
committed
update rector config, bump to PHP 8.2
1 parent 0352158 commit 290c520

18 files changed

+53
-78
lines changed

rector.php

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,19 @@
33
declare(strict_types=1);
44

55
use Rector\Config\RectorConfig;
6-
use Rector\PHPUnit\Set\PHPUnitSetList;
7-
use Rector\Set\ValueObject\LevelSetList;
8-
use Rector\Set\ValueObject\SetList;
9-
10-
return static function (RectorConfig $rectorConfig): void {
11-
$rectorConfig->sets([
12-
PHPUnitSetList::PHPUNIT_100,
13-
SetList::CODE_QUALITY,
14-
SetList::DEAD_CODE,
15-
LevelSetList::UP_TO_PHP_81,
16-
SetList::CODING_STYLE,
17-
SetList::TYPE_DECLARATION,
18-
SetList::NAMING,
19-
SetList::PRIVATIZATION,
20-
SetList::EARLY_RETURN,
21-
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
22-
]);
23-
24-
$rectorConfig->paths([
25-
__DIR__ . '/config',
26-
__DIR__ . '/src',
27-
__DIR__ . '/tests',
28-
]);
29-
30-
$rectorConfig->importNames();
31-
32-
$rectorConfig->skip([
6+
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
7+
8+
return RectorConfig::configure()
9+
->withPhpSets()
10+
->withPreparedSets(codeQuality: true, deadCode: true, codingStyle: true, typeDeclarations: true, naming: true, privatization: true, earlyReturn: true, phpunitCodeQuality: true)
11+
->withPaths([__DIR__ . '/config', __DIR__ . '/src', __DIR__ . '/tests'])
12+
->withRootFiles()
13+
->withImportNames()
14+
->withSkip([
3315
'*/Source/*',
3416
'*/Fixture/*',
35-
36-
\Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class => [
17+
StringClassNameToClassConstantRector::class => [
3718
__DIR__ . '/tests/Naming/ClassToSuffixResolverTest.php',
3819
__DIR__ . '/tests/Rules/Rector/PhpUpgradeImplementsMinPhpVersionInterfaceRule/PhpUpgradeImplementsMinPhpVersionInterfaceRuleTest.php',
3920
],
4021
]);
41-
42-
$rectorConfig->ruleWithConfiguration(\Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class, [
43-
'Symfony\Component\Console\*',
44-
'Rector\Contract\Rector\ConfigurableRectorInterface',
45-
]);
46-
};

src/NodeAnalyzer/EnumAnalyzer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
use PHPStan\Reflection\ClassReflection;
1313
use Symplify\PHPStanRules\PhpDoc\BarePhpDocParser;
1414

15-
final class EnumAnalyzer
15+
final readonly class EnumAnalyzer
1616
{
1717
public function __construct(
18-
private readonly BarePhpDocParser $barePhpDocParser
18+
private BarePhpDocParser $barePhpDocParser
1919
) {
2020
}
2121

src/NodeFinder/TypeAwareNodeFinder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
/**
1111
* @todo remove after https://github.com/nikic/PHP-Parser/pull/869 is released
1212
*/
13-
final class TypeAwareNodeFinder
13+
final readonly class TypeAwareNodeFinder
1414
{
15-
private readonly NodeFinder $nodeFinder;
15+
private NodeFinder $nodeFinder;
1616

1717
public function __construct()
1818
{

src/ParentClassMethodNodeResolver.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
use PHPStan\Reflection\ReflectionProvider;
1111
use Symplify\PHPStanRules\Reflection\ReflectionParser;
1212

13-
final class ParentClassMethodNodeResolver
13+
final readonly class ParentClassMethodNodeResolver
1414
{
1515
public function __construct(
16-
private readonly ReflectionParser $reflectionParser,
17-
private readonly ReflectionProvider $reflectionProvider
16+
private ReflectionParser $reflectionParser,
17+
private ReflectionProvider $reflectionProvider
1818
) {
1919
}
2020

src/PhpDoc/BarePhpDocParser.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
use PHPStan\PhpDocParser\Parser\PhpDocParser;
1313
use PHPStan\PhpDocParser\Parser\TokenIterator;
1414

15-
final class BarePhpDocParser
15+
final readonly class BarePhpDocParser
1616
{
1717
public function __construct(
18-
private readonly PhpDocParser $phpDocParser,
19-
private readonly Lexer $lexer
18+
private PhpDocParser $phpDocParser,
19+
private Lexer $lexer
2020
) {
2121
}
2222

src/PhpDoc/PhpDocResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
use PHPStan\Reflection\ClassReflection;
1111
use PHPStan\Type\FileTypeMapper;
1212

13-
final class PhpDocResolver
13+
final readonly class PhpDocResolver
1414
{
1515
public function __construct(
16-
private readonly FileTypeMapper $fileTypeMapper
16+
private FileTypeMapper $fileTypeMapper
1717
) {
1818
}
1919

src/Rules/Enum/RequireUniqueEnumConstantRule.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
* @implements Rule<InClassNode>
1919
* @see \Symplify\PHPStanRules\Tests\Rules\Enum\RequireUniqueEnumConstantRule\RequireUniqueEnumConstantRuleTest
2020
*/
21-
final class RequireUniqueEnumConstantRule implements Rule
21+
final readonly class RequireUniqueEnumConstantRule implements Rule
2222
{
2323
/**
2424
* @var string
2525
*/
2626
public const ERROR_MESSAGE = 'Enum constants "%s" are duplicated. Make them unique instead';
2727

2828
public function __construct(
29-
private readonly EnumAnalyzer $enumAnalyzer
29+
private EnumAnalyzer $enumAnalyzer
3030
) {
3131
}
3232

src/Rules/ForbiddenFuncCallRule.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* @implements Rule<FuncCall>
2323
* @see \Symplify\PHPStanRules\Tests\Rules\ForbiddenFuncCallRule\ForbiddenFuncCallRuleTest
2424
*/
25-
final class ForbiddenFuncCallRule implements Rule
25+
final readonly class ForbiddenFuncCallRule implements Rule
2626
{
2727
/**
2828
* @var string
@@ -33,9 +33,9 @@ final class ForbiddenFuncCallRule implements Rule
3333
* @param array<string> $forbiddenFunctions
3434
*/
3535
public function __construct(
36-
private readonly array $forbiddenFunctions,
37-
private readonly ArrayStringAndFnMatcher $arrayStringAndFnMatcher,
38-
private readonly RequiredWithMessageFormatter $requiredWithMessageFormatter,
36+
private array $forbiddenFunctions,
37+
private ArrayStringAndFnMatcher $arrayStringAndFnMatcher,
38+
private RequiredWithMessageFormatter $requiredWithMessageFormatter,
3939
) {
4040
}
4141

src/Rules/ForbiddenMultipleClassLikeInOneFileRule.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
* @implements Rule<FileNode>
1919
* @see \Symplify\PHPStanRules\Tests\Rules\ForbiddenMultipleClassLikeInOneFileRule\ForbiddenMultipleClassLikeInOneFileRuleTest
2020
*/
21-
final class ForbiddenMultipleClassLikeInOneFileRule implements Rule
21+
final readonly class ForbiddenMultipleClassLikeInOneFileRule implements Rule
2222
{
2323
/**
2424
* @var string
2525
*/
2626
public const ERROR_MESSAGE = 'Multiple class/interface/trait is not allowed in single file';
2727

28-
private readonly NodeFinder $nodeFinder;
28+
private NodeFinder $nodeFinder;
2929

3030
public function __construct(
3131
) {

src/Rules/NoInlineStringRegexRule.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@
2121
* @implements Rule<CallLike>
2222
* @see \Symplify\PHPStanRules\Tests\Rules\NoInlineStringRegexRule\NoInlineStringRegexRuleTest
2323
*/
24-
final class NoInlineStringRegexRule implements Rule
24+
final readonly class NoInlineStringRegexRule implements Rule
2525
{
2626
/**
2727
* @var string
2828
*/
2929
public const ERROR_MESSAGE = 'Use local named constant instead of inline string for regex to explain meaning by constant name';
3030

3131
public function __construct(
32-
private readonly RegexFuncCallAnalyzer $regexFuncCallAnalyzer,
33-
private readonly RegexStaticCallAnalyzer $regexStaticCallAnalyzer
32+
private RegexFuncCallAnalyzer $regexFuncCallAnalyzer,
33+
private RegexStaticCallAnalyzer $regexStaticCallAnalyzer
3434
) {
3535
}
3636

0 commit comments

Comments
 (0)