- Sort links and keywords in ArrayDumper result (fixes issue #1499)
- Adapt ArrayDumperTestpull/1544/head
parent
3b2accfb58
commit
704837c574
|
@ -16,6 +16,7 @@ use Composer\Package\BasePackage;
|
||||||
use Composer\Package\PackageInterface;
|
use Composer\Package\PackageInterface;
|
||||||
use Composer\Package\CompletePackageInterface;
|
use Composer\Package\CompletePackageInterface;
|
||||||
use Composer\Package\RootPackageInterface;
|
use Composer\Package\RootPackageInterface;
|
||||||
|
use Composer\Package\Link;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Konstantin Kudryashiv <ever.zet@gmail.com>
|
* @author Konstantin Kudryashiv <ever.zet@gmail.com>
|
||||||
|
@ -59,6 +60,15 @@ class ArrayDumper
|
||||||
|
|
||||||
foreach (BasePackage::$supportedLinkTypes as $type => $opts) {
|
foreach (BasePackage::$supportedLinkTypes as $type => $opts) {
|
||||||
if ($links = $package->{'get'.ucfirst($opts['method'])}()) {
|
if ($links = $package->{'get'.ucfirst($opts['method'])}()) {
|
||||||
|
usort($links, function (Link $a, Link $b) {
|
||||||
|
$comparison = strcmp($a->getTarget(), $b->getTarget());
|
||||||
|
|
||||||
|
if (0 !== $comparison) {
|
||||||
|
return $comparison;
|
||||||
|
}
|
||||||
|
|
||||||
|
return strcmp($a->getPrettyConstraint(), $b->getPrettyConstraint());
|
||||||
|
});
|
||||||
foreach ($links as $link) {
|
foreach ($links as $link) {
|
||||||
$data[$type][$link->getTarget()] = $link->getPrettyConstraint();
|
$data[$type][$link->getTarget()] = $link->getPrettyConstraint();
|
||||||
}
|
}
|
||||||
|
@ -66,6 +76,7 @@ class ArrayDumper
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($packages = $package->getSuggests()) {
|
if ($packages = $package->getSuggests()) {
|
||||||
|
ksort($packages);
|
||||||
$data['suggest'] = $packages;
|
$data['suggest'] = $packages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,6 +99,10 @@ class ArrayDumper
|
||||||
);
|
);
|
||||||
|
|
||||||
$data = $this->dumpValues($package, $keys, $data);
|
$data = $this->dumpValues($package, $keys, $data);
|
||||||
|
|
||||||
|
if (isset($data['keywords']) && is_array($data['keywords'])) {
|
||||||
|
sort($data['keywords']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($package instanceof RootPackageInterface) {
|
if ($package instanceof RootPackageInterface) {
|
||||||
|
|
|
@ -101,7 +101,9 @@ class ArrayDumperTest extends \PHPUnit_Framework_TestCase
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'keywords',
|
'keywords',
|
||||||
array('package', 'dependency', 'autoload')
|
array('package', 'dependency', 'autoload'),
|
||||||
|
null,
|
||||||
|
array('autoload', 'dependency', 'package')
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'bin',
|
'bin',
|
||||||
|
@ -148,6 +150,42 @@ class ArrayDumperTest extends \PHPUnit_Framework_TestCase
|
||||||
array(
|
array(
|
||||||
'support',
|
'support',
|
||||||
array('foo' => 'bar'),
|
array('foo' => 'bar'),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'require',
|
||||||
|
array(new Link('foo', 'foo/bar', new VersionConstraint('=', '1.0.0.0'), 'requires', '1.0.0'), new Link('bar', 'bar/baz', new VersionConstraint('=', '1.0.0.0'), 'requires', '1.0.0')),
|
||||||
|
'requires',
|
||||||
|
array('bar/baz' => '1.0.0', 'foo/bar' => '1.0.0')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'require-dev',
|
||||||
|
array(new Link('foo', 'foo/bar', new VersionConstraint('=', '1.0.0.0'), 'requires', '1.0.0'), new Link('bar', 'bar/baz', new VersionConstraint('=', '1.0.0.0'), 'requires', '1.0.0')),
|
||||||
|
'devRequires',
|
||||||
|
array('bar/baz' => '1.0.0', 'foo/bar' => '1.0.0')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'suggest',
|
||||||
|
array('foo/bar' => 'very useful package', 'bar/baz' => 'another useful package'),
|
||||||
|
'suggests',
|
||||||
|
array('bar/baz' => 'another useful package', 'foo/bar' => 'very useful package')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'provide',
|
||||||
|
array(new Link('foo', 'foo/bar', new VersionConstraint('=', '1.0.0.0'), 'requires', '1.0.0'), new Link('bar', 'bar/baz', new VersionConstraint('=', '1.0.0.0'), 'requires', '1.0.0')),
|
||||||
|
'provides',
|
||||||
|
array('bar/baz' => '1.0.0', 'foo/bar' => '1.0.0')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'replace',
|
||||||
|
array(new Link('foo', 'foo/bar', new VersionConstraint('=', '1.0.0.0'), 'requires', '1.0.0'), new Link('bar', 'bar/baz', new VersionConstraint('=', '1.0.0.0'), 'requires', '1.0.0')),
|
||||||
|
'replaces',
|
||||||
|
array('bar/baz' => '1.0.0', 'foo/bar' => '1.0.0')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'conflict',
|
||||||
|
array(new Link('foo', 'foo/bar', new VersionConstraint('=', '1.0.0.0'), 'requires', '1.0.0'), new Link('bar', 'bar/baz', new VersionConstraint('=', '1.0.0.0'), 'requires', '1.0.0')),
|
||||||
|
'conflicts',
|
||||||
|
array('bar/baz' => '1.0.0', 'foo/bar' => '1.0.0')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue