mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-20 23:41:57 +02:00
Updated Rector to commit 3dac3a00d8a9e306bacc1ae2f9ded092dc95c212
3dac3a00d8
[Performance] Cache PHP version features on reading composer.json on PhpVersionProvider (#5484)
This commit is contained in:
parent
3ea4c627d4
commit
72af333641
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '663f526966313e0f178c088ea667119490404da9';
|
||||
public const PACKAGE_VERSION = '3dac3a00d8a9e306bacc1ae2f9ded092dc95c212';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2024-01-20 21:57:32';
|
||||
public const RELEASE_DATE = '2024-01-21 08:10:26';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
@ -26,6 +26,10 @@ final class PhpVersionProvider
|
||||
* @see https://regex101.com/r/qBMnbl/1
|
||||
*/
|
||||
private const VALID_PHP_VERSION_REGEX = '#^\\d{5,6}$#';
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
private $phpVersionFeatures = null;
|
||||
public function __construct(ProjectComposerJsonPhpVersionResolver $projectComposerJsonPhpVersionResolver)
|
||||
{
|
||||
$this->projectComposerJsonPhpVersionResolver = $projectComposerJsonPhpVersionResolver;
|
||||
@ -35,13 +39,12 @@ final class PhpVersionProvider
|
||||
*/
|
||||
public function provide() : int
|
||||
{
|
||||
$phpVersionFeatures = null;
|
||||
if (SimpleParameterProvider::hasParameter(Option::PHP_VERSION_FEATURES)) {
|
||||
$phpVersionFeatures = SimpleParameterProvider::provideIntParameter(Option::PHP_VERSION_FEATURES);
|
||||
$this->validatePhpVersionFeaturesParameter($phpVersionFeatures);
|
||||
$this->phpVersionFeatures = SimpleParameterProvider::provideIntParameter(Option::PHP_VERSION_FEATURES);
|
||||
$this->validatePhpVersionFeaturesParameter($this->phpVersionFeatures);
|
||||
}
|
||||
if ($phpVersionFeatures > 0) {
|
||||
return $phpVersionFeatures;
|
||||
if ($this->phpVersionFeatures > 0) {
|
||||
return $this->phpVersionFeatures;
|
||||
}
|
||||
// for tests
|
||||
if (StaticPHPUnitEnvironment::isPHPUnitRun()) {
|
||||
@ -52,11 +55,11 @@ final class PhpVersionProvider
|
||||
if (\file_exists($projectComposerJson)) {
|
||||
$phpVersion = $this->projectComposerJsonPhpVersionResolver->resolve($projectComposerJson);
|
||||
if ($phpVersion !== null) {
|
||||
return $phpVersion;
|
||||
return $this->phpVersionFeatures = $phpVersion;
|
||||
}
|
||||
}
|
||||
// fallback to current PHP runtime version
|
||||
return \PHP_VERSION_ID;
|
||||
return $this->phpVersionFeatures = \PHP_VERSION_ID;
|
||||
}
|
||||
public function isAtLeastPhpVersion(int $phpVersion) : bool
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user