2021-11-30 07:57:42 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of the Symfony package.
|
|
|
|
*
|
|
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
2022-01-26 10:10:51 +00:00
|
|
|
namespace RectorPrefix20220126\Symfony\Component\Console\Completion;
|
2021-11-30 07:57:42 +00:00
|
|
|
|
2022-01-26 10:10:51 +00:00
|
|
|
use RectorPrefix20220126\Symfony\Component\Console\Input\InputOption;
|
2021-11-30 07:57:42 +00:00
|
|
|
/**
|
|
|
|
* Stores all completion suggestions for the current input.
|
|
|
|
*
|
|
|
|
* @author Wouter de Jong <wouter@wouterj.nl>
|
|
|
|
*/
|
|
|
|
final class CompletionSuggestions
|
|
|
|
{
|
|
|
|
private $valueSuggestions = [];
|
|
|
|
private $optionSuggestions = [];
|
|
|
|
/**
|
|
|
|
* Add a suggested value for an input option or argument.
|
|
|
|
*
|
|
|
|
* @return $this
|
2021-12-09 13:05:29 +00:00
|
|
|
* @param string|\Symfony\Component\Console\Completion\Suggestion $value
|
2021-11-30 07:57:42 +00:00
|
|
|
*/
|
2021-12-09 13:05:29 +00:00
|
|
|
public function suggestValue($value)
|
2021-11-30 07:57:42 +00:00
|
|
|
{
|
2022-01-26 10:10:51 +00:00
|
|
|
$this->valueSuggestions[] = !$value instanceof \RectorPrefix20220126\Symfony\Component\Console\Completion\Suggestion ? new \RectorPrefix20220126\Symfony\Component\Console\Completion\Suggestion($value) : $value;
|
2021-11-30 07:57:42 +00:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Add multiple suggested values at once for an input option or argument.
|
|
|
|
*
|
|
|
|
* @param list<string|Suggestion> $values
|
|
|
|
*
|
|
|
|
* @return $this
|
|
|
|
*/
|
2021-12-09 13:05:29 +00:00
|
|
|
public function suggestValues(array $values)
|
2021-11-30 07:57:42 +00:00
|
|
|
{
|
|
|
|
foreach ($values as $value) {
|
|
|
|
$this->suggestValue($value);
|
|
|
|
}
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Add a suggestion for an input option name.
|
|
|
|
*
|
|
|
|
* @return $this
|
|
|
|
*/
|
2022-01-26 10:10:51 +00:00
|
|
|
public function suggestOption(\RectorPrefix20220126\Symfony\Component\Console\Input\InputOption $option)
|
2021-11-30 07:57:42 +00:00
|
|
|
{
|
|
|
|
$this->optionSuggestions[] = $option;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Add multiple suggestions for input option names at once.
|
|
|
|
*
|
|
|
|
* @param InputOption[] $options
|
|
|
|
*
|
|
|
|
* @return $this
|
|
|
|
*/
|
2021-12-09 13:05:29 +00:00
|
|
|
public function suggestOptions(array $options)
|
2021-11-30 07:57:42 +00:00
|
|
|
{
|
|
|
|
foreach ($options as $option) {
|
|
|
|
$this->suggestOption($option);
|
|
|
|
}
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @return InputOption[]
|
|
|
|
*/
|
|
|
|
public function getOptionSuggestions() : array
|
|
|
|
{
|
|
|
|
return $this->optionSuggestions;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @return Suggestion[]
|
|
|
|
*/
|
|
|
|
public function getValueSuggestions() : array
|
|
|
|
{
|
|
|
|
return $this->valueSuggestions;
|
|
|
|
}
|
|
|
|
}
|