-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathdowngrade-php81.php
More file actions
56 lines (50 loc) · 2.82 KB
/
downgrade-php81.php
File metadata and controls
56 lines (50 loc) · 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
declare(strict_types=1);
use Rector\DowngradePhp74\Rector\Array_\DowngradeArraySpreadRector;
use Rector\DowngradePhp81\Rector\FuncCall\DowngradeHashAlgorithmXxHashRector;
use Rector\DowngradePhp81\Rector\LNumber\DowngradeOctalNumberRector;
use Rector\DowngradePhp81\Rector\MethodCall\DowngradeIsEnumRector;
use Rector\Config\RectorConfig;
use Rector\ValueObject\PhpVersion;
use Rector\DowngradePhp81\Rector\ClassConst\DowngradeFinalizePublicClassConstantRector;
use Rector\DowngradePhp81\Rector\FuncCall\DowngradeArrayIsListRector;
use Rector\DowngradePhp81\Rector\FuncCall\DowngradeFirstClassCallableSyntaxRector;
use Rector\DowngradePhp81\Rector\FunctionLike\DowngradeNeverTypeDeclarationRector;
use Rector\DowngradePhp81\Rector\FunctionLike\DowngradeNewInInitializerRector;
use Rector\DowngradePhp81\Rector\FunctionLike\DowngradePureIntersectionTypeRector;
use Rector\DowngradePhp81\Rector\Instanceof_\DowngradePhp81ResourceReturnToObjectRector;
use Rector\DowngradePhp81\Rector\Property\DowngradeReadonlyPropertyRector;
use Rector\DowngradePhp81\Rector\StmtsAwareInterface\DowngradeSetAccessibleReflectionPropertyRector;
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
use Rector\Renaming\ValueObject\MethodCallRename;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->phpVersion(PhpVersion::PHP_80);
$rectorConfig->rules([
DowngradeFinalizePublicClassConstantRector::class,
DowngradeFirstClassCallableSyntaxRector::class,
DowngradeNeverTypeDeclarationRector::class,
DowngradePureIntersectionTypeRector::class,
DowngradeNewInInitializerRector::class,
DowngradePhp81ResourceReturnToObjectRector::class,
DowngradeReadonlyPropertyRector::class,
DowngradeArraySpreadRector::class,
// DowngradeArraySpreadStringKeyRector::class,
DowngradeArrayIsListRector::class,
DowngradeSetAccessibleReflectionPropertyRector::class,
DowngradeIsEnumRector::class,
DowngradeOctalNumberRector::class,
DowngradeHashAlgorithmXxHashRector::class,
]);
// @see https://php.watch/versions/8.1/internal-method-return-types#reflection
$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [
new MethodCallRename('ReflectionFunction', 'hasTentativeReturnType', 'hasReturnType'),
new MethodCallRename('ReflectionFunction', 'getTentativeReturnType', 'getReturnType'),
new MethodCallRename('ReflectionMethod', 'hasTentativeReturnType', 'hasReturnType'),
new MethodCallRename('ReflectionMethod', 'getTentativeReturnType', 'getReturnType'),
]);
$rectorConfig->ruleWithConfiguration(RenameFunctionRector::class, [
// @see https://php.watch/versions/8.1/enums#enum-exists
'enum_exists' => 'class_exists',
]);
};