Update depends command
parent
8d4f8543fc
commit
d1f66073ca
|
@ -25,7 +25,10 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||||
*/
|
*/
|
||||||
class DependsCommand extends Command
|
class DependsCommand extends Command
|
||||||
{
|
{
|
||||||
protected $linkTypes = array('require', 'recommend', 'suggest');
|
protected $linkTypes = array(
|
||||||
|
'require' => 'requires',
|
||||||
|
'require-dev' => 'devRequires',
|
||||||
|
);
|
||||||
|
|
||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
|
@ -34,7 +37,7 @@ class DependsCommand extends Command
|
||||||
->setDescription('Shows which packages depend on the given package')
|
->setDescription('Shows which packages depend on the given package')
|
||||||
->setDefinition(array(
|
->setDefinition(array(
|
||||||
new InputArgument('package', InputArgument::REQUIRED, 'Package to inspect'),
|
new InputArgument('package', InputArgument::REQUIRED, 'Package to inspect'),
|
||||||
new InputOption('link-type', '', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Link types to show', $this->linkTypes)
|
new InputOption('link-type', '', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Link types to show (require, require-dev)', array_keys($this->linkTypes))
|
||||||
))
|
))
|
||||||
->setHelp(<<<EOT
|
->setHelp(<<<EOT
|
||||||
Displays detailed information about where a package is referenced.
|
Displays detailed information about where a package is referenced.
|
||||||
|
@ -81,10 +84,10 @@ EOT
|
||||||
foreach ($repository->getPackages() as $package) {
|
foreach ($repository->getPackages() as $package) {
|
||||||
foreach ($types as $type) {
|
foreach ($types as $type) {
|
||||||
$type = rtrim($type, 's');
|
$type = rtrim($type, 's');
|
||||||
if (!in_array($type, $this->linkTypes)) {
|
if (!isset($this->linkTypes[$type])) {
|
||||||
throw new \InvalidArgumentException('Unexpected link type: '.$type.', valid types: '.implode(', ', $this->linkTypes));
|
throw new \InvalidArgumentException('Unexpected link type: '.$type.', valid types: '.implode(', ', array_keys($this->linkTypes)));
|
||||||
}
|
}
|
||||||
foreach ($package->{'get'.$type.'s'}() as $link) {
|
foreach ($package->{'get'.$this->linkTypes[$type]}() as $link) {
|
||||||
if ($link->getTarget() === $needle) {
|
if ($link->getTarget() === $needle) {
|
||||||
if ($verbose) {
|
if ($verbose) {
|
||||||
$references[] = array($type, $package, $link);
|
$references[] = array($type, $package, $link);
|
||||||
|
|
|
@ -72,7 +72,6 @@ class InstallationManagerTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->createPackageMock(), $this->createPackageMock()
|
$this->createPackageMock(), $this->createPackageMock()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
$manager
|
$manager
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('install')
|
->method('install')
|
||||||
|
|
Loading…
Reference in New Issue