-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,7 @@ public function normalize(Json $json): Json | |
continue; | ||
} | ||
|
||
$packages = self::mergeDuplicateExtensions($packages); | ||
$decoded->{$name} = self::sortPackages($packages); | ||
} | ||
|
||
|
@@ -114,4 +115,38 @@ private static function sortPackages(array $packages): array | |
|
||
return $packages; | ||
} | ||
|
||
/** | ||
* This code is adopted from composer/composer (originally licensed under MIT by Nils Adermann <[email protected]> | ||
* and Jordi Boggiano <[email protected]>). | ||
* | ||
* @see https://github.com/composer/composer/blob/2.8.1/src/Composer/Repository/PlatformRepository.php#L682 | ||
* | ||
* @param array<string, string> $packages | ||
* | ||
* @return array<string, string> | ||
*/ | ||
private static function mergeDuplicateExtensions($packages): array | ||
{ | ||
foreach ($packages as $name => $value) { | ||
Check warning on line 131 in src/Vendor/Composer/PackageHashNormalizer.php GitHub Actions / Mutation Tests (7.4, locked)
|
||
if (!\str_starts_with($name, 'ext-')) { | ||
Check warning on line 132 in src/Vendor/Composer/PackageHashNormalizer.php GitHub Actions / Mutation Tests (7.4, locked)
|
||
continue; | ||
Check warning on line 133 in src/Vendor/Composer/PackageHashNormalizer.php GitHub Actions / Mutation Tests (7.4, locked)
|
||
} | ||
|
||
$newName = \str_replace(' ', '-', \strtolower($name)); | ||
|
||
if ($name === $newName) { | ||
continue; | ||
} | ||
|
||
if (isset($packages[$newName])) { | ||
$value .= '||' . $packages[$newName]; | ||
} | ||
|
||
$packages[$newName] = $value; | ||
unset($packages[$name]); | ||
} | ||
|
||
return $packages; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...onConstraints/HasEntries/Yes/HasNormalizedVersionConstraints/No/Extension/normalized.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"homepage": "https://github.com/ergebnis/composer-normalize/issues/1388", | ||
"value-contains-packages-and-version-constraints": { | ||
"ext-extension-name": "1 || 2 || 3 || 4 || 5 || 6" | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...sionConstraints/HasEntries/Yes/HasNormalizedVersionConstraints/No/Extension/original.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"homepage": "https://github.com/ergebnis/composer-normalize/issues/1388", | ||
"value-contains-packages-and-version-constraints": { | ||
"ext-extension name": "1", | ||
"ext-Extension Name": "2", | ||
"ext-EXTENSION NAME": "3", | ||
"ext-extension-name": "4", | ||
"ext-Extension-Name": "5", | ||
"ext-EXTENSION-NAME": "6" | ||
} | ||
} |