diff --git a/src/Composer/Command/SearchCommand.php b/src/Composer/Command/SearchCommand.php index d06c3aa91..10df68e35 100644 --- a/src/Composer/Command/SearchCommand.php +++ b/src/Composer/Command/SearchCommand.php @@ -46,16 +46,21 @@ EOT // create local repo, this contains all packages that are installed in the local project $localRepo = $composer->getRepositoryManager()->getLocalRepository(); + $tokens = array_map('strtolower', $input->getArgument('tokens')); foreach ($composer->getRepositoryManager()->getRepositories() as $repository) { foreach ($repository->getPackages() as $package) { - foreach ((array) $input->getArgument('tokens') as $token) { - if (false === strpos($package->getName(), $token)) { + foreach ($tokens as $token) { + if (false === ($pos = strpos($package->getName(), $token))) { continue; } $state = $localRepo->hasPackage($package) ? 'installed' : $state = 'available'; - $output->writeln($state . ': ' . $package->getPrettyName() . ' ' . $package->getPrettyVersion() . ''); + $name = substr($package->getPrettyName(), 0, $pos) + . '' . substr($package->getPrettyName(), $pos, strlen($token)) . '' + . substr($package->getPrettyName(), $pos + strlen($token)); + $output->writeln($state . ': ' . $name . ' ' . $package->getPrettyVersion() . ''); + continue 2; } } }