forked from rectorphp/rector-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPhpLevelSetResolver.php
More file actions
59 lines (51 loc) · 1.75 KB
/
PhpLevelSetResolver.php
File metadata and controls
59 lines (51 loc) · 1.75 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
57
58
59
<?php
declare(strict_types=1);
namespace Rector\Configuration;
use Rector\Set\ValueObject\SetList;
use Rector\Tests\Configuration\PhpLevelSetResolverTest;
use Rector\ValueObject\PhpVersion;
use Webmozart\Assert\Assert;
/**
* @see PhpLevelSetResolverTest
* @see \Rector\Tests\Configuration\PhpLevelSetResolverTest
*/
final class PhpLevelSetResolver
{
/**
* @var array<PhpVersion::*, SetList::PHP_*>
*/
private const array VERSION_LOWER_BOUND_CONFIGS = [
PhpVersion::PHP_52 => SetList::PHP_52,
PhpVersion::PHP_53 => SetList::PHP_53,
PhpVersion::PHP_54 => SetList::PHP_54,
PhpVersion::PHP_55 => SetList::PHP_55,
PhpVersion::PHP_56 => SetList::PHP_56,
PhpVersion::PHP_70 => SetList::PHP_70,
PhpVersion::PHP_71 => SetList::PHP_71,
PhpVersion::PHP_72 => SetList::PHP_72,
PhpVersion::PHP_73 => SetList::PHP_73,
PhpVersion::PHP_74 => SetList::PHP_74,
PhpVersion::PHP_80 => SetList::PHP_80,
PhpVersion::PHP_81 => SetList::PHP_81,
PhpVersion::PHP_82 => SetList::PHP_82,
PhpVersion::PHP_83 => SetList::PHP_83,
PhpVersion::PHP_84 => SetList::PHP_84,
PhpVersion::PHP_85 => SetList::PHP_85,
PhpVersion::PHP_86 => SetList::PHP_86,
];
/**
* @param PhpVersion::* $phpVersion
* @return string[]
*/
public static function resolveFromPhpVersion(int $phpVersion): array
{
$configFilePaths = [];
foreach (self::VERSION_LOWER_BOUND_CONFIGS as $versionLowerBound => $phpSetFilePath) {
if ($versionLowerBound <= $phpVersion) {
$configFilePaths[] = $phpSetFilePath;
}
}
Assert::allFileExists($configFilePaths);
return $configFilePaths;
}
}