Aggiornato Composer
This commit is contained in:
20
vendor/symfony/console/Command/Command.php
vendored
20
vendor/symfony/console/Command/Command.php
vendored
@@ -96,7 +96,7 @@ class Command
|
||||
*
|
||||
* @throws LogicException When the command name is empty
|
||||
*/
|
||||
public function __construct(string $name = null)
|
||||
public function __construct(?string $name = null)
|
||||
{
|
||||
$this->definition = new InputDefinition();
|
||||
|
||||
@@ -132,7 +132,7 @@ class Command
|
||||
$this->ignoreValidationErrors = true;
|
||||
}
|
||||
|
||||
public function setApplication(Application $application = null)
|
||||
public function setApplication(?Application $application = null)
|
||||
{
|
||||
$this->application = $application;
|
||||
if ($application) {
|
||||
@@ -242,7 +242,7 @@ class Command
|
||||
*
|
||||
* @return int The command exit code
|
||||
*
|
||||
* @throws \Exception When binding input fails. Bypass this by calling {@link ignoreValidationErrors()}.
|
||||
* @throws ExceptionInterface When input binding fails. Bypass this by calling {@link ignoreValidationErrors()}.
|
||||
*
|
||||
* @see setCode()
|
||||
* @see execute()
|
||||
@@ -429,11 +429,11 @@ class Command
|
||||
* @param int|null $mode The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL
|
||||
* @param mixed $default The default value (for InputArgument::OPTIONAL mode only)
|
||||
*
|
||||
* @throws InvalidArgumentException When argument mode is not valid
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws InvalidArgumentException When argument mode is not valid
|
||||
*/
|
||||
public function addArgument(string $name, int $mode = null, string $description = '', $default = null)
|
||||
public function addArgument(string $name, ?int $mode = null, string $description = '', $default = null)
|
||||
{
|
||||
$this->definition->addArgument(new InputArgument($name, $mode, $description, $default));
|
||||
if (null !== $this->fullDefinition) {
|
||||
@@ -450,11 +450,11 @@ class Command
|
||||
* @param int|null $mode The option mode: One of the InputOption::VALUE_* constants
|
||||
* @param mixed $default The default value (must be null for InputOption::VALUE_NONE)
|
||||
*
|
||||
* @throws InvalidArgumentException If option mode is invalid or incompatible
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws InvalidArgumentException If option mode is invalid or incompatible
|
||||
*/
|
||||
public function addOption(string $name, $shortcut = null, int $mode = null, string $description = '', $default = null)
|
||||
public function addOption(string $name, $shortcut = null, ?int $mode = null, string $description = '', $default = null)
|
||||
{
|
||||
$this->definition->addOption(new InputOption($name, $shortcut, $mode, $description, $default));
|
||||
if (null !== $this->fullDefinition) {
|
||||
@@ -518,7 +518,7 @@ class Command
|
||||
*
|
||||
* @final since Symfony 5.1
|
||||
*/
|
||||
public function setHidden(bool $hidden /*= true*/)
|
||||
public function setHidden(bool $hidden /* = true */)
|
||||
{
|
||||
$this->hidden = $hidden;
|
||||
|
||||
|
||||
@@ -65,15 +65,15 @@ final class CompleteCommand extends Command
|
||||
{
|
||||
try {
|
||||
// uncomment when a bugfix or BC break has been introduced in the shell completion scripts
|
||||
//$version = $input->getOption('symfony');
|
||||
//if ($version && version_compare($version, 'x.y', '>=')) {
|
||||
// $version = $input->getOption('symfony');
|
||||
// if ($version && version_compare($version, 'x.y', '>=')) {
|
||||
// $message = sprintf('Completion script version is not supported ("%s" given, ">=x.y" required).', $version);
|
||||
// $this->log($message);
|
||||
|
||||
// $output->writeln($message.' Install the Symfony completion script again by using the "completion" command.');
|
||||
|
||||
// return 126;
|
||||
//}
|
||||
// }
|
||||
|
||||
$shell = $input->getOption('shell');
|
||||
if (!$shell) {
|
||||
@@ -105,11 +105,12 @@ final class CompleteCommand extends Command
|
||||
} elseif (
|
||||
$completionInput->mustSuggestArgumentValuesFor('command')
|
||||
&& $command->getName() !== $completionInput->getCompletionValue()
|
||||
&& !\in_array($completionInput->getCompletionValue(), $command->getAliases(), true)
|
||||
) {
|
||||
$this->log(' No command found, completing using the Application class.');
|
||||
|
||||
// expand shortcut names ("cache:cl<TAB>") into their full name ("cache:clear")
|
||||
$suggestions->suggestValue($command->getName());
|
||||
$suggestions->suggestValues(array_filter(array_merge([$command->getName()], $command->getAliases())));
|
||||
} else {
|
||||
$command->mergeApplicationDefinition();
|
||||
$completionInput->bind($command->getDefinition());
|
||||
@@ -154,10 +155,10 @@ final class CompleteCommand extends Command
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return self::FAILURE;
|
||||
return 2;
|
||||
}
|
||||
|
||||
return self::SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function createCompletionInput(InputInterface $input): CompletionInput
|
||||
|
||||
@@ -41,7 +41,7 @@ final class DumpCompletionCommand extends Command
|
||||
{
|
||||
$fullCommand = $_SERVER['PHP_SELF'];
|
||||
$commandName = basename($fullCommand);
|
||||
$fullCommand = realpath($fullCommand) ?: $fullCommand;
|
||||
$fullCommand = @realpath($fullCommand) ?: $fullCommand;
|
||||
|
||||
$this
|
||||
->setHelp(<<<EOH
|
||||
@@ -53,7 +53,7 @@ to use shell autocompletion (currently only bash completion is supported).
|
||||
|
||||
Dump the script to a global completion file and restart your shell:
|
||||
|
||||
<info>%command.full_name% bash | sudo tee /etc/bash_completion.d/${commandName}</>
|
||||
<info>%command.full_name% bash | sudo tee /etc/bash_completion.d/{$commandName}</>
|
||||
|
||||
Or dump the script to a local file and source it:
|
||||
|
||||
@@ -70,7 +70,7 @@ Or dump the script to a local file and source it:
|
||||
|
||||
Add this to the end of your shell configuration file (e.g. <info>"~/.bashrc"</>):
|
||||
|
||||
<info>eval "$(${fullCommand} completion bash)"</>
|
||||
<info>eval "$({$fullCommand} completion bash)"</>
|
||||
EOH
|
||||
)
|
||||
->addArgument('shell', InputArgument::OPTIONAL, 'The shell type (e.g. "bash"), the value of the "$SHELL" env var will be used if this is not given')
|
||||
@@ -85,7 +85,7 @@ EOH
|
||||
if ($input->getOption('debug')) {
|
||||
$this->tailDebugLog($commandName, $output);
|
||||
|
||||
return self::SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
$shell = $input->getArgument('shell') ?? self::guessShell();
|
||||
@@ -93,15 +93,21 @@ EOH
|
||||
if (!file_exists($completionFile)) {
|
||||
$supportedShells = $this->getSupportedShells();
|
||||
|
||||
($output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output)
|
||||
->writeln(sprintf('<error>Detected shell "%s", which is not supported by Symfony shell completion (supported shells: "%s").</>', $shell, implode('", "', $supportedShells)));
|
||||
if ($output instanceof ConsoleOutputInterface) {
|
||||
$output = $output->getErrorOutput();
|
||||
}
|
||||
if ($shell) {
|
||||
$output->writeln(sprintf('<error>Detected shell "%s", which is not supported by Symfony shell completion (supported shells: "%s").</>', $shell, implode('", "', $supportedShells)));
|
||||
} else {
|
||||
$output->writeln(sprintf('<error>Shell not detected, Symfony shell completion only supports "%s").</>', implode('", "', $supportedShells)));
|
||||
}
|
||||
|
||||
return self::INVALID;
|
||||
return 2;
|
||||
}
|
||||
|
||||
$output->write(str_replace(['{{ COMMAND_NAME }}', '{{ VERSION }}'], [$commandName, $this->getApplication()->getVersion()], file_get_contents($completionFile)));
|
||||
|
||||
return self::SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static function guessShell(): string
|
||||
@@ -126,8 +132,14 @@ EOH
|
||||
*/
|
||||
private function getSupportedShells(): array
|
||||
{
|
||||
return array_map(function ($f) {
|
||||
return pathinfo($f, \PATHINFO_EXTENSION);
|
||||
}, glob(__DIR__.'/../Resources/completion.*'));
|
||||
$shells = [];
|
||||
|
||||
foreach (new \DirectoryIterator(__DIR__.'/../Resources/') as $file) {
|
||||
if (str_starts_with($file->getBasename(), 'completion.') && $file->isFile()) {
|
||||
$shells[] = $file->getExtension();
|
||||
}
|
||||
}
|
||||
|
||||
return $shells;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ final class LazyCommand extends Command
|
||||
$this->getCommand()->ignoreValidationErrors();
|
||||
}
|
||||
|
||||
public function setApplication(Application $application = null): void
|
||||
public function setApplication(?Application $application = null): void
|
||||
{
|
||||
if ($this->command instanceof parent) {
|
||||
$this->command->setApplication($application);
|
||||
@@ -117,7 +117,7 @@ final class LazyCommand extends Command
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function addArgument(string $name, int $mode = null, string $description = '', $default = null): self
|
||||
public function addArgument(string $name, ?int $mode = null, string $description = '', $default = null): self
|
||||
{
|
||||
$this->getCommand()->addArgument($name, $mode, $description, $default);
|
||||
|
||||
@@ -127,7 +127,7 @@ final class LazyCommand extends Command
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function addOption(string $name, $shortcut = null, int $mode = null, string $description = '', $default = null): self
|
||||
public function addOption(string $name, $shortcut = null, ?int $mode = null, string $description = '', $default = null): self
|
||||
{
|
||||
$this->getCommand()->addOption($name, $shortcut, $mode, $description, $default);
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ trait LockableTrait
|
||||
/**
|
||||
* Locks a command.
|
||||
*/
|
||||
private function lock(string $name = null, bool $blocking = false): bool
|
||||
private function lock(?string $name = null, bool $blocking = false): bool
|
||||
{
|
||||
if (!class_exists(SemaphoreStore::class)) {
|
||||
throw new LogicException('To enable the locking feature you must install the symfony/lock component.');
|
||||
|
||||
Reference in New Issue
Block a user