/** * prints all available versions of this package and highlights the installed one if any */ protected function printVersions(InputInterface $input, OutputInterface $output, PackageInterface $package, RepositoryInterface $installedRepo, RepositoryInterface $repos) { if ($input->getArgument('version')) { $output->writeln('<info>version</info> : ' . $package->getPrettyVersion()); return; } $versions = array(); foreach ($repos->findPackagesByName($package->getName()) as $version) { $versions[] = $version->getPrettyVersion(); } $versions = join(', ', $versions); // highlight installed version if ($installedRepo->hasPackage($package)) { $versions = str_replace($package->getPrettyVersion(), '<info>* ' . $package->getPrettyVersion() . '</info>', $versions); } $output->writeln('<info>versions</info> : ' . $versions); }