package and depencies
This commit is contained in:
@@ -64,9 +64,6 @@ final class CompletionInput extends ArgvInput
|
||||
return $input;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function bind(InputDefinition $definition): void
|
||||
{
|
||||
parent::bind($definition);
|
||||
@@ -84,7 +81,7 @@ final class CompletionInput extends ArgvInput
|
||||
return;
|
||||
}
|
||||
|
||||
if (null !== $option && $option->acceptValue()) {
|
||||
if ($option?->acceptValue()) {
|
||||
$this->completionType = self::TYPE_OPTION_VALUE;
|
||||
$this->completionName = $option->getName();
|
||||
$this->completionValue = $optionValue ?: (!str_starts_with($optionToken, '--') ? substr($optionToken, 2) : '');
|
||||
@@ -97,7 +94,7 @@ final class CompletionInput extends ArgvInput
|
||||
if ('-' === $previousToken[0] && '' !== trim($previousToken, '-')) {
|
||||
// check if previous option accepted a value
|
||||
$previousOption = $this->getOptionFromToken($previousToken);
|
||||
if (null !== $previousOption && $previousOption->acceptValue()) {
|
||||
if ($previousOption?->acceptValue()) {
|
||||
$this->completionType = self::TYPE_OPTION_VALUE;
|
||||
$this->completionName = $previousOption->getName();
|
||||
$this->completionValue = $relevantToken;
|
||||
@@ -183,7 +180,7 @@ final class CompletionInput extends ArgvInput
|
||||
{
|
||||
try {
|
||||
return parent::parseToken($token, $parseOptions);
|
||||
} catch (RuntimeException $e) {
|
||||
} catch (RuntimeException) {
|
||||
// suppress errors, completed input is almost never valid
|
||||
}
|
||||
|
||||
|
@@ -26,11 +26,9 @@ final class CompletionSuggestions
|
||||
/**
|
||||
* Add a suggested value for an input option or argument.
|
||||
*
|
||||
* @param string|Suggestion $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function suggestValue($value): self
|
||||
public function suggestValue(string|Suggestion $value): static
|
||||
{
|
||||
$this->valueSuggestions[] = !$value instanceof Suggestion ? new Suggestion($value) : $value;
|
||||
|
||||
@@ -44,7 +42,7 @@ final class CompletionSuggestions
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function suggestValues(array $values): self
|
||||
public function suggestValues(array $values): static
|
||||
{
|
||||
foreach ($values as $value) {
|
||||
$this->suggestValue($value);
|
||||
@@ -58,7 +56,7 @@ final class CompletionSuggestions
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function suggestOption(InputOption $option): self
|
||||
public function suggestOption(InputOption $option): static
|
||||
{
|
||||
$this->optionSuggestions[] = $option;
|
||||
|
||||
@@ -72,7 +70,7 @@ final class CompletionSuggestions
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function suggestOptions(array $options): self
|
||||
public function suggestOptions(array $options): static
|
||||
{
|
||||
foreach ($options as $option) {
|
||||
$this->suggestOption($option);
|
||||
|
33
vendor/symfony/console/Completion/Output/FishCompletionOutput.php
vendored
Normal file
33
vendor/symfony/console/Completion/Output/FishCompletionOutput.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Completion\Output;
|
||||
|
||||
use Symfony\Component\Console\Completion\CompletionSuggestions;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* @author Guillaume Aveline <guillaume.aveline@pm.me>
|
||||
*/
|
||||
class FishCompletionOutput implements CompletionOutputInterface
|
||||
{
|
||||
public function write(CompletionSuggestions $suggestions, OutputInterface $output): void
|
||||
{
|
||||
$values = $suggestions->getValueSuggestions();
|
||||
foreach ($suggestions->getOptionSuggestions() as $option) {
|
||||
$values[] = '--'.$option->getName();
|
||||
if ($option->isNegatable()) {
|
||||
$values[] = '--no-'.$option->getName();
|
||||
}
|
||||
}
|
||||
$output->write(implode("\n", $values));
|
||||
}
|
||||
}
|
36
vendor/symfony/console/Completion/Output/ZshCompletionOutput.php
vendored
Normal file
36
vendor/symfony/console/Completion/Output/ZshCompletionOutput.php
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Console\Completion\Output;
|
||||
|
||||
use Symfony\Component\Console\Completion\CompletionSuggestions;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* @author Jitendra A <adhocore@gmail.com>
|
||||
*/
|
||||
class ZshCompletionOutput implements CompletionOutputInterface
|
||||
{
|
||||
public function write(CompletionSuggestions $suggestions, OutputInterface $output): void
|
||||
{
|
||||
$values = [];
|
||||
foreach ($suggestions->getValueSuggestions() as $value) {
|
||||
$values[] = $value->getValue().($value->getDescription() ? "\t".$value->getDescription() : '');
|
||||
}
|
||||
foreach ($suggestions->getOptionSuggestions() as $option) {
|
||||
$values[] = '--'.$option->getName().($option->getDescription() ? "\t".$option->getDescription() : '');
|
||||
if ($option->isNegatable()) {
|
||||
$values[] = '--no-'.$option->getName().($option->getDescription() ? "\t".$option->getDescription() : '');
|
||||
}
|
||||
}
|
||||
$output->write(implode("\n", $values)."\n");
|
||||
}
|
||||
}
|
16
vendor/symfony/console/Completion/Suggestion.php
vendored
16
vendor/symfony/console/Completion/Suggestion.php
vendored
@@ -16,13 +16,12 @@ namespace Symfony\Component\Console\Completion;
|
||||
*
|
||||
* @author Wouter de Jong <wouter@wouterj.nl>
|
||||
*/
|
||||
class Suggestion
|
||||
class Suggestion implements \Stringable
|
||||
{
|
||||
private $value;
|
||||
|
||||
public function __construct(string $value)
|
||||
{
|
||||
$this->value = $value;
|
||||
public function __construct(
|
||||
private readonly string $value,
|
||||
private readonly string $description = ''
|
||||
) {
|
||||
}
|
||||
|
||||
public function getValue(): string
|
||||
@@ -30,6 +29,11 @@ class Suggestion
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->getValue();
|
||||
|
Reference in New Issue
Block a user