From 313b79ee13a0063b7df1f93100239f66d7dcb3fb Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 15 Apr 2013 19:04:22 +0200 Subject: [PATCH] Implement search over description/keywords, refs #1801 --- src/Composer/Repository/ArrayRepository.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Composer/Repository/ArrayRepository.php b/src/Composer/Repository/ArrayRepository.php index 5d3553816..92732b4f6 100644 --- a/src/Composer/Repository/ArrayRepository.php +++ b/src/Composer/Repository/ArrayRepository.php @@ -14,6 +14,7 @@ namespace Composer\Repository; use Composer\Package\AliasPackage; use Composer\Package\PackageInterface; +use Composer\Package\CompletePackageInterface; use Composer\Package\Version\VersionParser; /** @@ -84,8 +85,12 @@ class ArrayRepository implements RepositoryInterface $matches = array(); foreach ($this->getPackages() as $package) { $name = $package->getName(); - // TODO implement SEARCH_FULLTEXT handling with keywords/description matching - if (!isset($matches[$name]) && preg_match($regex, $name)) { + if (isset($matches[$name])) { + continue; + } + if (preg_match($regex, $name) + || ($mode === self::SEARCH_FULLTEXT && $package instanceof CompletePackageInterface && preg_match($regex, implode(' ', (array) $package->getKeywords()) . ' ' . $package->getDescription())) + ) { $matches[$name] = array( 'name' => $package->getPrettyName(), 'description' => $package->getDescription(),