From 57d1b5a37d84834f5d3a58e2ec41c3868f1c26b2 Mon Sep 17 00:00:00 2001 From: Povilas Balzaravicius Pawka Date: Thu, 6 Sep 2012 09:12:28 +0300 Subject: [PATCH 1/3] Issue #1056. Fixed callback call error on search command. --- src/Composer/Repository/ArrayRepository.php | 2 +- src/Composer/Repository/ComposerRepository.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Composer/Repository/ArrayRepository.php b/src/Composer/Repository/ArrayRepository.php index 07f648e0f..49ddd99d5 100644 --- a/src/Composer/Repository/ArrayRepository.php +++ b/src/Composer/Repository/ArrayRepository.php @@ -118,7 +118,7 @@ class ArrayRepository implements RepositoryInterface public function filterPackages($callback, $class = 'Composer\Package\Package') { foreach ($this->getPackages() as $package) { - if (false === $callback($package)) { + if (false === call_user_func($callback, $package)) { return false; } } diff --git a/src/Composer/Repository/ComposerRepository.php b/src/Composer/Repository/ComposerRepository.php index 123e08bce..0ea86e5e8 100644 --- a/src/Composer/Repository/ComposerRepository.php +++ b/src/Composer/Repository/ComposerRepository.php @@ -135,11 +135,11 @@ class ComposerRepository extends ArrayRepository implements NotifiableRepository } foreach ($this->rawData as $package) { - if (false === $callback($package = $this->loader->load($package, $class))) { + if (false === call_user_func($callback, $package = $this->loader->load($package, $class))) { return false; } if ($package->getAlias()) { - if (false === $callback($this->createAliasPackage($package))) { + if (false === call_user_func($callback, $this->createAliasPackage($package))) { return false; } } From 7154ef9af786c908c8d90f74b4d2bff42c36d4ad Mon Sep 17 00:00:00 2001 From: Povilas Balzaravicius Pawka Date: Thu, 6 Sep 2012 09:16:10 +0300 Subject: [PATCH 2/3] search: fixed output error when no results found. --- src/Composer/Command/SearchCommand.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Composer/Command/SearchCommand.php b/src/Composer/Command/SearchCommand.php index 1b3a535a0..b852314fc 100644 --- a/src/Composer/Command/SearchCommand.php +++ b/src/Composer/Command/SearchCommand.php @@ -67,8 +67,10 @@ EOT $this->output = $output; $repos->filterPackages(array($this, 'processPackage'), 'Composer\Package\CompletePackage'); - foreach ($this->lowMatches as $details) { - $output->writeln($details['name'] . ': '. $details['description']); + if (!empty($this->lowMatches)) { + foreach ($this->lowMatches as $details) { + $output->writeln($details['name'] . ': '. $details['description']); + } } } From bbac63821c80c4d53dbb15632d993873afee91a1 Mon Sep 17 00:00:00 2001 From: Povilas Balzaravicius Pawka Date: Thu, 6 Sep 2012 13:39:51 +0300 Subject: [PATCH 3/3] Search: initialize lowMatches as empty array. --- src/Composer/Command/SearchCommand.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Composer/Command/SearchCommand.php b/src/Composer/Command/SearchCommand.php index b852314fc..e332ac1f8 100644 --- a/src/Composer/Command/SearchCommand.php +++ b/src/Composer/Command/SearchCommand.php @@ -27,7 +27,7 @@ use Composer\Factory; class SearchCommand extends Command { protected $matches; - protected $lowMatches; + protected $lowMatches = array(); protected $tokens; protected $output; @@ -67,10 +67,8 @@ EOT $this->output = $output; $repos->filterPackages(array($this, 'processPackage'), 'Composer\Package\CompletePackage'); - if (!empty($this->lowMatches)) { - foreach ($this->lowMatches as $details) { - $output->writeln($details['name'] . ': '. $details['description']); - } + foreach ($this->lowMatches as $details) { + $output->writeln($details['name'] . ': '. $details['description']); } }