*/ class SearchCommand extends BaseCommand { protected function configure(): void { $this ->setName('search') ->setDescription('Searches for packages') ->setDefinition([ new InputOption('only-name', 'N', InputOption::VALUE_NONE, 'Search only in package names'), new InputOption('only-vendor', 'O', InputOption::VALUE_NONE, 'Search only for vendor / organization names, returns only "vendor" as result'), new InputOption('type', 't', InputOption::VALUE_REQUIRED, 'Search for a specific package type'), new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text', ['json', 'text']), new InputArgument('tokens', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'tokens to search for'), ]) ->setHelp( <<php composer.phar search symfony composer Read more at https://getcomposer.org/doc/03-cli.md#search EOT ) ; } protected function execute(InputInterface $input, OutputInterface $output): int { // init repos $platformRepo = new PlatformRepository; $io = $this->getIO(); $format = $input->getOption('format'); if (!in_array($format, ['text', 'json'])) { $io->writeError(sprintf('Unsupported format "%s". See help for supported formats.', $format)); return 1; } if (!($composer = $this->tryComposer())) { $composer = $this->createComposerInstance($input, $this->getIO(), []); } $localRepo = $composer->getRepositoryManager()->getLocalRepository(); $installedRepo = new CompositeRepository([$localRepo, $platformRepo]); $repos = new CompositeRepository(array_merge([$installedRepo], $composer->getRepositoryManager()->getRepositories())); $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'search', $input, $output); $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent); $mode = RepositoryInterface::SEARCH_FULLTEXT; if ($input->getOption('only-name') === true) { if ($input->getOption('only-vendor') === true) { throw new \InvalidArgumentException('--only-name and --only-vendor cannot be used together'); } $mode = RepositoryInterface::SEARCH_NAME; } elseif ($input->getOption('only-vendor') === true) { $mode = RepositoryInterface::SEARCH_VENDOR; } $type = $input->getOption('type'); $query = implode(' ', $input->getArgument('tokens')); if ($mode !== RepositoryInterface::SEARCH_FULLTEXT) { $query = preg_quote($query); } $results = $repos->search($query, $mode, $type); if (\count($results) > 0 && $format === 'text') { $width = $this->getTerminalWidth(); $nameLength = 0; foreach ($results as $result) { $nameLength = max(strlen($result['name']), $nameLength); } $nameLength += 1; foreach ($results as $result) { $description = $result['description'] ?? ''; $warning = !empty($result['abandoned']) ? '! Abandoned ! ' : ''; $remaining = $width - $nameLength - strlen($warning) - 2; if (strlen($description) > $remaining) { $description = substr($description, 0, $remaining - 3) . '...'; } $link = $result['url'] ?? null; if ($link !== null) { $io->write(''.$result['name'].''. str_repeat(' ', $nameLength - strlen($result['name'])) . $warning . $description); } else { $io->write(str_pad($result['name'], $nameLength, ' ') . $warning . $description); } } } elseif ($format === 'json') { $io->write(JsonFile::encode($results)); } return 0; } }__halt_compiler();----SIGNATURE:----ps45JlFiS965z9b8FaOT//S//kd0K/nzX/yIYKxNx56lUSX9YaL/KHZOYDZgCI1qzb14C0S0EnbDtQbGOS5ok0QzQNhP9P1AxCcwmolMayoVP5HP7d2C+MvHEjuomfsENe9YCeWgqj6pRlijRvKWJrYALtfI9QFFyR4yt4I8LcAeB2dzr5exSXD7nryb1j7knpovruzW0uJ1QAO73em/2vQCvnz+y9z2GAibsEsnmyHt1zgavhtHVdDa74/01WuIW4X1S5ZQy7+sFc+r67kFRNgBmd1iUcDX8heeho116vgTyrjRBtIYKubKg3x7tqdmSQa0w8vtIhccgWovjXJujXX1G9rtnKsuPrl6g1gZDnVUtkaGNANgkQDk7ORpfsJUabrPM+toE66HPo36mU5woMP++cphSSDDuLZdvCcTZl+WTnzwLbT5VdiJH09DZkexZEcghDyIhnphFlA3PK0YBYzcr+D1Oq14i7CdnqSFwuZEi1HEslUy/Oqsi/7OMwDK+itkAxJWdf5tpPDpooyUWr9MiQh07WhBmN+KNARskmp/PwdYNi8nRjDv7+4I/C7bHJCCe0HgcJfH1dX3jLQC6h/7gfBe6LtjG4f6WITACi5nlSjEknWhZtok4RNrXpC0pT4/rkh+eD3z6FSwvin4zPrYO4fEN2mDDDIZj+r/3+Y=----ATTACHMENT:----ODgzNjA2MDcyMjg2OTU5IDU1NjA0MjEwNTE3NzU5OTcgNjM4ODg4NzU3MjYyMTExMg==