Skip to content

Commit

Permalink
Updated Rector to commit 625bc7eee281d46b0e7c706d9ca9e259b7ef0db6
Browse files Browse the repository at this point in the history
rectorphp/rector-src@625bc7e Fix platform version resolution, use require first (#5555)
  • Loading branch information
TomasVotruba committed Feb 4, 2024
1 parent 8cb1866 commit b0c6aaf
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion rules/Php80/Rector/Class_/AnnotationToAttributeRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover;
use Rector\Comments\NodeDocBlock\DocBlockUpdater;
use Rector\Contract\Rector\ConfigurableRectorInterface;
use Rector\Exception\Configuration\InvalidConfigurationException;
use Rector\Naming\Naming\UseImportsResolver;
use Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer;
use Rector\Php80\NodeFactory\AttrGroupsFactory;
Expand All @@ -32,7 +33,6 @@
use Rector\PhpAttribute\NodeFactory\PhpAttributeGroupFactory;
use Rector\PhpDocParser\PhpDocParser\PhpDocNodeTraverser;
use Rector\Rector\AbstractRector;
use Rector\Exception\Configuration\InvalidConfigurationException;
use Rector\ValueObject\PhpVersionFeature;
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
Expand Down
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '037153ba50e85666dc8bdc90f832ea4c0ff3677e';
public const PACKAGE_VERSION = '625bc7eee281d46b0e7c706d9ca9e259b7ef0db6';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-02-05 04:51:31';
public const RELEASE_DATE = '2024-02-05 00:12:02';
/**
* @var int
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,19 @@ public static function resolve(string $composerJson) : ?int
}
$composerJsonContents = FileSystem::read($composerJson);
$projectComposerJson = Json::decode($composerJsonContents, Json::FORCE_ARRAY);
// give this one a priority, as more generic one
$requirePhpVersion = $projectComposerJson['require']['php'] ?? null;
if ($requirePhpVersion !== null) {
self::$cachedPhpVersions[$composerJson] = self::createIntVersionFromComposerVersion($requirePhpVersion);
return self::$cachedPhpVersions[$composerJson];
}
// see https://getcomposer.org/doc/06-config.md#platform
$platformPhp = $projectComposerJson['config']['platform']['php'] ?? null;
if ($platformPhp !== null) {
self::$cachedPhpVersions[$composerJson] = PhpVersionFactory::createIntVersion($platformPhp);
return self::$cachedPhpVersions[$composerJson];
}
$requirePhpVersion = $projectComposerJson['require']['php'] ?? null;
if ($requirePhpVersion === null) {
return self::$cachedPhpVersions[$composerJson] = null;
}
self::$cachedPhpVersions[$composerJson] = self::createIntVersionFromComposerVersion($requirePhpVersion);
return self::$cachedPhpVersions[$composerJson];
return null;
}
private static function createIntVersionFromComposerVersion(string $projectPhpVersion) : int
{
Expand Down
5 changes: 1 addition & 4 deletions src/Util/PhpVersionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,9 @@ public static function createIntVersion(string $version) : int
}
$explodeVersion = \explode('.', $version);
$countExplodedVersion = \count($explodeVersion);
if ($countExplodedVersion === 2) {
if ($countExplodedVersion >= 2) {
return (int) $explodeVersion[0] * 10000 + (int) $explodeVersion[1] * 100;
}
if ($countExplodedVersion >= 3) {
return (int) $explodeVersion[0] * 10000 + (int) $explodeVersion[1] * 100 + (int) $explodeVersion[2];
}
return (int) $version;
}
}

0 comments on commit b0c6aaf

Please sign in to comment.