1
0
Fork 0

Fix handling of platform packages to be future proof, refs #3872

pull/3991/head
Jordi Boggiano 2015-05-01 16:14:17 +01:00
parent 081e26f4d7
commit 06fb00bfe5
1 changed files with 23 additions and 17 deletions

View File

@ -12,6 +12,8 @@
namespace Composer\Json;
use Composer\Repository\PlatformRepository;
/**
* @author Jordi Boggiano <j.boggiano@seld.be>
*/
@ -111,23 +113,27 @@ class JsonManipulator
private function sortPackages(array &$packages = array())
{
$prefix = function ($requirement) {
return preg_replace(
array(
'/^php$/',
'/^hhvm$/',
'/^ext-\w+$/',
'/^lib-\w+$/',
'/^.+$/',
),
array(
'0-$0',
'1-$0',
'2-$0',
'3-$0',
'4-$0',
),
$requirement
);
if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $requirement)) {
return preg_replace(
array(
'/^php/',
'/^hhvm/',
'/^ext/',
'/^lib/',
'/^\D/',
),
array(
'0-$0',
'1-$0',
'2-$0',
'3-$0',
'4-$0',
),
$requirement
);
}
return '5-'.$requirement;
};
uksort($packages, function ($a, $b) use ($prefix) {