From 227bf02062eae76c8bdb45e989ebd3fc06dd4209 Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Sun, 31 Dec 2023 16:51:54 +0000 Subject: [PATCH] Account for 1.x.x usage too --- .../Composer/VersionConstraintNormalizer.php | 15 +++++++++++++++ .../VersionRange/Wildcard/Stable/normalized.json | 6 +++++- .../No/VersionRange/Wildcard/Stable/original.json | 6 +++++- .../Wildcard/Unstable/normalized.json | 6 +++++- .../VersionRange/Wildcard/Unstable/original.json | 6 +++++- 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/Vendor/Composer/VersionConstraintNormalizer.php b/src/Vendor/Composer/VersionConstraintNormalizer.php index 9b2b2599..56051f00 100644 --- a/src/Vendor/Composer/VersionConstraintNormalizer.php +++ b/src/Vendor/Composer/VersionConstraintNormalizer.php @@ -122,6 +122,21 @@ private static function normalizeVersionConstraintSeparators(string $versionCons private static function replaceWildcardXWithAsterisk(string $versionConstraint): string { + // '1.x.x' -> '1.*' + $versionConstraint = self::applyRegularExpressionReplacementToVersionsInTurn( + $versionConstraint, + '{^(\d+)\.[xX]\.[xX]$}', + '$1.*', + ); + + // '1.x' -> '1.*' + $versionConstraint = self::applyRegularExpressionReplacementToVersionsInTurn( + $versionConstraint, + '{^(\d+)\.[xX]$}', + '$1.*', + ); + + // 'x' -> '*' return self::applyRegularExpressionReplacementToVersionsInTurn( $versionConstraint, '{^[xX]$}', diff --git a/test/Template/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/ValueContainsPackagesAndVersionConstraints/HasEntries/Yes/HasNormalizedVersionConstraints/No/VersionRange/Wildcard/Stable/normalized.json b/test/Template/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/ValueContainsPackagesAndVersionConstraints/HasEntries/Yes/HasNormalizedVersionConstraints/No/VersionRange/Wildcard/Stable/normalized.json index 6883deb9..659cc52a 100644 --- a/test/Template/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/ValueContainsPackagesAndVersionConstraints/HasEntries/Yes/HasNormalizedVersionConstraints/No/VersionRange/Wildcard/Stable/normalized.json +++ b/test/Template/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/ValueContainsPackagesAndVersionConstraints/HasEntries/Yes/HasNormalizedVersionConstraints/No/VersionRange/Wildcard/Stable/normalized.json @@ -8,6 +8,10 @@ "version-range-wildcard-stable/05-major-minor-patch-trimmed": "~1.2.0", "version-range-wildcard-stable/06-major-minor-patch-untrimmed": "~1.2.0", "version-range-wildcard-stable/07-major-minor-patch-lower-x": "~1.2.0", - "version-range-wildcard-stable/08-major-minor-patch-upper-X": "~1.2.0" + "version-range-wildcard-stable/08-major-minor-patch-upper-X": "~1.2.0", + "version-range-wildcard-stable/09-major-minor-patch-lower-x": "^1.0", + "version-range-wildcard-stable/10-major-minor-patch-upper-X": "^1.0", + "version-range-wildcard-stable/11-major-minor-patch-mixed-xX": "^1.0", + "version-range-wildcard-stable/12-major-minor-patch-mixed-Xx": "^1.0" } } diff --git a/test/Template/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/ValueContainsPackagesAndVersionConstraints/HasEntries/Yes/HasNormalizedVersionConstraints/No/VersionRange/Wildcard/Stable/original.json b/test/Template/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/ValueContainsPackagesAndVersionConstraints/HasEntries/Yes/HasNormalizedVersionConstraints/No/VersionRange/Wildcard/Stable/original.json index 9e15ee8a..fd8c5d91 100644 --- a/test/Template/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/ValueContainsPackagesAndVersionConstraints/HasEntries/Yes/HasNormalizedVersionConstraints/No/VersionRange/Wildcard/Stable/original.json +++ b/test/Template/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/ValueContainsPackagesAndVersionConstraints/HasEntries/Yes/HasNormalizedVersionConstraints/No/VersionRange/Wildcard/Stable/original.json @@ -8,6 +8,10 @@ "version-range-wildcard-stable/05-major-minor-patch-trimmed": "1.2.*", "version-range-wildcard-stable/06-major-minor-patch-untrimmed": " 1.2.* ", "version-range-wildcard-stable/07-major-minor-patch-lower-x": "1.2.x", - "version-range-wildcard-stable/08-major-minor-patch-upper-X": "1.2.X" + "version-range-wildcard-stable/08-major-minor-patch-upper-X": "1.2.X", + "version-range-wildcard-stable/09-major-minor-patch-lower-x": "1.x.x", + "version-range-wildcard-stable/10-major-minor-patch-upper-X": "1.X.X", + "version-range-wildcard-stable/11-major-minor-patch-mixed-xX": "1.x.X", + "version-range-wildcard-stable/12-major-minor-patch-mixed-Xx": "1.X.x" } } diff --git a/test/Template/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/ValueContainsPackagesAndVersionConstraints/HasEntries/Yes/HasNormalizedVersionConstraints/No/VersionRange/Wildcard/Unstable/normalized.json b/test/Template/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/ValueContainsPackagesAndVersionConstraints/HasEntries/Yes/HasNormalizedVersionConstraints/No/VersionRange/Wildcard/Unstable/normalized.json index 3ac23915..b89ca0a8 100644 --- a/test/Template/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/ValueContainsPackagesAndVersionConstraints/HasEntries/Yes/HasNormalizedVersionConstraints/No/VersionRange/Wildcard/Unstable/normalized.json +++ b/test/Template/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/ValueContainsPackagesAndVersionConstraints/HasEntries/Yes/HasNormalizedVersionConstraints/No/VersionRange/Wildcard/Unstable/normalized.json @@ -8,6 +8,10 @@ "version-range-wildcard-unstable/05-major-minor-patch-trimmed": "~0.1.0", "version-range-wildcard-unstable/06-major-minor-patch-untrimmed": "~0.1.0", "version-range-wildcard-unstable/07-major-minor-patch-lower-x": "~0.1.0", - "version-range-wildcard-unstable/08-major-minor-patch-upper-X": "~0.1.0" + "version-range-wildcard-unstable/08-major-minor-patch-upper-X": "~0.1.0", + "version-range-wildcard-unstable/09-major-minor-patch-lower-x": "^0.0", + "version-range-wildcard-unstable/10-major-minor-patch-upper-X": "^0.0", + "version-range-wildcard-unstable/11-major-minor-patch-mixed-xX": "^0.0", + "version-range-wildcard-unstable/12-major-minor-patch-mixed-Xx": "^0.0" } } diff --git a/test/Template/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/ValueContainsPackagesAndVersionConstraints/HasEntries/Yes/HasNormalizedVersionConstraints/No/VersionRange/Wildcard/Unstable/original.json b/test/Template/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/ValueContainsPackagesAndVersionConstraints/HasEntries/Yes/HasNormalizedVersionConstraints/No/VersionRange/Wildcard/Unstable/original.json index 1be4681b..c96e2e71 100644 --- a/test/Template/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/ValueContainsPackagesAndVersionConstraints/HasEntries/Yes/HasNormalizedVersionConstraints/No/VersionRange/Wildcard/Unstable/original.json +++ b/test/Template/Vendor/Composer/ComposerJsonNormalizer/NormalizeNormalizesJson/Json/IsObject/HasEntries/Yes/HasProperty/ValueContainsPackagesAndVersionConstraints/HasEntries/Yes/HasNormalizedVersionConstraints/No/VersionRange/Wildcard/Unstable/original.json @@ -8,6 +8,10 @@ "version-range-wildcard-unstable/05-major-minor-patch-trimmed": "0.1.*", "version-range-wildcard-unstable/06-major-minor-patch-untrimmed": " 0.1.* ", "version-range-wildcard-unstable/07-major-minor-patch-lower-x": "0.1.x", - "version-range-wildcard-unstable/08-major-minor-patch-upper-X": "0.1.X" + "version-range-wildcard-unstable/08-major-minor-patch-upper-X": "0.1.X", + "version-range-wildcard-unstable/09-major-minor-patch-lower-x": "0.x.x", + "version-range-wildcard-unstable/10-major-minor-patch-upper-X": "0.X.X", + "version-range-wildcard-unstable/11-major-minor-patch-mixed-xX": "0.x.X", + "version-range-wildcard-unstable/12-major-minor-patch-mixed-Xx": "0.X.x" } }