Skip to content

Commit de073e2

Browse files
authored
Merge pull request #8618 from justbyitself/patch-2
refactor: replace PHP_VERSION by PHP_VERSION_ID
2 parents e6052cf + f3e5391 commit de073e2

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

rector.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use Rector\CodingStyle\Rector\ClassMethod\FuncGetArgsToVariadicParamRector;
2929
use Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector;
3030
use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector;
31+
use Rector\CodingStyle\Rector\FuncCall\VersionCompareFuncCallToConstantRector;
3132
use Rector\Config\RectorConfig;
3233
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedConstructorParamRector;
3334
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector;
@@ -149,6 +150,7 @@
149150
$rectorConfig->rule(CompleteDynamicPropertiesRector::class);
150151
$rectorConfig->rule(BooleanInIfConditionRuleFixerRector::class);
151152
$rectorConfig->rule(SingleInArrayToCompareRector::class);
153+
$rectorConfig->rule(VersionCompareFuncCallToConstantRector::class);
152154

153155
$rectorConfig
154156
->ruleWithConfiguration(StringClassNameToClassConstantRector::class, [

system/Autoloader/Autoloader.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,11 +346,7 @@ public function sanitizeFilename(string $filename): string
346346
);
347347
}
348348
if ($result === false) {
349-
if (version_compare(PHP_VERSION, '8.0.0', '>=')) {
350-
$message = preg_last_error_msg();
351-
} else {
352-
$message = 'Regex error. error code: ' . preg_last_error();
353-
}
349+
$message = PHP_VERSION_ID >= 80000 ? preg_last_error_msg() : 'Regex error. error code: ' . preg_last_error();
354350

355351
throw new RuntimeException($message . '. filename: "' . $filename . '"');
356352
}

0 commit comments

Comments
 (0)