fix:更新已知bug,优化代码
This commit is contained in:
@@ -208,7 +208,7 @@ EOLUA;
|
||||
// and removes the linked items. When the set is still not empty after
|
||||
// the scan, it means we're in cluster mode and that the linked items
|
||||
// are on other nodes: we move the links to a temporary set and we
|
||||
// gargage collect that set from the client side.
|
||||
// garbage collect that set from the client side.
|
||||
|
||||
$lua = <<<'EOLUA'
|
||||
redis.replicate_commands()
|
||||
|
||||
@@ -51,7 +51,7 @@ class TagAwareMarshaller implements MarshallerInterface
|
||||
$serialized[$id][9] = "\x5F";
|
||||
}
|
||||
} else {
|
||||
// other arbitratry values are serialized using the decorated marshaller below
|
||||
// other arbitrary values are serialized using the decorated marshaller below
|
||||
$notSerialized[$id] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
12
vendor/symfony/cache/README.md
vendored
12
vendor/symfony/cache/README.md
vendored
@@ -1,13 +1,13 @@
|
||||
Symfony PSR-6 implementation for caching
|
||||
========================================
|
||||
|
||||
The Cache component provides an extended
|
||||
[PSR-6](http://www.php-fig.org/psr/psr-6/) implementation for adding cache to
|
||||
The Cache component provides extended
|
||||
[PSR-6](https://www.php-fig.org/psr/psr-6/) implementations for adding cache to
|
||||
your applications. It is designed to have a low overhead so that caching is
|
||||
fastest. It ships with a few caching adapters for the most widespread and
|
||||
suited to caching backends. It also provides a `doctrine/cache` proxy adapter
|
||||
to cover more advanced caching needs and a proxy adapter for greater
|
||||
interoperability between PSR-6 implementations.
|
||||
fastest. It ships with adapters for the most widespread caching backends.
|
||||
It also provides a [PSR-16](https://www.php-fig.org/psr/psr-16/) adapter,
|
||||
and implementations for [symfony/cache-contracts](https://github.com/symfony/cache-contracts)'
|
||||
`CacheInterface` and `TagAwareCacheInterface`.
|
||||
|
||||
Resources
|
||||
---------
|
||||
|
||||
@@ -394,7 +394,7 @@ trait AbstractAdapterTrait
|
||||
$this->ids[$key] = $key;
|
||||
|
||||
if (\count($this->ids) > 1000) {
|
||||
array_splice($this->ids, 0, 500); // stop memory leak if there are many keys
|
||||
$this->ids = \array_slice($this->ids, 500, null, true); // stop memory leak if there are many keys
|
||||
}
|
||||
|
||||
if (null === $this->maxIdLength) {
|
||||
|
||||
2
vendor/symfony/cache/composer.json
vendored
2
vendor/symfony/cache/composer.json
vendored
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "symfony/cache",
|
||||
"type": "library",
|
||||
"description": "Provides an extended PSR-6, PSR-16 (and tags) implementation",
|
||||
"description": "Provides extended PSR-6, PSR-16 (and tags) implementations",
|
||||
"keywords": ["caching", "psr6"],
|
||||
"homepage": "https://symfony.com",
|
||||
"license": "MIT",
|
||||
|
||||
160
vendor/symfony/console/Application.php
vendored
160
vendor/symfony/console/Application.php
vendored
@@ -70,23 +70,23 @@ use Symfony\Contracts\Service\ResetInterface;
|
||||
*/
|
||||
class Application implements ResetInterface
|
||||
{
|
||||
private $commands = [];
|
||||
private $wantHelps = false;
|
||||
private $runningCommand;
|
||||
private $name;
|
||||
private $version;
|
||||
private $commandLoader;
|
||||
private $catchExceptions = true;
|
||||
private $autoExit = true;
|
||||
private array $commands = [];
|
||||
private bool $wantHelps = false;
|
||||
private $runningCommand = null;
|
||||
private string $name;
|
||||
private string $version;
|
||||
private $commandLoader = null;
|
||||
private bool $catchExceptions = true;
|
||||
private bool $autoExit = true;
|
||||
private $definition;
|
||||
private $helperSet;
|
||||
private $dispatcher;
|
||||
private $dispatcher = null;
|
||||
private $terminal;
|
||||
private $defaultCommand;
|
||||
private $singleCommand = false;
|
||||
private $initialized;
|
||||
private string $defaultCommand;
|
||||
private bool $singleCommand = false;
|
||||
private bool $initialized = false;
|
||||
private $signalRegistry;
|
||||
private $signalsToDispatchEvent = [];
|
||||
private array $signalsToDispatchEvent = [];
|
||||
|
||||
public function __construct(string $name = 'UNKNOWN', string $version = 'UNKNOWN')
|
||||
{
|
||||
@@ -134,7 +134,7 @@ class Application implements ResetInterface
|
||||
*
|
||||
* @throws \Exception When running fails. Bypass this when {@link setCatchExceptions()}.
|
||||
*/
|
||||
public function run(InputInterface $input = null, OutputInterface $output = null)
|
||||
public function run(InputInterface $input = null, OutputInterface $output = null): int
|
||||
{
|
||||
if (\function_exists('putenv')) {
|
||||
@putenv('LINES='.$this->terminal->getHeight());
|
||||
@@ -276,7 +276,9 @@ class Application implements ResetInterface
|
||||
$alternative = $alternatives[0];
|
||||
|
||||
$style = new SymfonyStyle($input, $output);
|
||||
$style->block(sprintf("\nCommand \"%s\" is not defined.\n", $name), null, 'error');
|
||||
$output->writeln('');
|
||||
$formattedBlock = (new FormatterHelper())->formatBlock(sprintf('Command "%s" is not defined.', $name), 'error', true);
|
||||
$output->writeln($formattedBlock);
|
||||
if (!$style->confirm(sprintf('Do you want to run "%s" instead? ', $alternative), false)) {
|
||||
if (null !== $this->dispatcher) {
|
||||
$event = new ConsoleErrorEvent($input, $output, $e);
|
||||
@@ -316,16 +318,10 @@ class Application implements ResetInterface
|
||||
|
||||
/**
|
||||
* Get the helper set associated with the command.
|
||||
*
|
||||
* @return HelperSet
|
||||
*/
|
||||
public function getHelperSet()
|
||||
public function getHelperSet(): HelperSet
|
||||
{
|
||||
if (!$this->helperSet) {
|
||||
$this->helperSet = $this->getDefaultHelperSet();
|
||||
}
|
||||
|
||||
return $this->helperSet;
|
||||
return $this->helperSet ??= $this->getDefaultHelperSet();
|
||||
}
|
||||
|
||||
public function setDefinition(InputDefinition $definition)
|
||||
@@ -335,14 +331,10 @@ class Application implements ResetInterface
|
||||
|
||||
/**
|
||||
* Gets the InputDefinition related to this Application.
|
||||
*
|
||||
* @return InputDefinition
|
||||
*/
|
||||
public function getDefinition()
|
||||
public function getDefinition(): InputDefinition
|
||||
{
|
||||
if (!$this->definition) {
|
||||
$this->definition = $this->getDefaultInputDefinition();
|
||||
}
|
||||
$this->definition ??= $this->getDefaultInputDefinition();
|
||||
|
||||
if ($this->singleCommand) {
|
||||
$inputDefinition = $this->definition;
|
||||
@@ -388,20 +380,16 @@ class Application implements ResetInterface
|
||||
|
||||
/**
|
||||
* Gets the help message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHelp()
|
||||
public function getHelp(): string
|
||||
{
|
||||
return $this->getLongVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether to catch exceptions or not during commands execution.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function areExceptionsCaught()
|
||||
public function areExceptionsCaught(): bool
|
||||
{
|
||||
return $this->catchExceptions;
|
||||
}
|
||||
@@ -416,10 +404,8 @@ class Application implements ResetInterface
|
||||
|
||||
/**
|
||||
* Gets whether to automatically exit after a command execution or not.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isAutoExitEnabled()
|
||||
public function isAutoExitEnabled(): bool
|
||||
{
|
||||
return $this->autoExit;
|
||||
}
|
||||
@@ -434,10 +420,8 @@ class Application implements ResetInterface
|
||||
|
||||
/**
|
||||
* Gets the name of the application.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
@@ -452,10 +436,8 @@ class Application implements ResetInterface
|
||||
|
||||
/**
|
||||
* Gets the application version.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVersion()
|
||||
public function getVersion(): string
|
||||
{
|
||||
return $this->version;
|
||||
}
|
||||
@@ -488,10 +470,8 @@ class Application implements ResetInterface
|
||||
|
||||
/**
|
||||
* Registers a new command.
|
||||
*
|
||||
* @return Command
|
||||
*/
|
||||
public function register(string $name)
|
||||
public function register(string $name): Command
|
||||
{
|
||||
return $this->add(new Command($name));
|
||||
}
|
||||
@@ -584,10 +564,8 @@ class Application implements ResetInterface
|
||||
|
||||
/**
|
||||
* Returns true if the command exists, false otherwise.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has(string $name)
|
||||
public function has(string $name): bool
|
||||
{
|
||||
$this->init();
|
||||
|
||||
@@ -601,7 +579,7 @@ class Application implements ResetInterface
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getNamespaces()
|
||||
public function getNamespaces(): array
|
||||
{
|
||||
$namespaces = [];
|
||||
foreach ($this->all() as $command) {
|
||||
@@ -622,11 +600,9 @@ class Application implements ResetInterface
|
||||
/**
|
||||
* Finds a registered namespace by a name or an abbreviation.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws NamespaceNotFoundException When namespace is incorrect or ambiguous
|
||||
*/
|
||||
public function findNamespace(string $namespace)
|
||||
public function findNamespace(string $namespace): string
|
||||
{
|
||||
$allNamespaces = $this->getNamespaces();
|
||||
$expr = implode('[^:]*:', array_map('preg_quote', explode(':', $namespace))).'[^:]*';
|
||||
@@ -818,7 +794,7 @@ class Application implements ResetInterface
|
||||
*
|
||||
* @return string[][]
|
||||
*/
|
||||
public static function getAbbreviations(array $names)
|
||||
public static function getAbbreviations(array $names): array
|
||||
{
|
||||
$abbrevs = [];
|
||||
foreach ($names as $name) {
|
||||
@@ -933,11 +909,21 @@ class Application implements ResetInterface
|
||||
}
|
||||
|
||||
switch ($shellVerbosity = (int) getenv('SHELL_VERBOSITY')) {
|
||||
case -1: $output->setVerbosity(OutputInterface::VERBOSITY_QUIET); break;
|
||||
case 1: $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE); break;
|
||||
case 2: $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE); break;
|
||||
case 3: $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG); break;
|
||||
default: $shellVerbosity = 0; break;
|
||||
case -1:
|
||||
$output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
|
||||
break;
|
||||
case 1:
|
||||
$output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
|
||||
break;
|
||||
case 2:
|
||||
$output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
|
||||
break;
|
||||
case 3:
|
||||
$output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
|
||||
break;
|
||||
default:
|
||||
$shellVerbosity = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (true === $input->hasParameterOption(['--quiet', '-q'], true)) {
|
||||
@@ -983,22 +969,30 @@ class Application implements ResetInterface
|
||||
}
|
||||
}
|
||||
|
||||
if ($command instanceof SignalableCommandInterface && ($this->signalsToDispatchEvent || $command->getSubscribedSignals())) {
|
||||
if (!$this->signalRegistry) {
|
||||
throw new RuntimeException('Unable to subscribe to signal events. Make sure that the `pcntl` extension is installed and that "pcntl_*" functions are not disabled by your php.ini\'s "disable_functions" directive.');
|
||||
}
|
||||
if ($this->signalsToDispatchEvent) {
|
||||
$commandSignals = $command instanceof SignalableCommandInterface ? $command->getSubscribedSignals() : [];
|
||||
|
||||
if (Terminal::hasSttyAvailable()) {
|
||||
$sttyMode = shell_exec('stty -g');
|
||||
if ($commandSignals || null !== $this->dispatcher) {
|
||||
if (!$this->signalRegistry) {
|
||||
throw new RuntimeException('Unable to subscribe to signal events. Make sure that the `pcntl` extension is installed and that "pcntl_*" functions are not disabled by your php.ini\'s "disable_functions" directive.');
|
||||
}
|
||||
|
||||
foreach ([\SIGINT, \SIGTERM] as $signal) {
|
||||
$this->signalRegistry->register($signal, static function () use ($sttyMode) {
|
||||
shell_exec('stty '.$sttyMode);
|
||||
});
|
||||
if (Terminal::hasSttyAvailable()) {
|
||||
$sttyMode = shell_exec('stty -g');
|
||||
|
||||
foreach ([\SIGINT, \SIGTERM] as $signal) {
|
||||
$this->signalRegistry->register($signal, static function () use ($sttyMode) {
|
||||
shell_exec('stty '.$sttyMode);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($commandSignals as $signal) {
|
||||
$this->signalRegistry->register($signal, [$command, 'handleSignal']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->dispatcher) {
|
||||
if (null !== $this->dispatcher) {
|
||||
foreach ($this->signalsToDispatchEvent as $signal) {
|
||||
$event = new ConsoleSignalEvent($command, $input, $output, $signal);
|
||||
|
||||
@@ -1014,10 +1008,6 @@ class Application implements ResetInterface
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($command->getSubscribedSignals() as $signal) {
|
||||
$this->signalRegistry->register($signal, [$command, 'handleSignal']);
|
||||
}
|
||||
}
|
||||
|
||||
if (null === $this->dispatcher) {
|
||||
@@ -1065,20 +1055,16 @@ class Application implements ResetInterface
|
||||
|
||||
/**
|
||||
* Gets the name of the command based on input.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getCommandName(InputInterface $input)
|
||||
protected function getCommandName(InputInterface $input): ?string
|
||||
{
|
||||
return $this->singleCommand ? $this->defaultCommand : $input->getFirstArgument();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the default input definition.
|
||||
*
|
||||
* @return InputDefinition
|
||||
*/
|
||||
protected function getDefaultInputDefinition()
|
||||
protected function getDefaultInputDefinition(): InputDefinition
|
||||
{
|
||||
return new InputDefinition([
|
||||
new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'),
|
||||
@@ -1096,17 +1082,15 @@ class Application implements ResetInterface
|
||||
*
|
||||
* @return Command[]
|
||||
*/
|
||||
protected function getDefaultCommands()
|
||||
protected function getDefaultCommands(): array
|
||||
{
|
||||
return [new HelpCommand(), new ListCommand(), new CompleteCommand(), new DumpCompletionCommand()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the default helper set with the helpers that should always be available.
|
||||
*
|
||||
* @return HelperSet
|
||||
*/
|
||||
protected function getDefaultHelperSet()
|
||||
protected function getDefaultHelperSet(): HelperSet
|
||||
{
|
||||
return new HelperSet([
|
||||
new FormatterHelper(),
|
||||
@@ -1128,10 +1112,8 @@ class Application implements ResetInterface
|
||||
* Returns the namespace part of the command name.
|
||||
*
|
||||
* This method is not part of public API and should not be used directly.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function extractNamespace(string $name, int $limit = null)
|
||||
public function extractNamespace(string $name, int $limit = null): string
|
||||
{
|
||||
$parts = explode(':', $name, -1);
|
||||
|
||||
@@ -1191,7 +1173,7 @@ class Application implements ResetInterface
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDefaultCommand(string $commandName, bool $isSingleCommand = false)
|
||||
public function setDefaultCommand(string $commandName, bool $isSingleCommand = false): static
|
||||
{
|
||||
$this->defaultCommand = explode('|', ltrim($commandName, '|'))[0];
|
||||
|
||||
|
||||
9
vendor/symfony/console/CHANGELOG.md
vendored
9
vendor/symfony/console/CHANGELOG.md
vendored
@@ -1,6 +1,15 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
6.0
|
||||
---
|
||||
|
||||
* `Command::setHidden()` has a default value (`true`) for `$hidden` parameter and is final
|
||||
* Remove `Helper::strlen()`, use `Helper::width()` instead
|
||||
* Remove `Helper::strlenWithoutDecoration()`, use `Helper::removeDecoration()` instead
|
||||
* `AddConsoleCommandPass` can not be configured anymore
|
||||
* Remove `HelperSet::setCommand()` and `getCommand()` without replacement
|
||||
|
||||
5.4
|
||||
---
|
||||
|
||||
|
||||
6
vendor/symfony/console/Color.php
vendored
6
vendor/symfony/console/Color.php
vendored
@@ -49,9 +49,9 @@ final class Color
|
||||
'conceal' => ['set' => 8, 'unset' => 28],
|
||||
];
|
||||
|
||||
private $foreground;
|
||||
private $background;
|
||||
private $options = [];
|
||||
private string $foreground;
|
||||
private string $background;
|
||||
private array $options = [];
|
||||
|
||||
public function __construct(string $foreground = '', string $background = '', array $options = [])
|
||||
{
|
||||
|
||||
128
vendor/symfony/console/Command/Command.php
vendored
128
vendor/symfony/console/Command/Command.php
vendored
@@ -47,29 +47,26 @@ class Command
|
||||
*/
|
||||
protected static $defaultDescription;
|
||||
|
||||
private $application;
|
||||
private $name;
|
||||
private $processTitle;
|
||||
private $aliases = [];
|
||||
private $application = null;
|
||||
private ?string $name = null;
|
||||
private ?string $processTitle = null;
|
||||
private array $aliases = [];
|
||||
private $definition;
|
||||
private $hidden = false;
|
||||
private $help = '';
|
||||
private $description = '';
|
||||
private $fullDefinition;
|
||||
private $ignoreValidationErrors = false;
|
||||
private $code;
|
||||
private $synopsis = [];
|
||||
private $usages = [];
|
||||
private $helperSet;
|
||||
private bool $hidden = false;
|
||||
private string $help = '';
|
||||
private string $description = '';
|
||||
private $fullDefinition = null;
|
||||
private bool $ignoreValidationErrors = false;
|
||||
private ?\Closure $code = null;
|
||||
private array $synopsis = [];
|
||||
private array $usages = [];
|
||||
private $helperSet = null;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public static function getDefaultName()
|
||||
public static function getDefaultName(): ?string
|
||||
{
|
||||
$class = static::class;
|
||||
|
||||
if (\PHP_VERSION_ID >= 80000 && $attribute = (new \ReflectionClass($class))->getAttributes(AsCommand::class)) {
|
||||
if ($attribute = (new \ReflectionClass($class))->getAttributes(AsCommand::class)) {
|
||||
return $attribute[0]->newInstance()->name;
|
||||
}
|
||||
|
||||
@@ -82,7 +79,7 @@ class Command
|
||||
{
|
||||
$class = static::class;
|
||||
|
||||
if (\PHP_VERSION_ID >= 80000 && $attribute = (new \ReflectionClass($class))->getAttributes(AsCommand::class)) {
|
||||
if ($attribute = (new \ReflectionClass($class))->getAttributes(AsCommand::class)) {
|
||||
return $attribute[0]->newInstance()->description;
|
||||
}
|
||||
|
||||
@@ -151,20 +148,16 @@ class Command
|
||||
|
||||
/**
|
||||
* Gets the helper set.
|
||||
*
|
||||
* @return HelperSet|null
|
||||
*/
|
||||
public function getHelperSet()
|
||||
public function getHelperSet(): ?HelperSet
|
||||
{
|
||||
return $this->helperSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the application instance for this command.
|
||||
*
|
||||
* @return Application|null
|
||||
*/
|
||||
public function getApplication()
|
||||
public function getApplication(): ?Application
|
||||
{
|
||||
return $this->application;
|
||||
}
|
||||
@@ -247,7 +240,7 @@ class Command
|
||||
* @see setCode()
|
||||
* @see execute()
|
||||
*/
|
||||
public function run(InputInterface $input, OutputInterface $output)
|
||||
public function run(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
// add the application arguments and options
|
||||
$this->mergeApplicationDefinition();
|
||||
@@ -326,7 +319,7 @@ class Command
|
||||
*
|
||||
* @see execute()
|
||||
*/
|
||||
public function setCode(callable $code)
|
||||
public function setCode(callable $code): static
|
||||
{
|
||||
if ($code instanceof \Closure) {
|
||||
$r = new \ReflectionFunction($code);
|
||||
@@ -340,6 +333,8 @@ class Command
|
||||
restore_error_handler();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$code = \Closure::fromCallable($code);
|
||||
}
|
||||
|
||||
$this->code = $code;
|
||||
@@ -377,11 +372,9 @@ class Command
|
||||
/**
|
||||
* Sets an array of argument and option instances.
|
||||
*
|
||||
* @param array|InputDefinition $definition An array of argument and option instances or a definition instance
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDefinition($definition)
|
||||
public function setDefinition(array|InputDefinition $definition): static
|
||||
{
|
||||
if ($definition instanceof InputDefinition) {
|
||||
$this->definition = $definition;
|
||||
@@ -396,10 +389,8 @@ class Command
|
||||
|
||||
/**
|
||||
* Gets the InputDefinition attached to this Command.
|
||||
*
|
||||
* @return InputDefinition
|
||||
*/
|
||||
public function getDefinition()
|
||||
public function getDefinition(): InputDefinition
|
||||
{
|
||||
return $this->fullDefinition ?? $this->getNativeDefinition();
|
||||
}
|
||||
@@ -411,16 +402,10 @@ class Command
|
||||
* be changed by merging with the application InputDefinition.
|
||||
*
|
||||
* This method is not part of public API and should not be used directly.
|
||||
*
|
||||
* @return InputDefinition
|
||||
*/
|
||||
public function getNativeDefinition()
|
||||
public function getNativeDefinition(): InputDefinition
|
||||
{
|
||||
if (null === $this->definition) {
|
||||
throw new LogicException(sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', static::class));
|
||||
}
|
||||
|
||||
return $this->definition;
|
||||
return $this->definition ?? throw new LogicException(sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', static::class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -433,7 +418,7 @@ class Command
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addArgument(string $name, int $mode = null, string $description = '', $default = null)
|
||||
public function addArgument(string $name, int $mode = null, string $description = '', mixed $default = null): static
|
||||
{
|
||||
$this->definition->addArgument(new InputArgument($name, $mode, $description, $default));
|
||||
if (null !== $this->fullDefinition) {
|
||||
@@ -446,15 +431,15 @@ class Command
|
||||
/**
|
||||
* Adds an option.
|
||||
*
|
||||
* @param string|array|null $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
|
||||
* @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)
|
||||
* @param $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
|
||||
* @param $mode The option mode: One of the InputOption::VALUE_* constants
|
||||
* @param $default The default value (must be null for InputOption::VALUE_NONE)
|
||||
*
|
||||
* @throws InvalidArgumentException If option mode is invalid or incompatible
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addOption(string $name, $shortcut = null, int $mode = null, string $description = '', $default = null)
|
||||
public function addOption(string $name, string|array $shortcut = null, int $mode = null, string $description = '', mixed $default = null): static
|
||||
{
|
||||
$this->definition->addOption(new InputOption($name, $shortcut, $mode, $description, $default));
|
||||
if (null !== $this->fullDefinition) {
|
||||
@@ -476,7 +461,7 @@ class Command
|
||||
*
|
||||
* @throws InvalidArgumentException When the name is invalid
|
||||
*/
|
||||
public function setName(string $name)
|
||||
public function setName(string $name): static
|
||||
{
|
||||
$this->validateName($name);
|
||||
|
||||
@@ -493,7 +478,7 @@ class Command
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setProcessTitle(string $title)
|
||||
public function setProcessTitle(string $title): static
|
||||
{
|
||||
$this->processTitle = $title;
|
||||
|
||||
@@ -502,23 +487,18 @@ class Command
|
||||
|
||||
/**
|
||||
* Returns the command name.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getName()
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $hidden Whether or not the command should be hidden from the list of commands
|
||||
* The default value will be true in Symfony 6.0
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @final since Symfony 5.1
|
||||
*/
|
||||
public function setHidden(bool $hidden /* = true */)
|
||||
public function setHidden(bool $hidden = true): static
|
||||
{
|
||||
$this->hidden = $hidden;
|
||||
|
||||
@@ -528,7 +508,7 @@ class Command
|
||||
/**
|
||||
* @return bool whether the command should be publicly shown or not
|
||||
*/
|
||||
public function isHidden()
|
||||
public function isHidden(): bool
|
||||
{
|
||||
return $this->hidden;
|
||||
}
|
||||
@@ -538,7 +518,7 @@ class Command
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDescription(string $description)
|
||||
public function setDescription(string $description): static
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
@@ -547,10 +527,8 @@ class Command
|
||||
|
||||
/**
|
||||
* Returns the description for the command.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription()
|
||||
public function getDescription(): string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
@@ -560,7 +538,7 @@ class Command
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setHelp(string $help)
|
||||
public function setHelp(string $help): static
|
||||
{
|
||||
$this->help = $help;
|
||||
|
||||
@@ -569,10 +547,8 @@ class Command
|
||||
|
||||
/**
|
||||
* Returns the help for the command.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHelp()
|
||||
public function getHelp(): string
|
||||
{
|
||||
return $this->help;
|
||||
}
|
||||
@@ -580,10 +556,8 @@ class Command
|
||||
/**
|
||||
* Returns the processed help for the command replacing the %command.name% and
|
||||
* %command.full_name% patterns with the real values dynamically.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getProcessedHelp()
|
||||
public function getProcessedHelp(): string
|
||||
{
|
||||
$name = $this->name;
|
||||
$isSingleCommand = $this->application && $this->application->isSingleCommand();
|
||||
@@ -609,7 +583,7 @@ class Command
|
||||
*
|
||||
* @throws InvalidArgumentException When an alias is invalid
|
||||
*/
|
||||
public function setAliases(iterable $aliases)
|
||||
public function setAliases(iterable $aliases): static
|
||||
{
|
||||
$list = [];
|
||||
|
||||
@@ -625,10 +599,8 @@ class Command
|
||||
|
||||
/**
|
||||
* Returns the aliases for the command.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAliases()
|
||||
public function getAliases(): array
|
||||
{
|
||||
return $this->aliases;
|
||||
}
|
||||
@@ -637,10 +609,8 @@ class Command
|
||||
* Returns the synopsis for the command.
|
||||
*
|
||||
* @param bool $short Whether to show the short version of the synopsis (with options folded) or not
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSynopsis(bool $short = false)
|
||||
public function getSynopsis(bool $short = false): string
|
||||
{
|
||||
$key = $short ? 'short' : 'long';
|
||||
|
||||
@@ -656,7 +626,7 @@ class Command
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addUsage(string $usage)
|
||||
public function addUsage(string $usage): static
|
||||
{
|
||||
if (!str_starts_with($usage, $this->name)) {
|
||||
$usage = sprintf('%s %s', $this->name, $usage);
|
||||
@@ -669,10 +639,8 @@ class Command
|
||||
|
||||
/**
|
||||
* Returns alternative usages of the command.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getUsages()
|
||||
public function getUsages(): array
|
||||
{
|
||||
return $this->usages;
|
||||
}
|
||||
@@ -680,12 +648,10 @@ class Command
|
||||
/**
|
||||
* Gets a helper instance by name.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws LogicException if no HelperSet is defined
|
||||
* @throws InvalidArgumentException if the helper is not defined
|
||||
*/
|
||||
public function getHelper(string $name)
|
||||
public function getHelper(string $name): mixed
|
||||
{
|
||||
if (null === $this->helperSet) {
|
||||
throw new LogicException(sprintf('Cannot retrieve helper "%s" because there is no HelperSet defined. Did you forget to add your command to the application or to set the application on the command using the setApplication() method? You can also set the HelperSet directly using the setHelperSet() method.', $name));
|
||||
|
||||
@@ -67,11 +67,9 @@ EOF
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
if (null === $this->command) {
|
||||
$this->command = $this->getApplication()->find($input->getArgument('command_name'));
|
||||
}
|
||||
$this->command ??= $this->getApplication()->find($input->getArgument('command_name'));
|
||||
|
||||
$helper = new DescriptorHelper();
|
||||
$helper->describe($output, $this->command, [
|
||||
@@ -79,7 +77,7 @@ EOF
|
||||
'raw_text' => $input->getOption('raw'),
|
||||
]);
|
||||
|
||||
$this->command = null;
|
||||
unset($this->command);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
42
vendor/symfony/console/Command/LazyCommand.php
vendored
42
vendor/symfony/console/Command/LazyCommand.php
vendored
@@ -25,7 +25,7 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
final class LazyCommand extends Command
|
||||
{
|
||||
private $command;
|
||||
private $isEnabled;
|
||||
private ?bool $isEnabled;
|
||||
|
||||
public function __construct(string $name, array $aliases, string $description, bool $isHidden, \Closure $commandFactory, ?bool $isEnabled = true)
|
||||
{
|
||||
@@ -76,10 +76,7 @@ final class LazyCommand extends Command
|
||||
$this->getCommand()->complete($input, $suggestions);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setCode(callable $code): self
|
||||
public function setCode(callable $code): static
|
||||
{
|
||||
$this->getCommand()->setCode($code);
|
||||
|
||||
@@ -94,10 +91,7 @@ final class LazyCommand extends Command
|
||||
$this->getCommand()->mergeApplicationDefinition($mergeArgs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setDefinition($definition): self
|
||||
public function setDefinition(array|InputDefinition $definition): static
|
||||
{
|
||||
$this->getCommand()->setDefinition($definition);
|
||||
|
||||
@@ -114,40 +108,28 @@ final class LazyCommand extends Command
|
||||
return $this->getCommand()->getNativeDefinition();
|
||||
}
|
||||
|
||||
/**
|
||||
* @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 = '', mixed $default = null): static
|
||||
{
|
||||
$this->getCommand()->addArgument($name, $mode, $description, $default);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function addOption(string $name, $shortcut = null, int $mode = null, string $description = '', $default = null): self
|
||||
public function addOption(string $name, string|array $shortcut = null, int $mode = null, string $description = '', mixed $default = null): static
|
||||
{
|
||||
$this->getCommand()->addOption($name, $shortcut, $mode, $description, $default);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setProcessTitle(string $title): self
|
||||
public function setProcessTitle(string $title): static
|
||||
{
|
||||
$this->getCommand()->setProcessTitle($title);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setHelp(string $help): self
|
||||
public function setHelp(string $help): static
|
||||
{
|
||||
$this->getCommand()->setHelp($help);
|
||||
|
||||
@@ -169,10 +151,7 @@ final class LazyCommand extends Command
|
||||
return $this->getCommand()->getSynopsis($short);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function addUsage(string $usage): self
|
||||
public function addUsage(string $usage): static
|
||||
{
|
||||
$this->getCommand()->addUsage($usage);
|
||||
|
||||
@@ -184,10 +163,7 @@ final class LazyCommand extends Command
|
||||
return $this->getCommand()->getUsages();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getHelper(string $name)
|
||||
public function getHelper(string $name): mixed
|
||||
{
|
||||
return $this->getCommand()->getHelper($name);
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ EOF
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$helper = new DescriptorHelper();
|
||||
$helper->describe($output, $this->getApplication(), [
|
||||
|
||||
@@ -13,7 +13,6 @@ namespace Symfony\Component\Console\Command;
|
||||
|
||||
use Symfony\Component\Console\Exception\LogicException;
|
||||
use Symfony\Component\Lock\LockFactory;
|
||||
use Symfony\Component\Lock\LockInterface;
|
||||
use Symfony\Component\Lock\Store\FlockStore;
|
||||
use Symfony\Component\Lock\Store\SemaphoreStore;
|
||||
|
||||
@@ -24,8 +23,7 @@ use Symfony\Component\Lock\Store\SemaphoreStore;
|
||||
*/
|
||||
trait LockableTrait
|
||||
{
|
||||
/** @var LockInterface|null */
|
||||
private $lock;
|
||||
private $lock = null;
|
||||
|
||||
/**
|
||||
* Locks a command.
|
||||
|
||||
@@ -22,21 +22,17 @@ interface CommandLoaderInterface
|
||||
/**
|
||||
* Loads a command.
|
||||
*
|
||||
* @return Command
|
||||
*
|
||||
* @throws CommandNotFoundException
|
||||
*/
|
||||
public function get(string $name);
|
||||
public function get(string $name): Command;
|
||||
|
||||
/**
|
||||
* Checks if a command exists.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has(string $name);
|
||||
public function has(string $name): bool;
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getNames();
|
||||
public function getNames(): array;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Console\CommandLoader;
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Exception\CommandNotFoundException;
|
||||
|
||||
/**
|
||||
@@ -22,7 +23,7 @@ use Symfony\Component\Console\Exception\CommandNotFoundException;
|
||||
class ContainerCommandLoader implements CommandLoaderInterface
|
||||
{
|
||||
private $container;
|
||||
private $commandMap;
|
||||
private array $commandMap;
|
||||
|
||||
/**
|
||||
* @param array $commandMap An array with command names as keys and service ids as values
|
||||
@@ -36,7 +37,7 @@ class ContainerCommandLoader implements CommandLoaderInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get(string $name)
|
||||
public function get(string $name): Command
|
||||
{
|
||||
if (!$this->has($name)) {
|
||||
throw new CommandNotFoundException(sprintf('Command "%s" does not exist.', $name));
|
||||
@@ -48,7 +49,7 @@ class ContainerCommandLoader implements CommandLoaderInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function has(string $name)
|
||||
public function has(string $name): bool
|
||||
{
|
||||
return isset($this->commandMap[$name]) && $this->container->has($this->commandMap[$name]);
|
||||
}
|
||||
@@ -56,7 +57,7 @@ class ContainerCommandLoader implements CommandLoaderInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getNames()
|
||||
public function getNames(): array
|
||||
{
|
||||
return array_keys($this->commandMap);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Console\CommandLoader;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Exception\CommandNotFoundException;
|
||||
|
||||
/**
|
||||
@@ -20,7 +21,7 @@ use Symfony\Component\Console\Exception\CommandNotFoundException;
|
||||
*/
|
||||
class FactoryCommandLoader implements CommandLoaderInterface
|
||||
{
|
||||
private $factories;
|
||||
private array $factories;
|
||||
|
||||
/**
|
||||
* @param callable[] $factories Indexed by command names
|
||||
@@ -33,7 +34,7 @@ class FactoryCommandLoader implements CommandLoaderInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function has(string $name)
|
||||
public function has(string $name): bool
|
||||
{
|
||||
return isset($this->factories[$name]);
|
||||
}
|
||||
@@ -41,7 +42,7 @@ class FactoryCommandLoader implements CommandLoaderInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get(string $name)
|
||||
public function get(string $name): Command
|
||||
{
|
||||
if (!isset($this->factories[$name])) {
|
||||
throw new CommandNotFoundException(sprintf('Command "%s" does not exist.', $name));
|
||||
@@ -55,7 +56,7 @@ class FactoryCommandLoader implements CommandLoaderInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getNames()
|
||||
public function getNames(): array
|
||||
{
|
||||
return array_keys($this->factories);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Symfony\Component\Console\Completion;
|
||||
*/
|
||||
class Suggestion
|
||||
{
|
||||
private $value;
|
||||
private string $value;
|
||||
|
||||
public function __construct(string $value)
|
||||
{
|
||||
|
||||
26
vendor/symfony/console/Cursor.php
vendored
26
vendor/symfony/console/Cursor.php
vendored
@@ -33,7 +33,7 @@ final class Cursor
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function moveUp(int $lines = 1): self
|
||||
public function moveUp(int $lines = 1): static
|
||||
{
|
||||
$this->output->write(sprintf("\x1b[%dA", $lines));
|
||||
|
||||
@@ -43,7 +43,7 @@ final class Cursor
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function moveDown(int $lines = 1): self
|
||||
public function moveDown(int $lines = 1): static
|
||||
{
|
||||
$this->output->write(sprintf("\x1b[%dB", $lines));
|
||||
|
||||
@@ -53,7 +53,7 @@ final class Cursor
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function moveRight(int $columns = 1): self
|
||||
public function moveRight(int $columns = 1): static
|
||||
{
|
||||
$this->output->write(sprintf("\x1b[%dC", $columns));
|
||||
|
||||
@@ -63,7 +63,7 @@ final class Cursor
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function moveLeft(int $columns = 1): self
|
||||
public function moveLeft(int $columns = 1): static
|
||||
{
|
||||
$this->output->write(sprintf("\x1b[%dD", $columns));
|
||||
|
||||
@@ -73,7 +73,7 @@ final class Cursor
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function moveToColumn(int $column): self
|
||||
public function moveToColumn(int $column): static
|
||||
{
|
||||
$this->output->write(sprintf("\x1b[%dG", $column));
|
||||
|
||||
@@ -83,7 +83,7 @@ final class Cursor
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function moveToPosition(int $column, int $row): self
|
||||
public function moveToPosition(int $column, int $row): static
|
||||
{
|
||||
$this->output->write(sprintf("\x1b[%d;%dH", $row + 1, $column));
|
||||
|
||||
@@ -93,7 +93,7 @@ final class Cursor
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function savePosition(): self
|
||||
public function savePosition(): static
|
||||
{
|
||||
$this->output->write("\x1b7");
|
||||
|
||||
@@ -103,7 +103,7 @@ final class Cursor
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function restorePosition(): self
|
||||
public function restorePosition(): static
|
||||
{
|
||||
$this->output->write("\x1b8");
|
||||
|
||||
@@ -113,7 +113,7 @@ final class Cursor
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function hide(): self
|
||||
public function hide(): static
|
||||
{
|
||||
$this->output->write("\x1b[?25l");
|
||||
|
||||
@@ -123,7 +123,7 @@ final class Cursor
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function show(): self
|
||||
public function show(): static
|
||||
{
|
||||
$this->output->write("\x1b[?25h\x1b[?0c");
|
||||
|
||||
@@ -135,7 +135,7 @@ final class Cursor
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function clearLine(): self
|
||||
public function clearLine(): static
|
||||
{
|
||||
$this->output->write("\x1b[2K");
|
||||
|
||||
@@ -157,7 +157,7 @@ final class Cursor
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function clearOutput(): self
|
||||
public function clearOutput(): static
|
||||
{
|
||||
$this->output->write("\x1b[0J");
|
||||
|
||||
@@ -169,7 +169,7 @@ final class Cursor
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function clearScreen(): self
|
||||
public function clearScreen(): static
|
||||
{
|
||||
$this->output->write("\x1b[2J");
|
||||
|
||||
|
||||
@@ -29,33 +29,16 @@ use Symfony\Component\DependencyInjection\TypedReference;
|
||||
*/
|
||||
class AddConsoleCommandPass implements CompilerPassInterface
|
||||
{
|
||||
private $commandLoaderServiceId;
|
||||
private $commandTag;
|
||||
private $noPreloadTag;
|
||||
private $privateTagName;
|
||||
|
||||
public function __construct(string $commandLoaderServiceId = 'console.command_loader', string $commandTag = 'console.command', string $noPreloadTag = 'container.no_preload', string $privateTagName = 'container.private')
|
||||
{
|
||||
if (0 < \func_num_args()) {
|
||||
trigger_deprecation('symfony/console', '5.3', 'Configuring "%s" is deprecated.', __CLASS__);
|
||||
}
|
||||
|
||||
$this->commandLoaderServiceId = $commandLoaderServiceId;
|
||||
$this->commandTag = $commandTag;
|
||||
$this->noPreloadTag = $noPreloadTag;
|
||||
$this->privateTagName = $privateTagName;
|
||||
}
|
||||
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
$commandServices = $container->findTaggedServiceIds($this->commandTag, true);
|
||||
$commandServices = $container->findTaggedServiceIds('console.command', true);
|
||||
$lazyCommandMap = [];
|
||||
$lazyCommandRefs = [];
|
||||
$serviceIds = [];
|
||||
|
||||
foreach ($commandServices as $id => $tags) {
|
||||
$definition = $container->getDefinition($id);
|
||||
$definition->addTag($this->noPreloadTag);
|
||||
$definition->addTag('container.no_preload');
|
||||
$class = $container->getParameterBag()->resolveValue($definition->getClass());
|
||||
|
||||
if (isset($tags[0]['command'])) {
|
||||
@@ -65,7 +48,7 @@ class AddConsoleCommandPass implements CompilerPassInterface
|
||||
throw new InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id));
|
||||
}
|
||||
if (!$r->isSubclassOf(Command::class)) {
|
||||
throw new InvalidArgumentException(sprintf('The service "%s" tagged "%s" must be a subclass of "%s".', $id, $this->commandTag, Command::class));
|
||||
throw new InvalidArgumentException(sprintf('The service "%s" tagged "%s" must be a subclass of "%s".', $id, 'console.command', Command::class));
|
||||
}
|
||||
$aliases = str_replace('%', '%%', $class::getDefaultName() ?? '');
|
||||
}
|
||||
@@ -78,7 +61,7 @@ class AddConsoleCommandPass implements CompilerPassInterface
|
||||
}
|
||||
|
||||
if (null === $commandName) {
|
||||
if (!$definition->isPublic() || $definition->isPrivate() || $definition->hasTag($this->privateTagName)) {
|
||||
if (!$definition->isPublic() || $definition->isPrivate() || $definition->hasTag('container.private')) {
|
||||
$commandId = 'console.command.public_alias.'.$id;
|
||||
$container->setAlias($commandId, $id)->setPublic(true);
|
||||
$id = $commandId;
|
||||
@@ -122,7 +105,7 @@ class AddConsoleCommandPass implements CompilerPassInterface
|
||||
throw new InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id));
|
||||
}
|
||||
if (!$r->isSubclassOf(Command::class)) {
|
||||
throw new InvalidArgumentException(sprintf('The service "%s" tagged "%s" must be a subclass of "%s".', $id, $this->commandTag, Command::class));
|
||||
throw new InvalidArgumentException(sprintf('The service "%s" tagged "%s" must be a subclass of "%s".', $id, 'console.command', Command::class));
|
||||
}
|
||||
$description = str_replace('%', '%%', $class::getDefaultDescription() ?? '');
|
||||
}
|
||||
@@ -138,9 +121,9 @@ class AddConsoleCommandPass implements CompilerPassInterface
|
||||
}
|
||||
|
||||
$container
|
||||
->register($this->commandLoaderServiceId, ContainerCommandLoader::class)
|
||||
->register('console.command_loader', ContainerCommandLoader::class)
|
||||
->setPublic(true)
|
||||
->addTag($this->noPreloadTag)
|
||||
->addTag('container.no_preload')
|
||||
->setArguments([ServiceLocatorTagPass::register($container, $lazyCommandRefs), $lazyCommandMap]);
|
||||
|
||||
$container->setParameter('console.command.ids', $serviceIds);
|
||||
|
||||
@@ -25,23 +25,19 @@ class ApplicationDescription
|
||||
public const GLOBAL_NAMESPACE = '_global';
|
||||
|
||||
private $application;
|
||||
private $namespace;
|
||||
private $showHidden;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $namespaces;
|
||||
private ?string $namespace;
|
||||
private bool $showHidden;
|
||||
private array $namespaces;
|
||||
|
||||
/**
|
||||
* @var array<string, Command>
|
||||
*/
|
||||
private $commands;
|
||||
private array $commands;
|
||||
|
||||
/**
|
||||
* @var array<string, Command>
|
||||
*/
|
||||
private $aliases;
|
||||
private array $aliases = [];
|
||||
|
||||
public function __construct(Application $application, string $namespace = null, bool $showHidden = false)
|
||||
{
|
||||
@@ -52,7 +48,7 @@ class ApplicationDescription
|
||||
|
||||
public function getNamespaces(): array
|
||||
{
|
||||
if (null === $this->namespaces) {
|
||||
if (!isset($this->namespaces)) {
|
||||
$this->inspectApplication();
|
||||
}
|
||||
|
||||
@@ -64,7 +60,7 @@ class ApplicationDescription
|
||||
*/
|
||||
public function getCommands(): array
|
||||
{
|
||||
if (null === $this->commands) {
|
||||
if (!isset($this->commands)) {
|
||||
$this->inspectApplication();
|
||||
}
|
||||
|
||||
@@ -131,7 +127,7 @@ class ApplicationDescription
|
||||
}
|
||||
|
||||
if ($namespacedCommands) {
|
||||
ksort($namespacedCommands);
|
||||
ksort($namespacedCommands, \SORT_STRING);
|
||||
foreach ($namespacedCommands as $key => $commandsSet) {
|
||||
ksort($commandsSet);
|
||||
$sortedCommands[$key] = $commandsSet;
|
||||
|
||||
@@ -273,10 +273,8 @@ class TextDescriptor extends Descriptor
|
||||
|
||||
/**
|
||||
* Formats input option/argument default value.
|
||||
*
|
||||
* @param mixed $default
|
||||
*/
|
||||
private function formatDefaultValue($default): string
|
||||
private function formatDefaultValue(mixed $default): string
|
||||
{
|
||||
if (\INF === $default) {
|
||||
return 'INF';
|
||||
|
||||
@@ -26,7 +26,7 @@ final class ConsoleCommandEvent extends ConsoleEvent
|
||||
/**
|
||||
* Indicates if the command should be run or skipped.
|
||||
*/
|
||||
private $commandShouldRun = true;
|
||||
private bool $commandShouldRun = true;
|
||||
|
||||
/**
|
||||
* Disables the command, so it won't be run.
|
||||
|
||||
@@ -22,8 +22,8 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
*/
|
||||
final class ConsoleErrorEvent extends ConsoleEvent
|
||||
{
|
||||
private $error;
|
||||
private $exitCode;
|
||||
private \Throwable $error;
|
||||
private int $exitCode;
|
||||
|
||||
public function __construct(InputInterface $input, OutputInterface $output, \Throwable $error, Command $command = null)
|
||||
{
|
||||
|
||||
12
vendor/symfony/console/Event/ConsoleEvent.php
vendored
12
vendor/symfony/console/Event/ConsoleEvent.php
vendored
@@ -37,30 +37,24 @@ class ConsoleEvent extends Event
|
||||
|
||||
/**
|
||||
* Gets the command that is executed.
|
||||
*
|
||||
* @return Command|null
|
||||
*/
|
||||
public function getCommand()
|
||||
public function getCommand(): ?Command
|
||||
{
|
||||
return $this->command;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the input instance.
|
||||
*
|
||||
* @return InputInterface
|
||||
*/
|
||||
public function getInput()
|
||||
public function getInput(): InputInterface
|
||||
{
|
||||
return $this->input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the output instance.
|
||||
*
|
||||
* @return OutputInterface
|
||||
*/
|
||||
public function getOutput()
|
||||
public function getOutput(): OutputInterface
|
||||
{
|
||||
return $this->output;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
*/
|
||||
final class ConsoleSignalEvent extends ConsoleEvent
|
||||
{
|
||||
private $handlingSignal;
|
||||
private int $handlingSignal;
|
||||
|
||||
public function __construct(Command $command, InputInterface $input, OutputInterface $output, int $handlingSignal)
|
||||
{
|
||||
|
||||
@@ -22,7 +22,7 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
*/
|
||||
final class ConsoleTerminateEvent extends ConsoleEvent
|
||||
{
|
||||
private $exitCode;
|
||||
private int $exitCode;
|
||||
|
||||
public function __construct(Command $command, InputInterface $input, OutputInterface $output, int $exitCode)
|
||||
{
|
||||
|
||||
@@ -69,7 +69,7 @@ class ErrorListener implements EventSubscriberInterface
|
||||
$this->logger->debug('Command "{command}" exited with code "{code}"', ['command' => $inputString, 'code' => $exitCode]);
|
||||
}
|
||||
|
||||
public static function getSubscribedEvents()
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
return [
|
||||
ConsoleEvents::ERROR => ['onConsoleError', -128],
|
||||
@@ -82,7 +82,7 @@ class ErrorListener implements EventSubscriberInterface
|
||||
$commandName = $event->getCommand() ? $event->getCommand()->getName() : null;
|
||||
$input = $event->getInput();
|
||||
|
||||
if (method_exists($input, '__toString')) {
|
||||
if ($input instanceof \Stringable) {
|
||||
if ($commandName) {
|
||||
return str_replace(["'$commandName'", "\"$commandName\""], $commandName, (string) $input);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Symfony\Component\Console\Exception;
|
||||
*/
|
||||
class CommandNotFoundException extends \InvalidArgumentException implements ExceptionInterface
|
||||
{
|
||||
private $alternatives;
|
||||
private array $alternatives;
|
||||
|
||||
/**
|
||||
* @param string $message Exception message to throw
|
||||
@@ -36,7 +36,7 @@ class CommandNotFoundException extends \InvalidArgumentException implements Exce
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getAlternatives()
|
||||
public function getAlternatives(): array
|
||||
{
|
||||
return $this->alternatives;
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||
*/
|
||||
class OutputFormatter implements WrappableOutputFormatterInterface
|
||||
{
|
||||
private $decorated;
|
||||
private $styles = [];
|
||||
private bool $decorated;
|
||||
private array $styles = [];
|
||||
private $styleStack;
|
||||
|
||||
public function __clone()
|
||||
@@ -35,10 +35,8 @@ class OutputFormatter implements WrappableOutputFormatterInterface
|
||||
|
||||
/**
|
||||
* Escapes "<" and ">" special chars in given text.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function escape(string $text)
|
||||
public static function escape(string $text): string
|
||||
{
|
||||
$text = preg_replace('/([^\\\\]|^)([<>])/', '$1\\\\$2', $text);
|
||||
|
||||
@@ -94,7 +92,7 @@ class OutputFormatter implements WrappableOutputFormatterInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isDecorated()
|
||||
public function isDecorated(): bool
|
||||
{
|
||||
return $this->decorated;
|
||||
}
|
||||
@@ -110,7 +108,7 @@ class OutputFormatter implements WrappableOutputFormatterInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasStyle(string $name)
|
||||
public function hasStyle(string $name): bool
|
||||
{
|
||||
return isset($this->styles[strtolower($name)]);
|
||||
}
|
||||
@@ -118,7 +116,7 @@ class OutputFormatter implements WrappableOutputFormatterInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getStyle(string $name)
|
||||
public function getStyle(string $name): OutputFormatterStyleInterface
|
||||
{
|
||||
if (!$this->hasStyle($name)) {
|
||||
throw new InvalidArgumentException(sprintf('Undefined style: "%s".', $name));
|
||||
@@ -130,7 +128,7 @@ class OutputFormatter implements WrappableOutputFormatterInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function format(?string $message)
|
||||
public function format(?string $message): ?string
|
||||
{
|
||||
return $this->formatAndWrap($message, 0);
|
||||
}
|
||||
@@ -186,10 +184,7 @@ class OutputFormatter implements WrappableOutputFormatterInterface
|
||||
return strtr($output, ["\0" => '\\', '\\<' => '<', '\\>' => '>']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return OutputFormatterStyleStack
|
||||
*/
|
||||
public function getStyleStack()
|
||||
public function getStyleStack(): OutputFormatterStyleStack
|
||||
{
|
||||
return $this->styleStack;
|
||||
}
|
||||
|
||||
@@ -25,10 +25,8 @@ interface OutputFormatterInterface
|
||||
|
||||
/**
|
||||
* Whether the output will decorate messages.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isDecorated();
|
||||
public function isDecorated(): bool;
|
||||
|
||||
/**
|
||||
* Sets a new style.
|
||||
@@ -37,24 +35,18 @@ interface OutputFormatterInterface
|
||||
|
||||
/**
|
||||
* Checks if output formatter has style with specified name.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasStyle(string $name);
|
||||
public function hasStyle(string $name): bool;
|
||||
|
||||
/**
|
||||
* Gets style options from style with specified name.
|
||||
*
|
||||
* @return OutputFormatterStyleInterface
|
||||
*
|
||||
* @throws \InvalidArgumentException When style isn't defined
|
||||
*/
|
||||
public function getStyle(string $name);
|
||||
public function getStyle(string $name): OutputFormatterStyleInterface;
|
||||
|
||||
/**
|
||||
* Formats a message according to the given styles.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function format(?string $message);
|
||||
public function format(?string $message): ?string;
|
||||
}
|
||||
|
||||
@@ -21,11 +21,11 @@ use Symfony\Component\Console\Color;
|
||||
class OutputFormatterStyle implements OutputFormatterStyleInterface
|
||||
{
|
||||
private $color;
|
||||
private $foreground;
|
||||
private $background;
|
||||
private $options;
|
||||
private $href;
|
||||
private $handlesHrefGracefully;
|
||||
private string $foreground;
|
||||
private string $background;
|
||||
private array $options;
|
||||
private ?string $href = null;
|
||||
private bool $handlesHrefGracefully;
|
||||
|
||||
/**
|
||||
* Initializes output formatter style.
|
||||
@@ -92,12 +92,10 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function apply(string $text)
|
||||
public function apply(string $text): string
|
||||
{
|
||||
if (null === $this->handlesHrefGracefully) {
|
||||
$this->handlesHrefGracefully = 'JetBrains-JediTerm' !== getenv('TERMINAL_EMULATOR')
|
||||
&& (!getenv('KONSOLE_VERSION') || (int) getenv('KONSOLE_VERSION') > 201100);
|
||||
}
|
||||
$this->handlesHrefGracefully ??= 'JetBrains-JediTerm' !== getenv('TERMINAL_EMULATOR')
|
||||
&& (!getenv('KONSOLE_VERSION') || (int) getenv('KONSOLE_VERSION') > 201100);
|
||||
|
||||
if (null !== $this->href && $this->handlesHrefGracefully) {
|
||||
$text = "\033]8;;$this->href\033\\$text\033]8;;\033\\";
|
||||
|
||||
@@ -45,8 +45,6 @@ interface OutputFormatterStyleInterface
|
||||
|
||||
/**
|
||||
* Applies the style to a given text.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function apply(string $text);
|
||||
public function apply(string $text): string;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class OutputFormatterStyleStack implements ResetInterface
|
||||
/**
|
||||
* @var OutputFormatterStyleInterface[]
|
||||
*/
|
||||
private $styles;
|
||||
private array $styles = [];
|
||||
|
||||
private $emptyStyle;
|
||||
|
||||
@@ -51,11 +51,9 @@ class OutputFormatterStyleStack implements ResetInterface
|
||||
/**
|
||||
* Pops a style from the stack.
|
||||
*
|
||||
* @return OutputFormatterStyleInterface
|
||||
*
|
||||
* @throws InvalidArgumentException When style tags incorrectly nested
|
||||
*/
|
||||
public function pop(OutputFormatterStyleInterface $style = null)
|
||||
public function pop(OutputFormatterStyleInterface $style = null): OutputFormatterStyleInterface
|
||||
{
|
||||
if (empty($this->styles)) {
|
||||
return $this->emptyStyle;
|
||||
@@ -78,10 +76,8 @@ class OutputFormatterStyleStack implements ResetInterface
|
||||
|
||||
/**
|
||||
* Computes current style with stacks top codes.
|
||||
*
|
||||
* @return OutputFormatterStyle
|
||||
*/
|
||||
public function getCurrent()
|
||||
public function getCurrent(): OutputFormatterStyleInterface
|
||||
{
|
||||
if (empty($this->styles)) {
|
||||
return $this->emptyStyle;
|
||||
@@ -93,17 +89,14 @@ class OutputFormatterStyleStack implements ResetInterface
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setEmptyStyle(OutputFormatterStyleInterface $emptyStyle)
|
||||
public function setEmptyStyle(OutputFormatterStyleInterface $emptyStyle): static
|
||||
{
|
||||
$this->emptyStyle = $emptyStyle;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return OutputFormatterStyleInterface
|
||||
*/
|
||||
public function getEmptyStyle()
|
||||
public function getEmptyStyle(): OutputFormatterStyleInterface
|
||||
{
|
||||
return $this->emptyStyle;
|
||||
}
|
||||
|
||||
@@ -21,15 +21,13 @@ namespace Symfony\Component\Console\Helper;
|
||||
class DebugFormatterHelper extends Helper
|
||||
{
|
||||
private const COLORS = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'default'];
|
||||
private $started = [];
|
||||
private $count = -1;
|
||||
private array $started = [];
|
||||
private int $count = -1;
|
||||
|
||||
/**
|
||||
* Starts a debug formatting session.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function start(string $id, string $message, string $prefix = 'RUN')
|
||||
public function start(string $id, string $message, string $prefix = 'RUN'): string
|
||||
{
|
||||
$this->started[$id] = ['border' => ++$this->count % \count(self::COLORS)];
|
||||
|
||||
@@ -38,10 +36,8 @@ class DebugFormatterHelper extends Helper
|
||||
|
||||
/**
|
||||
* Adds progress to a formatting session.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function progress(string $id, string $buffer, bool $error = false, string $prefix = 'OUT', string $errorPrefix = 'ERR')
|
||||
public function progress(string $id, string $buffer, bool $error = false, string $prefix = 'OUT', string $errorPrefix = 'ERR'): string
|
||||
{
|
||||
$message = '';
|
||||
|
||||
@@ -74,10 +70,8 @@ class DebugFormatterHelper extends Helper
|
||||
|
||||
/**
|
||||
* Stops a formatting session.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function stop(string $id, string $message, bool $successful, string $prefix = 'RES')
|
||||
public function stop(string $id, string $message, bool $successful, string $prefix = 'RES'): string
|
||||
{
|
||||
$trailingEOL = isset($this->started[$id]['out']) || isset($this->started[$id]['err']) ? "\n" : '';
|
||||
|
||||
@@ -100,7 +94,7 @@ class DebugFormatterHelper extends Helper
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
public function getName(): string
|
||||
{
|
||||
return 'debug_formatter';
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class DescriptorHelper extends Helper
|
||||
/**
|
||||
* @var DescriptorInterface[]
|
||||
*/
|
||||
private $descriptors = [];
|
||||
private array $descriptors = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -70,7 +70,7 @@ class DescriptorHelper extends Helper
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function register(string $format, DescriptorInterface $descriptor)
|
||||
public function register(string $format, DescriptorInterface $descriptor): static
|
||||
{
|
||||
$this->descriptors[$format] = $descriptor;
|
||||
|
||||
@@ -80,7 +80,7 @@ class DescriptorHelper extends Helper
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
public function getName(): string
|
||||
{
|
||||
return 'descriptor';
|
||||
}
|
||||
|
||||
4
vendor/symfony/console/Helper/Dumper.php
vendored
4
vendor/symfony/console/Helper/Dumper.php
vendored
@@ -24,7 +24,7 @@ final class Dumper
|
||||
private $output;
|
||||
private $dumper;
|
||||
private $cloner;
|
||||
private $handler;
|
||||
private \Closure $handler;
|
||||
|
||||
public function __construct(OutputInterface $output, CliDumper $dumper = null, ClonerInterface $cloner = null)
|
||||
{
|
||||
@@ -57,7 +57,7 @@ final class Dumper
|
||||
}
|
||||
}
|
||||
|
||||
public function __invoke($var): string
|
||||
public function __invoke(mixed $var): string
|
||||
{
|
||||
return ($this->handler)($var);
|
||||
}
|
||||
|
||||
@@ -22,22 +22,16 @@ class FormatterHelper extends Helper
|
||||
{
|
||||
/**
|
||||
* Formats a message within a section.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function formatSection(string $section, string $message, string $style = 'info')
|
||||
public function formatSection(string $section, string $message, string $style = 'info'): string
|
||||
{
|
||||
return sprintf('<%s>[%s]</%s> %s', $style, $section, $style, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a message as a block of text.
|
||||
*
|
||||
* @param string|array $messages The message to write in the block
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function formatBlock($messages, string $style, bool $large = false)
|
||||
public function formatBlock(string|array $messages, string $style, bool $large = false): string
|
||||
{
|
||||
if (!\is_array($messages)) {
|
||||
$messages = [$messages];
|
||||
@@ -68,10 +62,8 @@ class FormatterHelper extends Helper
|
||||
|
||||
/**
|
||||
* Truncates a message to the given length.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function truncate(string $message, int $length, string $suffix = '...')
|
||||
public function truncate(string $message, int $length, string $suffix = '...'): string
|
||||
{
|
||||
$computedLength = $length - self::width($suffix);
|
||||
|
||||
@@ -85,7 +77,7 @@ class FormatterHelper extends Helper
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
public function getName(): string
|
||||
{
|
||||
return 'formatter';
|
||||
}
|
||||
|
||||
34
vendor/symfony/console/Helper/Helper.php
vendored
34
vendor/symfony/console/Helper/Helper.php
vendored
@@ -34,25 +34,11 @@ abstract class Helper implements HelperInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getHelperSet()
|
||||
public function getHelperSet(): ?HelperSet
|
||||
{
|
||||
return $this->helperSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the length of a string, using mb_strwidth if it is available.
|
||||
*
|
||||
* @deprecated since Symfony 5.3
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function strlen(?string $string)
|
||||
{
|
||||
trigger_deprecation('symfony/console', '5.3', 'Method "%s()" is deprecated and will be removed in Symfony 6.0. Use Helper::width() or Helper::length() instead.', __METHOD__);
|
||||
|
||||
return self::width($string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the width of a string, using mb_strwidth if it is available.
|
||||
* The width is how many characters positions the string will use.
|
||||
@@ -93,10 +79,8 @@ abstract class Helper implements HelperInterface
|
||||
|
||||
/**
|
||||
* Returns the subset of a string, using mb_substr if it is available.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function substr(?string $string, int $from, int $length = null)
|
||||
public static function substr(?string $string, int $from, int $length = null): string
|
||||
{
|
||||
$string ?? $string = '';
|
||||
|
||||
@@ -107,7 +91,7 @@ abstract class Helper implements HelperInterface
|
||||
return mb_substr($string, $from, $length, $encoding);
|
||||
}
|
||||
|
||||
public static function formatTime($secs)
|
||||
public static function formatTime(int|float $secs)
|
||||
{
|
||||
static $timeFormats = [
|
||||
[0, '< 1 sec'],
|
||||
@@ -153,16 +137,6 @@ abstract class Helper implements HelperInterface
|
||||
return sprintf('%d B', $memory);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Symfony 5.3
|
||||
*/
|
||||
public static function strlenWithoutDecoration(OutputFormatterInterface $formatter, ?string $string)
|
||||
{
|
||||
trigger_deprecation('symfony/console', '5.3', 'Method "%s()" is deprecated and will be removed in Symfony 6.0. Use Helper::removeDecoration() instead.', __METHOD__);
|
||||
|
||||
return self::width(self::removeDecoration($formatter, $string));
|
||||
}
|
||||
|
||||
public static function removeDecoration(OutputFormatterInterface $formatter, ?string $string)
|
||||
{
|
||||
$isDecorated = $formatter->isDecorated();
|
||||
@@ -171,6 +145,8 @@ abstract class Helper implements HelperInterface
|
||||
$string = $formatter->format($string ?? '');
|
||||
// remove already formatted characters
|
||||
$string = preg_replace("/\033\[[^m]*m/", '', $string ?? '');
|
||||
// remove terminal hyperlinks
|
||||
$string = preg_replace('/\\033]8;[^;]*;[^\\033]*\\033\\\\/', '', $string ?? '');
|
||||
$formatter->setDecorated($isDecorated);
|
||||
|
||||
return $string;
|
||||
|
||||
@@ -25,10 +25,8 @@ interface HelperInterface
|
||||
|
||||
/**
|
||||
* Gets the helper set associated with this helper.
|
||||
*
|
||||
* @return HelperSet|null
|
||||
*/
|
||||
public function getHelperSet();
|
||||
public function getHelperSet(): ?HelperSet;
|
||||
|
||||
/**
|
||||
* Returns the canonical name of this helper.
|
||||
|
||||
42
vendor/symfony/console/Helper/HelperSet.php
vendored
42
vendor/symfony/console/Helper/HelperSet.php
vendored
@@ -11,7 +11,6 @@
|
||||
|
||||
namespace Symfony\Component\Console\Helper;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
@@ -24,8 +23,7 @@ use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||
class HelperSet implements \IteratorAggregate
|
||||
{
|
||||
/** @var array<string, Helper> */
|
||||
private $helpers = [];
|
||||
private $command;
|
||||
private array $helpers = [];
|
||||
|
||||
/**
|
||||
* @param Helper[] $helpers An array of helper
|
||||
@@ -49,10 +47,8 @@ class HelperSet implements \IteratorAggregate
|
||||
|
||||
/**
|
||||
* Returns true if the helper if defined.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has(string $name)
|
||||
public function has(string $name): bool
|
||||
{
|
||||
return isset($this->helpers[$name]);
|
||||
}
|
||||
@@ -60,11 +56,9 @@ class HelperSet implements \IteratorAggregate
|
||||
/**
|
||||
* Gets a helper value.
|
||||
*
|
||||
* @return HelperInterface
|
||||
*
|
||||
* @throws InvalidArgumentException if the helper is not defined
|
||||
*/
|
||||
public function get(string $name)
|
||||
public function get(string $name): HelperInterface
|
||||
{
|
||||
if (!$this->has($name)) {
|
||||
throw new InvalidArgumentException(sprintf('The helper "%s" is not defined.', $name));
|
||||
@@ -73,35 +67,7 @@ class HelperSet implements \IteratorAggregate
|
||||
return $this->helpers[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Symfony 5.4
|
||||
*/
|
||||
public function setCommand(Command $command = null)
|
||||
{
|
||||
trigger_deprecation('symfony/console', '5.4', 'Method "%s()" is deprecated.', __METHOD__);
|
||||
|
||||
$this->command = $command;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the command associated with this helper set.
|
||||
*
|
||||
* @return Command
|
||||
*
|
||||
* @deprecated since Symfony 5.4
|
||||
*/
|
||||
public function getCommand()
|
||||
{
|
||||
trigger_deprecation('symfony/console', '5.4', 'Method "%s()" is deprecated.', __METHOD__);
|
||||
|
||||
return $this->command;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Traversable<string, Helper>
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function getIterator()
|
||||
public function getIterator(): \Traversable
|
||||
{
|
||||
return new \ArrayIterator($this->helpers);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ class ProcessHelper extends Helper
|
||||
* @param callable|null $callback A PHP callback to run whenever there is some
|
||||
* output available on STDOUT or STDERR
|
||||
*/
|
||||
public function run(OutputInterface $output, $cmd, string $error = null, callable $callback = null, int $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE): Process
|
||||
public function run(OutputInterface $output, array|Process $cmd, string $error = null, callable $callback = null, int $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE): Process
|
||||
{
|
||||
if (!class_exists(Process::class)) {
|
||||
throw new \LogicException('The ProcessHelper cannot be run as the Process component is not installed. Try running "compose require symfony/process".');
|
||||
@@ -48,10 +48,6 @@ class ProcessHelper extends Helper
|
||||
$cmd = [$cmd];
|
||||
}
|
||||
|
||||
if (!\is_array($cmd)) {
|
||||
throw new \TypeError(sprintf('The "command" argument of "%s()" must be an array or a "%s" instance, "%s" given.', __METHOD__, Process::class, get_debug_type($cmd)));
|
||||
}
|
||||
|
||||
if (\is_string($cmd[0] ?? null)) {
|
||||
$process = new Process($cmd);
|
||||
$cmd = [];
|
||||
@@ -98,7 +94,7 @@ class ProcessHelper extends Helper
|
||||
*
|
||||
* @see run()
|
||||
*/
|
||||
public function mustRun(OutputInterface $output, $cmd, string $error = null, callable $callback = null): Process
|
||||
public function mustRun(OutputInterface $output, array|Process $cmd, string $error = null, callable $callback = null): Process
|
||||
{
|
||||
$process = $this->run($output, $cmd, $error, $callback);
|
||||
|
||||
|
||||
62
vendor/symfony/console/Helper/ProgressBar.php
vendored
62
vendor/symfony/console/Helper/ProgressBar.php
vendored
@@ -36,32 +36,32 @@ final class ProgressBar
|
||||
private const FORMAT_DEBUG_NOMAX = 'debug_nomax';
|
||||
private const FORMAT_NORMAL_NOMAX = 'normal_nomax';
|
||||
|
||||
private $barWidth = 28;
|
||||
private $barChar;
|
||||
private $emptyBarChar = '-';
|
||||
private $progressChar = '>';
|
||||
private $format;
|
||||
private $internalFormat;
|
||||
private $redrawFreq = 1;
|
||||
private $writeCount;
|
||||
private $lastWriteTime;
|
||||
private $minSecondsBetweenRedraws = 0;
|
||||
private $maxSecondsBetweenRedraws = 1;
|
||||
private int $barWidth = 28;
|
||||
private string $barChar;
|
||||
private string $emptyBarChar = '-';
|
||||
private string $progressChar = '>';
|
||||
private ?string $format = null;
|
||||
private ?string $internalFormat = null;
|
||||
private ?int $redrawFreq = 1;
|
||||
private int $writeCount = 0;
|
||||
private float $lastWriteTime = 0;
|
||||
private float $minSecondsBetweenRedraws = 0;
|
||||
private float $maxSecondsBetweenRedraws = 1;
|
||||
private $output;
|
||||
private $step = 0;
|
||||
private $max;
|
||||
private $startTime;
|
||||
private $stepWidth;
|
||||
private $percent = 0.0;
|
||||
private $formatLineCount;
|
||||
private $messages = [];
|
||||
private $overwrite = true;
|
||||
private int $step = 0;
|
||||
private ?int $max = null;
|
||||
private int $startTime;
|
||||
private int $stepWidth;
|
||||
private float $percent = 0.0;
|
||||
private int $formatLineCount;
|
||||
private array $messages = [];
|
||||
private bool $overwrite = true;
|
||||
private $terminal;
|
||||
private $previousMessage;
|
||||
private ?string $previousMessage = null;
|
||||
private $cursor;
|
||||
|
||||
private static $formatters;
|
||||
private static $formats;
|
||||
private static array $formatters;
|
||||
private static array $formats;
|
||||
|
||||
/**
|
||||
* @param int $max Maximum steps (0 if unknown)
|
||||
@@ -103,9 +103,7 @@ final class ProgressBar
|
||||
*/
|
||||
public static function setPlaceholderFormatterDefinition(string $name, callable $callable): void
|
||||
{
|
||||
if (!self::$formatters) {
|
||||
self::$formatters = self::initPlaceholderFormatters();
|
||||
}
|
||||
self::$formatters ??= self::initPlaceholderFormatters();
|
||||
|
||||
self::$formatters[$name] = $callable;
|
||||
}
|
||||
@@ -117,9 +115,7 @@ final class ProgressBar
|
||||
*/
|
||||
public static function getPlaceholderFormatterDefinition(string $name): ?callable
|
||||
{
|
||||
if (!self::$formatters) {
|
||||
self::$formatters = self::initPlaceholderFormatters();
|
||||
}
|
||||
self::$formatters ??= self::initPlaceholderFormatters();
|
||||
|
||||
return self::$formatters[$name] ?? null;
|
||||
}
|
||||
@@ -134,9 +130,7 @@ final class ProgressBar
|
||||
*/
|
||||
public static function setFormatDefinition(string $name, string $format): void
|
||||
{
|
||||
if (!self::$formats) {
|
||||
self::$formats = self::initFormats();
|
||||
}
|
||||
self::$formats ??= self::initFormats();
|
||||
|
||||
self::$formats[$name] = $format;
|
||||
}
|
||||
@@ -148,9 +142,7 @@ final class ProgressBar
|
||||
*/
|
||||
public static function getFormatDefinition(string $name): ?string
|
||||
{
|
||||
if (!self::$formats) {
|
||||
self::$formats = self::initFormats();
|
||||
}
|
||||
self::$formats ??= self::initFormats();
|
||||
|
||||
return self::$formats[$name] ?? null;
|
||||
}
|
||||
@@ -574,6 +566,8 @@ final class ProgressBar
|
||||
|
||||
private function buildLine(): string
|
||||
{
|
||||
\assert(null !== $this->format);
|
||||
|
||||
$regex = "{%([a-z\-_]+)(?:\:([^%]+))?%}i";
|
||||
$callback = function ($matches) {
|
||||
if ($formatter = $this::getPlaceholderFormatterDefinition($matches[1])) {
|
||||
|
||||
@@ -32,19 +32,19 @@ class ProgressIndicator
|
||||
];
|
||||
|
||||
private $output;
|
||||
private $startTime;
|
||||
private $format;
|
||||
private $message;
|
||||
private $indicatorValues;
|
||||
private $indicatorCurrent;
|
||||
private $indicatorChangeInterval;
|
||||
private $indicatorUpdateTime;
|
||||
private $started = false;
|
||||
private int $startTime;
|
||||
private ?string $format = null;
|
||||
private ?string $message = null;
|
||||
private array $indicatorValues;
|
||||
private int $indicatorCurrent;
|
||||
private int $indicatorChangeInterval;
|
||||
private float $indicatorUpdateTime;
|
||||
private bool $started = false;
|
||||
|
||||
/**
|
||||
* @var array<string, callable>
|
||||
*/
|
||||
private static $formatters;
|
||||
private static array $formatters;
|
||||
|
||||
/**
|
||||
* @param int $indicatorChangeInterval Change interval in milliseconds
|
||||
@@ -146,10 +146,8 @@ class ProgressIndicator
|
||||
|
||||
/**
|
||||
* Gets the format for a given name.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public static function getFormatDefinition(string $name)
|
||||
public static function getFormatDefinition(string $name): ?string
|
||||
{
|
||||
return self::FORMATS[$name] ?? null;
|
||||
}
|
||||
@@ -161,23 +159,17 @@ class ProgressIndicator
|
||||
*/
|
||||
public static function setPlaceholderFormatterDefinition(string $name, callable $callable)
|
||||
{
|
||||
if (!self::$formatters) {
|
||||
self::$formatters = self::initPlaceholderFormatters();
|
||||
}
|
||||
self::$formatters ??= self::initPlaceholderFormatters();
|
||||
|
||||
self::$formatters[$name] = $callable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the placeholder formatter for a given name (including the delimiter char like %).
|
||||
*
|
||||
* @return callable|null
|
||||
*/
|
||||
public static function getPlaceholderFormatterDefinition(string $name)
|
||||
public static function getPlaceholderFormatterDefinition(string $name): ?callable
|
||||
{
|
||||
if (!self::$formatters) {
|
||||
self::$formatters = self::initPlaceholderFormatters();
|
||||
}
|
||||
self::$formatters ??= self::initPlaceholderFormatters();
|
||||
|
||||
return self::$formatters[$name] ?? null;
|
||||
}
|
||||
@@ -229,6 +221,9 @@ class ProgressIndicator
|
||||
return round(microtime(true) * 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, \Closure>
|
||||
*/
|
||||
private static function initPlaceholderFormatters(): array
|
||||
{
|
||||
return [
|
||||
|
||||
40
vendor/symfony/console/Helper/QuestionHelper.php
vendored
40
vendor/symfony/console/Helper/QuestionHelper.php
vendored
@@ -39,8 +39,8 @@ class QuestionHelper extends Helper
|
||||
*/
|
||||
private $inputStream;
|
||||
|
||||
private static $stty = true;
|
||||
private static $stdinIsInteractive;
|
||||
private static bool $stty = true;
|
||||
private static bool $stdinIsInteractive;
|
||||
|
||||
/**
|
||||
* Asks a question to the user.
|
||||
@@ -49,7 +49,7 @@ class QuestionHelper extends Helper
|
||||
*
|
||||
* @throws RuntimeException If there is no data to read in the input stream
|
||||
*/
|
||||
public function ask(InputInterface $input, OutputInterface $output, Question $question)
|
||||
public function ask(InputInterface $input, OutputInterface $output, Question $question): mixed
|
||||
{
|
||||
if ($output instanceof ConsoleOutputInterface) {
|
||||
$output = $output->getErrorOutput();
|
||||
@@ -87,7 +87,7 @@ class QuestionHelper extends Helper
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
public function getName(): string
|
||||
{
|
||||
return 'question';
|
||||
}
|
||||
@@ -103,11 +103,9 @@ class QuestionHelper extends Helper
|
||||
/**
|
||||
* Asks the question to the user.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws RuntimeException In case the fallback is deactivated and the response cannot be hidden
|
||||
*/
|
||||
private function doAsk(OutputInterface $output, Question $question)
|
||||
private function doAsk(OutputInterface $output, Question $question): mixed
|
||||
{
|
||||
$this->writePrompt($output, $question);
|
||||
|
||||
@@ -154,10 +152,7 @@ class QuestionHelper extends Helper
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
private function getDefaultAnswer(Question $question)
|
||||
private function getDefaultAnswer(Question $question): mixed
|
||||
{
|
||||
$default = $question->getDefault();
|
||||
|
||||
@@ -205,7 +200,7 @@ class QuestionHelper extends Helper
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
protected function formatChoiceQuestionChoices(ChoiceQuestion $question, string $tag)
|
||||
protected function formatChoiceQuestionChoices(ChoiceQuestion $question, string $tag): array
|
||||
{
|
||||
$messages = [];
|
||||
|
||||
@@ -457,11 +452,9 @@ class QuestionHelper extends Helper
|
||||
*
|
||||
* @param callable $interviewer A callable that will ask for a question and return the result
|
||||
*
|
||||
* @return mixed The validated response
|
||||
*
|
||||
* @throws \Exception In case the max number of attempts has been reached and no valid response has been given
|
||||
*/
|
||||
private function validateAttempts(callable $interviewer, OutputInterface $output, Question $question)
|
||||
private function validateAttempts(callable $interviewer, OutputInterface $output, Question $question): mixed
|
||||
{
|
||||
$error = null;
|
||||
$attempts = $question->getMaxAttempts();
|
||||
@@ -488,7 +481,7 @@ class QuestionHelper extends Helper
|
||||
return false;
|
||||
}
|
||||
|
||||
if (null !== self::$stdinIsInteractive) {
|
||||
if (isset(self::$stdinIsInteractive)) {
|
||||
return self::$stdinIsInteractive;
|
||||
}
|
||||
|
||||
@@ -514,10 +507,8 @@ class QuestionHelper extends Helper
|
||||
*
|
||||
* @param resource $inputStream The handler resource
|
||||
* @param Question $question The question being asked
|
||||
*
|
||||
* @return string|false The input received, false in case input could not be read
|
||||
*/
|
||||
private function readInput($inputStream, Question $question)
|
||||
private function readInput($inputStream, Question $question): string|false
|
||||
{
|
||||
if (!$question->isMultiline()) {
|
||||
$cp = $this->setIOCodepage();
|
||||
@@ -543,11 +534,6 @@ class QuestionHelper extends Helper
|
||||
return $this->resetIOCodepage($cp, $ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets console I/O to the host code page.
|
||||
*
|
||||
* @return int Previous code page in IBM/EBCDIC format
|
||||
*/
|
||||
private function setIOCodepage(): int
|
||||
{
|
||||
if (\function_exists('sapi_windows_cp_set')) {
|
||||
@@ -562,12 +548,8 @@ class QuestionHelper extends Helper
|
||||
|
||||
/**
|
||||
* Sets console I/O to the specified code page and converts the user input.
|
||||
*
|
||||
* @param string|false $input
|
||||
*
|
||||
* @return string|false
|
||||
*/
|
||||
private function resetIOCodepage(int $cp, $input)
|
||||
private function resetIOCodepage(int $cp, string|false $input): string|false
|
||||
{
|
||||
if (0 !== $cp) {
|
||||
sapi_windows_cp_set($cp);
|
||||
|
||||
138
vendor/symfony/console/Helper/Table.php
vendored
138
vendor/symfony/console/Helper/Table.php
vendored
@@ -36,69 +36,27 @@ class Table
|
||||
private const BORDER_OUTSIDE = 0;
|
||||
private const BORDER_INSIDE = 1;
|
||||
|
||||
private $headerTitle;
|
||||
private $footerTitle;
|
||||
|
||||
/**
|
||||
* Table headers.
|
||||
*/
|
||||
private $headers = [];
|
||||
|
||||
/**
|
||||
* Table rows.
|
||||
*/
|
||||
private $rows = [];
|
||||
private $horizontal = false;
|
||||
|
||||
/**
|
||||
* Column widths cache.
|
||||
*/
|
||||
private $effectiveColumnWidths = [];
|
||||
|
||||
/**
|
||||
* Number of columns cache.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $numberOfColumns;
|
||||
|
||||
/**
|
||||
* @var OutputInterface
|
||||
*/
|
||||
private ?string $headerTitle = null;
|
||||
private ?string $footerTitle = null;
|
||||
private array $headers = [];
|
||||
private array $rows = [];
|
||||
private bool $horizontal = false;
|
||||
private array $effectiveColumnWidths = [];
|
||||
private int $numberOfColumns;
|
||||
private $output;
|
||||
|
||||
/**
|
||||
* @var TableStyle
|
||||
*/
|
||||
private $style;
|
||||
private array $columnStyles = [];
|
||||
private array $columnWidths = [];
|
||||
private array $columnMaxWidths = [];
|
||||
private bool $rendered = false;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $columnStyles = [];
|
||||
|
||||
/**
|
||||
* User set column widths.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $columnWidths = [];
|
||||
private $columnMaxWidths = [];
|
||||
|
||||
/**
|
||||
* @var array<string, TableStyle>|null
|
||||
*/
|
||||
private static $styles;
|
||||
|
||||
private $rendered = false;
|
||||
private static array $styles;
|
||||
|
||||
public function __construct(OutputInterface $output)
|
||||
{
|
||||
$this->output = $output;
|
||||
|
||||
if (!self::$styles) {
|
||||
self::$styles = self::initStyles();
|
||||
}
|
||||
self::$styles ??= self::initStyles();
|
||||
|
||||
$this->setStyle('default');
|
||||
}
|
||||
@@ -108,39 +66,27 @@ class Table
|
||||
*/
|
||||
public static function setStyleDefinition(string $name, TableStyle $style)
|
||||
{
|
||||
if (!self::$styles) {
|
||||
self::$styles = self::initStyles();
|
||||
}
|
||||
self::$styles ??= self::initStyles();
|
||||
|
||||
self::$styles[$name] = $style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a style definition by name.
|
||||
*
|
||||
* @return TableStyle
|
||||
*/
|
||||
public static function getStyleDefinition(string $name)
|
||||
public static function getStyleDefinition(string $name): TableStyle
|
||||
{
|
||||
if (!self::$styles) {
|
||||
self::$styles = self::initStyles();
|
||||
}
|
||||
self::$styles ??= self::initStyles();
|
||||
|
||||
if (isset(self::$styles[$name])) {
|
||||
return self::$styles[$name];
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
|
||||
return self::$styles[$name] ?? throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets table style.
|
||||
*
|
||||
* @param TableStyle|string $name The style name or a TableStyle instance
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setStyle($name)
|
||||
public function setStyle(TableStyle|string $name): static
|
||||
{
|
||||
$this->style = $this->resolveStyle($name);
|
||||
|
||||
@@ -149,10 +95,8 @@ class Table
|
||||
|
||||
/**
|
||||
* Gets the current table style.
|
||||
*
|
||||
* @return TableStyle
|
||||
*/
|
||||
public function getStyle()
|
||||
public function getStyle(): TableStyle
|
||||
{
|
||||
return $this->style;
|
||||
}
|
||||
@@ -164,7 +108,7 @@ class Table
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setColumnStyle(int $columnIndex, $name)
|
||||
public function setColumnStyle(int $columnIndex, TableStyle|string $name): static
|
||||
{
|
||||
$this->columnStyles[$columnIndex] = $this->resolveStyle($name);
|
||||
|
||||
@@ -175,10 +119,8 @@ class Table
|
||||
* Gets the current style for a column.
|
||||
*
|
||||
* If style was not set, it returns the global table style.
|
||||
*
|
||||
* @return TableStyle
|
||||
*/
|
||||
public function getColumnStyle(int $columnIndex)
|
||||
public function getColumnStyle(int $columnIndex): TableStyle
|
||||
{
|
||||
return $this->columnStyles[$columnIndex] ?? $this->getStyle();
|
||||
}
|
||||
@@ -188,7 +130,7 @@ class Table
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setColumnWidth(int $columnIndex, int $width)
|
||||
public function setColumnWidth(int $columnIndex, int $width): static
|
||||
{
|
||||
$this->columnWidths[$columnIndex] = $width;
|
||||
|
||||
@@ -200,7 +142,7 @@ class Table
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setColumnWidths(array $widths)
|
||||
public function setColumnWidths(array $widths): static
|
||||
{
|
||||
$this->columnWidths = [];
|
||||
foreach ($widths as $index => $width) {
|
||||
@@ -218,7 +160,7 @@ class Table
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setColumnMaxWidth(int $columnIndex, int $width): self
|
||||
public function setColumnMaxWidth(int $columnIndex, int $width): static
|
||||
{
|
||||
if (!$this->output->getFormatter() instanceof WrappableOutputFormatterInterface) {
|
||||
throw new \LogicException(sprintf('Setting a maximum column width is only supported when using a "%s" formatter, got "%s".', WrappableOutputFormatterInterface::class, get_debug_type($this->output->getFormatter())));
|
||||
@@ -232,7 +174,7 @@ class Table
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setHeaders(array $headers)
|
||||
public function setHeaders(array $headers): static
|
||||
{
|
||||
$headers = array_values($headers);
|
||||
if (!empty($headers) && !\is_array($headers[0])) {
|
||||
@@ -254,7 +196,7 @@ class Table
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function addRows(array $rows)
|
||||
public function addRows(array $rows): static
|
||||
{
|
||||
foreach ($rows as $row) {
|
||||
$this->addRow($row);
|
||||
@@ -266,7 +208,7 @@ class Table
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function addRow($row)
|
||||
public function addRow(TableSeparator|array $row): static
|
||||
{
|
||||
if ($row instanceof TableSeparator) {
|
||||
$this->rows[] = $row;
|
||||
@@ -274,10 +216,6 @@ class Table
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (!\is_array($row)) {
|
||||
throw new InvalidArgumentException('A row must be an array or a TableSeparator instance.');
|
||||
}
|
||||
|
||||
$this->rows[] = array_values($row);
|
||||
|
||||
return $this;
|
||||
@@ -288,7 +226,7 @@ class Table
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function appendRow($row): self
|
||||
public function appendRow(TableSeparator|array $row): static
|
||||
{
|
||||
if (!$this->output instanceof ConsoleSectionOutput) {
|
||||
throw new RuntimeException(sprintf('Output should be an instance of "%s" when calling "%s".', ConsoleSectionOutput::class, __METHOD__));
|
||||
@@ -307,7 +245,7 @@ class Table
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setRow($column, array $row)
|
||||
public function setRow(int|string $column, array $row): static
|
||||
{
|
||||
$this->rows[$column] = $row;
|
||||
|
||||
@@ -317,7 +255,7 @@ class Table
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setHeaderTitle(?string $title): self
|
||||
public function setHeaderTitle(?string $title): static
|
||||
{
|
||||
$this->headerTitle = $title;
|
||||
|
||||
@@ -327,7 +265,7 @@ class Table
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setFooterTitle(?string $title): self
|
||||
public function setFooterTitle(?string $title): static
|
||||
{
|
||||
$this->footerTitle = $title;
|
||||
|
||||
@@ -337,7 +275,7 @@ class Table
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setHorizontal(bool $horizontal = true): self
|
||||
public function setHorizontal(bool $horizontal = true): static
|
||||
{
|
||||
$this->horizontal = $horizontal;
|
||||
|
||||
@@ -678,7 +616,7 @@ class Table
|
||||
{
|
||||
$unmergedRows = [];
|
||||
foreach ($rows[$line] as $column => $cell) {
|
||||
if (null !== $cell && !$cell instanceof TableCell && !\is_scalar($cell) && !(\is_object($cell) && method_exists($cell, '__toString'))) {
|
||||
if (null !== $cell && !$cell instanceof TableCell && !\is_scalar($cell) && !$cell instanceof \Stringable) {
|
||||
throw new InvalidArgumentException(sprintf('A cell must be a TableCell, a scalar or an object implementing "__toString()", "%s" given.', get_debug_type($cell)));
|
||||
}
|
||||
if ($cell instanceof TableCell && $cell->getRowspan() > 1) {
|
||||
@@ -847,7 +785,7 @@ class Table
|
||||
private function cleanup()
|
||||
{
|
||||
$this->effectiveColumnWidths = [];
|
||||
$this->numberOfColumns = null;
|
||||
unset($this->numberOfColumns);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -900,16 +838,12 @@ class Table
|
||||
];
|
||||
}
|
||||
|
||||
private function resolveStyle($name): TableStyle
|
||||
private function resolveStyle(TableStyle|string $name): TableStyle
|
||||
{
|
||||
if ($name instanceof TableStyle) {
|
||||
return $name;
|
||||
}
|
||||
|
||||
if (isset(self::$styles[$name])) {
|
||||
return self::$styles[$name];
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
|
||||
return self::$styles[$name] ?? throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
|
||||
}
|
||||
}
|
||||
|
||||
16
vendor/symfony/console/Helper/TableCell.php
vendored
16
vendor/symfony/console/Helper/TableCell.php
vendored
@@ -18,8 +18,8 @@ use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||
*/
|
||||
class TableCell
|
||||
{
|
||||
private $value;
|
||||
private $options = [
|
||||
private string $value;
|
||||
private array $options = [
|
||||
'rowspan' => 1,
|
||||
'colspan' => 1,
|
||||
'style' => null,
|
||||
@@ -43,30 +43,24 @@ class TableCell
|
||||
|
||||
/**
|
||||
* Returns the cell value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets number of colspan.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getColspan()
|
||||
public function getColspan(): int
|
||||
{
|
||||
return (int) $this->options['colspan'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets number of rowspan.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getRowspan()
|
||||
public function getRowspan(): int
|
||||
{
|
||||
return (int) $this->options['rowspan'];
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ class TableCellStyle
|
||||
'right' => \STR_PAD_LEFT,
|
||||
];
|
||||
|
||||
private $options = [
|
||||
private array $options = [
|
||||
'fg' => 'default',
|
||||
'bg' => 'default',
|
||||
'options' => null,
|
||||
@@ -63,7 +63,7 @@ class TableCellStyle
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getTagOptions()
|
||||
public function getTagOptions(): array
|
||||
{
|
||||
return array_filter(
|
||||
$this->getOptions(),
|
||||
@@ -74,10 +74,7 @@ class TableCellStyle
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPadByAlign()
|
||||
public function getPadByAlign(): int
|
||||
{
|
||||
return self::ALIGN_MAP[$this->getOptions()['align']];
|
||||
}
|
||||
|
||||
2
vendor/symfony/console/Helper/TableRows.php
vendored
2
vendor/symfony/console/Helper/TableRows.php
vendored
@@ -16,7 +16,7 @@ namespace Symfony\Component\Console\Helper;
|
||||
*/
|
||||
class TableRows implements \IteratorAggregate
|
||||
{
|
||||
private $generator;
|
||||
private \Closure $generator;
|
||||
|
||||
public function __construct(\Closure $generator)
|
||||
{
|
||||
|
||||
98
vendor/symfony/console/Helper/TableStyle.php
vendored
98
vendor/symfony/console/Helper/TableStyle.php
vendored
@@ -23,37 +23,37 @@ use Symfony\Component\Console\Exception\LogicException;
|
||||
*/
|
||||
class TableStyle
|
||||
{
|
||||
private $paddingChar = ' ';
|
||||
private $horizontalOutsideBorderChar = '-';
|
||||
private $horizontalInsideBorderChar = '-';
|
||||
private $verticalOutsideBorderChar = '|';
|
||||
private $verticalInsideBorderChar = '|';
|
||||
private $crossingChar = '+';
|
||||
private $crossingTopRightChar = '+';
|
||||
private $crossingTopMidChar = '+';
|
||||
private $crossingTopLeftChar = '+';
|
||||
private $crossingMidRightChar = '+';
|
||||
private $crossingBottomRightChar = '+';
|
||||
private $crossingBottomMidChar = '+';
|
||||
private $crossingBottomLeftChar = '+';
|
||||
private $crossingMidLeftChar = '+';
|
||||
private $crossingTopLeftBottomChar = '+';
|
||||
private $crossingTopMidBottomChar = '+';
|
||||
private $crossingTopRightBottomChar = '+';
|
||||
private $headerTitleFormat = '<fg=black;bg=white;options=bold> %s </>';
|
||||
private $footerTitleFormat = '<fg=black;bg=white;options=bold> %s </>';
|
||||
private $cellHeaderFormat = '<info>%s</info>';
|
||||
private $cellRowFormat = '%s';
|
||||
private $cellRowContentFormat = ' %s ';
|
||||
private $borderFormat = '%s';
|
||||
private $padType = \STR_PAD_RIGHT;
|
||||
private string $paddingChar = ' ';
|
||||
private string $horizontalOutsideBorderChar = '-';
|
||||
private string $horizontalInsideBorderChar = '-';
|
||||
private string $verticalOutsideBorderChar = '|';
|
||||
private string $verticalInsideBorderChar = '|';
|
||||
private string $crossingChar = '+';
|
||||
private string $crossingTopRightChar = '+';
|
||||
private string $crossingTopMidChar = '+';
|
||||
private string $crossingTopLeftChar = '+';
|
||||
private string $crossingMidRightChar = '+';
|
||||
private string $crossingBottomRightChar = '+';
|
||||
private string $crossingBottomMidChar = '+';
|
||||
private string $crossingBottomLeftChar = '+';
|
||||
private string $crossingMidLeftChar = '+';
|
||||
private string $crossingTopLeftBottomChar = '+';
|
||||
private string $crossingTopMidBottomChar = '+';
|
||||
private string $crossingTopRightBottomChar = '+';
|
||||
private string $headerTitleFormat = '<fg=black;bg=white;options=bold> %s </>';
|
||||
private string $footerTitleFormat = '<fg=black;bg=white;options=bold> %s </>';
|
||||
private string $cellHeaderFormat = '<info>%s</info>';
|
||||
private string $cellRowFormat = '%s';
|
||||
private string $cellRowContentFormat = ' %s ';
|
||||
private string $borderFormat = '%s';
|
||||
private int $padType = \STR_PAD_RIGHT;
|
||||
|
||||
/**
|
||||
* Sets padding character, used for cell padding.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPaddingChar(string $paddingChar)
|
||||
public function setPaddingChar(string $paddingChar): static
|
||||
{
|
||||
if (!$paddingChar) {
|
||||
throw new LogicException('The padding char must not be empty.');
|
||||
@@ -66,10 +66,8 @@ class TableStyle
|
||||
|
||||
/**
|
||||
* Gets padding character, used for cell padding.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPaddingChar()
|
||||
public function getPaddingChar(): string
|
||||
{
|
||||
return $this->paddingChar;
|
||||
}
|
||||
@@ -90,7 +88,7 @@ class TableStyle
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setHorizontalBorderChars(string $outside, string $inside = null): self
|
||||
public function setHorizontalBorderChars(string $outside, string $inside = null): static
|
||||
{
|
||||
$this->horizontalOutsideBorderChar = $outside;
|
||||
$this->horizontalInsideBorderChar = $inside ?? $outside;
|
||||
@@ -115,7 +113,7 @@ class TableStyle
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setVerticalBorderChars(string $outside, string $inside = null): self
|
||||
public function setVerticalBorderChars(string $outside, string $inside = null): static
|
||||
{
|
||||
$this->verticalOutsideBorderChar = $outside;
|
||||
$this->verticalInsideBorderChar = $inside ?? $outside;
|
||||
@@ -169,7 +167,7 @@ class TableStyle
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCrossingChars(string $cross, string $topLeft, string $topMid, string $topRight, string $midRight, string $bottomRight, string $bottomMid, string $bottomLeft, string $midLeft, string $topLeftBottom = null, string $topMidBottom = null, string $topRightBottom = null): self
|
||||
public function setCrossingChars(string $cross, string $topLeft, string $topMid, string $topRight, string $midRight, string $bottomRight, string $bottomMid, string $bottomLeft, string $midLeft, string $topLeftBottom = null, string $topMidBottom = null, string $topRightBottom = null): static
|
||||
{
|
||||
$this->crossingChar = $cross;
|
||||
$this->crossingTopLeftChar = $topLeft;
|
||||
@@ -199,10 +197,8 @@ class TableStyle
|
||||
|
||||
/**
|
||||
* Gets crossing character.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCrossingChar()
|
||||
public function getCrossingChar(): string
|
||||
{
|
||||
return $this->crossingChar;
|
||||
}
|
||||
@@ -235,7 +231,7 @@ class TableStyle
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCellHeaderFormat(string $cellHeaderFormat)
|
||||
public function setCellHeaderFormat(string $cellHeaderFormat): static
|
||||
{
|
||||
$this->cellHeaderFormat = $cellHeaderFormat;
|
||||
|
||||
@@ -244,10 +240,8 @@ class TableStyle
|
||||
|
||||
/**
|
||||
* Gets header cell format.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCellHeaderFormat()
|
||||
public function getCellHeaderFormat(): string
|
||||
{
|
||||
return $this->cellHeaderFormat;
|
||||
}
|
||||
@@ -257,7 +251,7 @@ class TableStyle
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCellRowFormat(string $cellRowFormat)
|
||||
public function setCellRowFormat(string $cellRowFormat): static
|
||||
{
|
||||
$this->cellRowFormat = $cellRowFormat;
|
||||
|
||||
@@ -266,10 +260,8 @@ class TableStyle
|
||||
|
||||
/**
|
||||
* Gets row cell format.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCellRowFormat()
|
||||
public function getCellRowFormat(): string
|
||||
{
|
||||
return $this->cellRowFormat;
|
||||
}
|
||||
@@ -279,7 +271,7 @@ class TableStyle
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCellRowContentFormat(string $cellRowContentFormat)
|
||||
public function setCellRowContentFormat(string $cellRowContentFormat): static
|
||||
{
|
||||
$this->cellRowContentFormat = $cellRowContentFormat;
|
||||
|
||||
@@ -288,10 +280,8 @@ class TableStyle
|
||||
|
||||
/**
|
||||
* Gets row cell content format.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCellRowContentFormat()
|
||||
public function getCellRowContentFormat(): string
|
||||
{
|
||||
return $this->cellRowContentFormat;
|
||||
}
|
||||
@@ -301,7 +291,7 @@ class TableStyle
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setBorderFormat(string $borderFormat)
|
||||
public function setBorderFormat(string $borderFormat): static
|
||||
{
|
||||
$this->borderFormat = $borderFormat;
|
||||
|
||||
@@ -310,10 +300,8 @@ class TableStyle
|
||||
|
||||
/**
|
||||
* Gets table border format.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBorderFormat()
|
||||
public function getBorderFormat(): string
|
||||
{
|
||||
return $this->borderFormat;
|
||||
}
|
||||
@@ -323,7 +311,7 @@ class TableStyle
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPadType(int $padType)
|
||||
public function setPadType(int $padType): static
|
||||
{
|
||||
if (!\in_array($padType, [\STR_PAD_LEFT, \STR_PAD_RIGHT, \STR_PAD_BOTH], true)) {
|
||||
throw new InvalidArgumentException('Invalid padding type. Expected one of (STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH).');
|
||||
@@ -336,10 +324,8 @@ class TableStyle
|
||||
|
||||
/**
|
||||
* Gets cell padding type.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPadType()
|
||||
public function getPadType(): int
|
||||
{
|
||||
return $this->padType;
|
||||
}
|
||||
@@ -352,7 +338,7 @@ class TableStyle
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setHeaderTitleFormat(string $format): self
|
||||
public function setHeaderTitleFormat(string $format): static
|
||||
{
|
||||
$this->headerTitleFormat = $format;
|
||||
|
||||
@@ -367,7 +353,7 @@ class TableStyle
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setFooterTitleFormat(string $format): self
|
||||
public function setFooterTitleFormat(string $format): static
|
||||
{
|
||||
$this->footerTitleFormat = $format;
|
||||
|
||||
|
||||
18
vendor/symfony/console/Input/ArgvInput.php
vendored
18
vendor/symfony/console/Input/ArgvInput.php
vendored
@@ -40,8 +40,8 @@ use Symfony\Component\Console\Exception\RuntimeException;
|
||||
*/
|
||||
class ArgvInput extends Input
|
||||
{
|
||||
private $tokens;
|
||||
private $parsed;
|
||||
private array $tokens;
|
||||
private array $parsed;
|
||||
|
||||
public function __construct(array $argv = null, InputDefinition $definition = null)
|
||||
{
|
||||
@@ -199,7 +199,7 @@ class ArgvInput extends Input
|
||||
*
|
||||
* @throws RuntimeException When option given doesn't exist
|
||||
*/
|
||||
private function addShortOption(string $shortcut, $value)
|
||||
private function addShortOption(string $shortcut, mixed $value)
|
||||
{
|
||||
if (!$this->definition->hasShortcut($shortcut)) {
|
||||
throw new RuntimeException(sprintf('The "-%s" option does not exist.', $shortcut));
|
||||
@@ -213,7 +213,7 @@ class ArgvInput extends Input
|
||||
*
|
||||
* @throws RuntimeException When option given doesn't exist
|
||||
*/
|
||||
private function addLongOption(string $name, $value)
|
||||
private function addLongOption(string $name, mixed $value)
|
||||
{
|
||||
if (!$this->definition->hasOption($name)) {
|
||||
if (!$this->definition->hasNegation($name)) {
|
||||
@@ -266,7 +266,7 @@ class ArgvInput extends Input
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFirstArgument()
|
||||
public function getFirstArgument(): ?string
|
||||
{
|
||||
$isOption = false;
|
||||
foreach ($this->tokens as $i => $token) {
|
||||
@@ -301,7 +301,7 @@ class ArgvInput extends Input
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasParameterOption($values, bool $onlyParams = false)
|
||||
public function hasParameterOption(string|array $values, bool $onlyParams = false): bool
|
||||
{
|
||||
$values = (array) $values;
|
||||
|
||||
@@ -326,7 +326,7 @@ class ArgvInput extends Input
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getParameterOption($values, $default = false, bool $onlyParams = false)
|
||||
public function getParameterOption(string|array $values, string|bool|int|float|array|null $default = false, bool $onlyParams = false): mixed
|
||||
{
|
||||
$values = (array) $values;
|
||||
$tokens = $this->tokens;
|
||||
@@ -356,10 +356,8 @@ class ArgvInput extends Input
|
||||
|
||||
/**
|
||||
* Returns a stringified representation of the args passed to the command.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
$tokens = array_map(function ($token) {
|
||||
if (preg_match('{^(-[^=]+=)(.+)}', $token, $match)) {
|
||||
|
||||
21
vendor/symfony/console/Input/ArrayInput.php
vendored
21
vendor/symfony/console/Input/ArrayInput.php
vendored
@@ -25,7 +25,7 @@ use Symfony\Component\Console\Exception\InvalidOptionException;
|
||||
*/
|
||||
class ArrayInput extends Input
|
||||
{
|
||||
private $parameters;
|
||||
private array $parameters;
|
||||
|
||||
public function __construct(array $parameters, InputDefinition $definition = null)
|
||||
{
|
||||
@@ -37,7 +37,7 @@ class ArrayInput extends Input
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFirstArgument()
|
||||
public function getFirstArgument(): ?string
|
||||
{
|
||||
foreach ($this->parameters as $param => $value) {
|
||||
if ($param && \is_string($param) && '-' === $param[0]) {
|
||||
@@ -53,7 +53,7 @@ class ArrayInput extends Input
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasParameterOption($values, bool $onlyParams = false)
|
||||
public function hasParameterOption(string|array $values, bool $onlyParams = false): bool
|
||||
{
|
||||
$values = (array) $values;
|
||||
|
||||
@@ -77,7 +77,7 @@ class ArrayInput extends Input
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getParameterOption($values, $default = false, bool $onlyParams = false)
|
||||
public function getParameterOption(string|array $values, string|bool|int|float|array|null $default = false, bool $onlyParams = false): mixed
|
||||
{
|
||||
$values = (array) $values;
|
||||
|
||||
@@ -100,10 +100,8 @@ class ArrayInput extends Input
|
||||
|
||||
/**
|
||||
* Returns a stringified representation of the args passed to the command.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
$params = [];
|
||||
foreach ($this->parameters as $param => $val) {
|
||||
@@ -148,7 +146,7 @@ class ArrayInput extends Input
|
||||
*
|
||||
* @throws InvalidOptionException When option given doesn't exist
|
||||
*/
|
||||
private function addShortOption(string $shortcut, $value)
|
||||
private function addShortOption(string $shortcut, mixed $value)
|
||||
{
|
||||
if (!$this->definition->hasShortcut($shortcut)) {
|
||||
throw new InvalidOptionException(sprintf('The "-%s" option does not exist.', $shortcut));
|
||||
@@ -163,7 +161,7 @@ class ArrayInput extends Input
|
||||
* @throws InvalidOptionException When option given doesn't exist
|
||||
* @throws InvalidOptionException When a required value is missing
|
||||
*/
|
||||
private function addLongOption(string $name, $value)
|
||||
private function addLongOption(string $name, mixed $value)
|
||||
{
|
||||
if (!$this->definition->hasOption($name)) {
|
||||
if (!$this->definition->hasNegation($name)) {
|
||||
@@ -194,12 +192,9 @@ class ArrayInput extends Input
|
||||
/**
|
||||
* Adds an argument value.
|
||||
*
|
||||
* @param string|int $name The argument name
|
||||
* @param mixed $value The value for the argument
|
||||
*
|
||||
* @throws InvalidArgumentException When argument given doesn't exist
|
||||
*/
|
||||
private function addArgument($name, $value)
|
||||
private function addArgument(string|int $name, mixed $value)
|
||||
{
|
||||
if (!$this->definition->hasArgument($name)) {
|
||||
throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
|
||||
|
||||
22
vendor/symfony/console/Input/Input.php
vendored
22
vendor/symfony/console/Input/Input.php
vendored
@@ -80,7 +80,7 @@ abstract class Input implements InputInterface, StreamableInputInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isInteractive()
|
||||
public function isInteractive(): bool
|
||||
{
|
||||
return $this->interactive;
|
||||
}
|
||||
@@ -96,7 +96,7 @@ abstract class Input implements InputInterface, StreamableInputInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getArguments()
|
||||
public function getArguments(): array
|
||||
{
|
||||
return array_merge($this->definition->getArgumentDefaults(), $this->arguments);
|
||||
}
|
||||
@@ -104,7 +104,7 @@ abstract class Input implements InputInterface, StreamableInputInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getArgument(string $name)
|
||||
public function getArgument(string $name): mixed
|
||||
{
|
||||
if (!$this->definition->hasArgument($name)) {
|
||||
throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
|
||||
@@ -116,7 +116,7 @@ abstract class Input implements InputInterface, StreamableInputInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setArgument(string $name, $value)
|
||||
public function setArgument(string $name, mixed $value)
|
||||
{
|
||||
if (!$this->definition->hasArgument($name)) {
|
||||
throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
|
||||
@@ -128,7 +128,7 @@ abstract class Input implements InputInterface, StreamableInputInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasArgument(string $name)
|
||||
public function hasArgument(string $name): bool
|
||||
{
|
||||
return $this->definition->hasArgument($name);
|
||||
}
|
||||
@@ -136,7 +136,7 @@ abstract class Input implements InputInterface, StreamableInputInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getOptions()
|
||||
public function getOptions(): array
|
||||
{
|
||||
return array_merge($this->definition->getOptionDefaults(), $this->options);
|
||||
}
|
||||
@@ -144,7 +144,7 @@ abstract class Input implements InputInterface, StreamableInputInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getOption(string $name)
|
||||
public function getOption(string $name): mixed
|
||||
{
|
||||
if ($this->definition->hasNegation($name)) {
|
||||
if (null === $value = $this->getOption($this->definition->negationToName($name))) {
|
||||
@@ -164,7 +164,7 @@ abstract class Input implements InputInterface, StreamableInputInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setOption(string $name, $value)
|
||||
public function setOption(string $name, mixed $value)
|
||||
{
|
||||
if ($this->definition->hasNegation($name)) {
|
||||
$this->options[$this->definition->negationToName($name)] = !$value;
|
||||
@@ -180,17 +180,15 @@ abstract class Input implements InputInterface, StreamableInputInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasOption(string $name)
|
||||
public function hasOption(string $name): bool
|
||||
{
|
||||
return $this->definition->hasOption($name) || $this->definition->hasNegation($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes a token through escapeshellarg if it contains unsafe chars.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function escapeToken(string $token)
|
||||
public function escapeToken(string $token): string
|
||||
{
|
||||
return preg_match('{^[\w-]+$}', $token) ? $token : escapeshellarg($token);
|
||||
}
|
||||
|
||||
30
vendor/symfony/console/Input/InputArgument.php
vendored
30
vendor/symfony/console/Input/InputArgument.php
vendored
@@ -25,10 +25,10 @@ class InputArgument
|
||||
public const OPTIONAL = 2;
|
||||
public const IS_ARRAY = 4;
|
||||
|
||||
private $name;
|
||||
private $mode;
|
||||
private $default;
|
||||
private $description;
|
||||
private string $name;
|
||||
private int $mode;
|
||||
private string|int|bool|array|null|float $default;
|
||||
private string $description;
|
||||
|
||||
/**
|
||||
* @param string $name The argument name
|
||||
@@ -38,7 +38,7 @@ class InputArgument
|
||||
*
|
||||
* @throws InvalidArgumentException When argument mode is not valid
|
||||
*/
|
||||
public function __construct(string $name, int $mode = null, string $description = '', $default = null)
|
||||
public function __construct(string $name, int $mode = null, string $description = '', string|bool|int|float|array $default = null)
|
||||
{
|
||||
if (null === $mode) {
|
||||
$mode = self::OPTIONAL;
|
||||
@@ -55,10 +55,8 @@ class InputArgument
|
||||
|
||||
/**
|
||||
* Returns the argument name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
@@ -68,7 +66,7 @@ class InputArgument
|
||||
*
|
||||
* @return bool true if parameter mode is self::REQUIRED, false otherwise
|
||||
*/
|
||||
public function isRequired()
|
||||
public function isRequired(): bool
|
||||
{
|
||||
return self::REQUIRED === (self::REQUIRED & $this->mode);
|
||||
}
|
||||
@@ -78,7 +76,7 @@ class InputArgument
|
||||
*
|
||||
* @return bool true if mode is self::IS_ARRAY, false otherwise
|
||||
*/
|
||||
public function isArray()
|
||||
public function isArray(): bool
|
||||
{
|
||||
return self::IS_ARRAY === (self::IS_ARRAY & $this->mode);
|
||||
}
|
||||
@@ -86,11 +84,9 @@ class InputArgument
|
||||
/**
|
||||
* Sets the default value.
|
||||
*
|
||||
* @param string|bool|int|float|array|null $default
|
||||
*
|
||||
* @throws LogicException When incorrect default value is given
|
||||
*/
|
||||
public function setDefault($default = null)
|
||||
public function setDefault(string|bool|int|float|array $default = null)
|
||||
{
|
||||
if ($this->isRequired() && null !== $default) {
|
||||
throw new LogicException('Cannot set a default value except for InputArgument::OPTIONAL mode.');
|
||||
@@ -109,20 +105,16 @@ class InputArgument
|
||||
|
||||
/**
|
||||
* Returns the default value.
|
||||
*
|
||||
* @return string|bool|int|float|array|null
|
||||
*/
|
||||
public function getDefault()
|
||||
public function getDefault(): string|bool|int|float|array|null
|
||||
{
|
||||
return $this->default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the description text.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription()
|
||||
public function getDescription(): string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
62
vendor/symfony/console/Input/InputDefinition.php
vendored
62
vendor/symfony/console/Input/InputDefinition.php
vendored
@@ -28,13 +28,13 @@ use Symfony\Component\Console\Exception\LogicException;
|
||||
*/
|
||||
class InputDefinition
|
||||
{
|
||||
private $arguments;
|
||||
private $requiredCount;
|
||||
private $lastArrayArgument;
|
||||
private $lastOptionalArgument;
|
||||
private $options;
|
||||
private $negations;
|
||||
private $shortcuts;
|
||||
private array $arguments = [];
|
||||
private int $requiredCount = 0;
|
||||
private $lastArrayArgument = null;
|
||||
private $lastOptionalArgument = null;
|
||||
private array $options = [];
|
||||
private array $negations = [];
|
||||
private array $shortcuts = [];
|
||||
|
||||
/**
|
||||
* @param array $definition An array of InputArgument and InputOption instance
|
||||
@@ -124,13 +124,9 @@ class InputDefinition
|
||||
/**
|
||||
* Returns an InputArgument by name or by position.
|
||||
*
|
||||
* @param string|int $name The InputArgument name or position
|
||||
*
|
||||
* @return InputArgument
|
||||
*
|
||||
* @throws InvalidArgumentException When argument given doesn't exist
|
||||
*/
|
||||
public function getArgument($name)
|
||||
public function getArgument(string|int $name): InputArgument
|
||||
{
|
||||
if (!$this->hasArgument($name)) {
|
||||
throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
|
||||
@@ -143,12 +139,8 @@ class InputDefinition
|
||||
|
||||
/**
|
||||
* Returns true if an InputArgument object exists by name or position.
|
||||
*
|
||||
* @param string|int $name The InputArgument name or position
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasArgument($name)
|
||||
public function hasArgument(string|int $name): bool
|
||||
{
|
||||
$arguments = \is_int($name) ? array_values($this->arguments) : $this->arguments;
|
||||
|
||||
@@ -160,27 +152,23 @@ class InputDefinition
|
||||
*
|
||||
* @return InputArgument[]
|
||||
*/
|
||||
public function getArguments()
|
||||
public function getArguments(): array
|
||||
{
|
||||
return $this->arguments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of InputArguments.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getArgumentCount()
|
||||
public function getArgumentCount(): int
|
||||
{
|
||||
return null !== $this->lastArrayArgument ? \PHP_INT_MAX : \count($this->arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of required InputArguments.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getArgumentRequiredCount()
|
||||
public function getArgumentRequiredCount(): int
|
||||
{
|
||||
return $this->requiredCount;
|
||||
}
|
||||
@@ -188,7 +176,7 @@ class InputDefinition
|
||||
/**
|
||||
* @return array<string|bool|int|float|array|null>
|
||||
*/
|
||||
public function getArgumentDefaults()
|
||||
public function getArgumentDefaults(): array
|
||||
{
|
||||
$values = [];
|
||||
foreach ($this->arguments as $argument) {
|
||||
@@ -262,11 +250,9 @@ class InputDefinition
|
||||
/**
|
||||
* Returns an InputOption by name.
|
||||
*
|
||||
* @return InputOption
|
||||
*
|
||||
* @throws InvalidArgumentException When option given doesn't exist
|
||||
*/
|
||||
public function getOption(string $name)
|
||||
public function getOption(string $name): InputOption
|
||||
{
|
||||
if (!$this->hasOption($name)) {
|
||||
throw new InvalidArgumentException(sprintf('The "--%s" option does not exist.', $name));
|
||||
@@ -280,10 +266,8 @@ class InputDefinition
|
||||
*
|
||||
* This method can't be used to check if the user included the option when
|
||||
* executing the command (use getOption() instead).
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasOption(string $name)
|
||||
public function hasOption(string $name): bool
|
||||
{
|
||||
return isset($this->options[$name]);
|
||||
}
|
||||
@@ -293,17 +277,15 @@ class InputDefinition
|
||||
*
|
||||
* @return InputOption[]
|
||||
*/
|
||||
public function getOptions()
|
||||
public function getOptions(): array
|
||||
{
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if an InputOption object exists by shortcut.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasShortcut(string $name)
|
||||
public function hasShortcut(string $name): bool
|
||||
{
|
||||
return isset($this->shortcuts[$name]);
|
||||
}
|
||||
@@ -318,10 +300,8 @@ class InputDefinition
|
||||
|
||||
/**
|
||||
* Gets an InputOption by shortcut.
|
||||
*
|
||||
* @return InputOption
|
||||
*/
|
||||
public function getOptionForShortcut(string $shortcut)
|
||||
public function getOptionForShortcut(string $shortcut): InputOption
|
||||
{
|
||||
return $this->getOption($this->shortcutToName($shortcut));
|
||||
}
|
||||
@@ -329,7 +309,7 @@ class InputDefinition
|
||||
/**
|
||||
* @return array<string|bool|int|float|array|null>
|
||||
*/
|
||||
public function getOptionDefaults()
|
||||
public function getOptionDefaults(): array
|
||||
{
|
||||
$values = [];
|
||||
foreach ($this->options as $option) {
|
||||
@@ -373,10 +353,8 @@ class InputDefinition
|
||||
|
||||
/**
|
||||
* Gets the synopsis.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSynopsis(bool $short = false)
|
||||
public function getSynopsis(bool $short = false): string
|
||||
{
|
||||
$elements = [];
|
||||
|
||||
|
||||
34
vendor/symfony/console/Input/InputInterface.php
vendored
34
vendor/symfony/console/Input/InputInterface.php
vendored
@@ -23,10 +23,8 @@ interface InputInterface
|
||||
{
|
||||
/**
|
||||
* Returns the first argument from the raw parameters (not parsed).
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getFirstArgument();
|
||||
public function getFirstArgument(): ?string;
|
||||
|
||||
/**
|
||||
* Returns true if the raw parameters (not parsed) contain a value.
|
||||
@@ -38,10 +36,8 @@ interface InputInterface
|
||||
*
|
||||
* @param string|array $values The values to look for in the raw parameters (can be an array)
|
||||
* @param bool $onlyParams Only check real parameters, skip those following an end of options (--) signal
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasParameterOption($values, bool $onlyParams = false);
|
||||
public function hasParameterOption(string|array $values, bool $onlyParams = false): bool;
|
||||
|
||||
/**
|
||||
* Returns the value of a raw option (not parsed).
|
||||
@@ -57,7 +53,7 @@ interface InputInterface
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getParameterOption($values, $default = false, bool $onlyParams = false);
|
||||
public function getParameterOption(string|array $values, string|bool|int|float|array|null $default = false, bool $onlyParams = false);
|
||||
|
||||
/**
|
||||
* Binds the current Input instance with the given arguments and options.
|
||||
@@ -78,7 +74,7 @@ interface InputInterface
|
||||
*
|
||||
* @return array<string|bool|int|float|array|null>
|
||||
*/
|
||||
public function getArguments();
|
||||
public function getArguments(): array;
|
||||
|
||||
/**
|
||||
* Returns the argument value for a given argument name.
|
||||
@@ -92,25 +88,21 @@ interface InputInterface
|
||||
/**
|
||||
* Sets an argument value by name.
|
||||
*
|
||||
* @param mixed $value The argument value
|
||||
*
|
||||
* @throws InvalidArgumentException When argument given doesn't exist
|
||||
*/
|
||||
public function setArgument(string $name, $value);
|
||||
public function setArgument(string $name, mixed $value);
|
||||
|
||||
/**
|
||||
* Returns true if an InputArgument object exists by name or position.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasArgument(string $name);
|
||||
public function hasArgument(string $name): bool;
|
||||
|
||||
/**
|
||||
* Returns all the given options merged with the default values.
|
||||
*
|
||||
* @return array<string|bool|int|float|array|null>
|
||||
*/
|
||||
public function getOptions();
|
||||
public function getOptions(): array;
|
||||
|
||||
/**
|
||||
* Returns the option value for a given option name.
|
||||
@@ -124,25 +116,19 @@ interface InputInterface
|
||||
/**
|
||||
* Sets an option value by name.
|
||||
*
|
||||
* @param mixed $value The option value
|
||||
*
|
||||
* @throws InvalidArgumentException When option given doesn't exist
|
||||
*/
|
||||
public function setOption(string $name, $value);
|
||||
public function setOption(string $name, mixed $value);
|
||||
|
||||
/**
|
||||
* Returns true if an InputOption object exists by name.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasOption(string $name);
|
||||
public function hasOption(string $name): bool;
|
||||
|
||||
/**
|
||||
* Is this input means interactive?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isInteractive();
|
||||
public function isInteractive(): bool;
|
||||
|
||||
/**
|
||||
* Sets the input interactivity.
|
||||
|
||||
45
vendor/symfony/console/Input/InputOption.php
vendored
45
vendor/symfony/console/Input/InputOption.php
vendored
@@ -46,11 +46,11 @@ class InputOption
|
||||
*/
|
||||
public const VALUE_NEGATABLE = 16;
|
||||
|
||||
private $name;
|
||||
private $shortcut;
|
||||
private $mode;
|
||||
private $default;
|
||||
private $description;
|
||||
private string $name;
|
||||
private string|array|null $shortcut;
|
||||
private int $mode;
|
||||
private string|int|bool|array|null|float $default;
|
||||
private string $description;
|
||||
|
||||
/**
|
||||
* @param string|array|null $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
|
||||
@@ -59,7 +59,7 @@ class InputOption
|
||||
*
|
||||
* @throws InvalidArgumentException If option mode is invalid or incompatible
|
||||
*/
|
||||
public function __construct(string $name, $shortcut = null, int $mode = null, string $description = '', $default = null)
|
||||
public function __construct(string $name, string|array $shortcut = null, int $mode = null, string $description = '', string|bool|int|float|array $default = null)
|
||||
{
|
||||
if (str_starts_with($name, '--')) {
|
||||
$name = substr($name, 2);
|
||||
@@ -109,20 +109,16 @@ class InputOption
|
||||
|
||||
/**
|
||||
* Returns the option shortcut.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getShortcut()
|
||||
public function getShortcut(): ?string
|
||||
{
|
||||
return $this->shortcut;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the option name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
@@ -132,7 +128,7 @@ class InputOption
|
||||
*
|
||||
* @return bool true if value mode is not self::VALUE_NONE, false otherwise
|
||||
*/
|
||||
public function acceptValue()
|
||||
public function acceptValue(): bool
|
||||
{
|
||||
return $this->isValueRequired() || $this->isValueOptional();
|
||||
}
|
||||
@@ -142,7 +138,7 @@ class InputOption
|
||||
*
|
||||
* @return bool true if value mode is self::VALUE_REQUIRED, false otherwise
|
||||
*/
|
||||
public function isValueRequired()
|
||||
public function isValueRequired(): bool
|
||||
{
|
||||
return self::VALUE_REQUIRED === (self::VALUE_REQUIRED & $this->mode);
|
||||
}
|
||||
@@ -152,7 +148,7 @@ class InputOption
|
||||
*
|
||||
* @return bool true if value mode is self::VALUE_OPTIONAL, false otherwise
|
||||
*/
|
||||
public function isValueOptional()
|
||||
public function isValueOptional(): bool
|
||||
{
|
||||
return self::VALUE_OPTIONAL === (self::VALUE_OPTIONAL & $this->mode);
|
||||
}
|
||||
@@ -162,7 +158,7 @@ class InputOption
|
||||
*
|
||||
* @return bool true if mode is self::VALUE_IS_ARRAY, false otherwise
|
||||
*/
|
||||
public function isArray()
|
||||
public function isArray(): bool
|
||||
{
|
||||
return self::VALUE_IS_ARRAY === (self::VALUE_IS_ARRAY & $this->mode);
|
||||
}
|
||||
@@ -172,10 +168,7 @@ class InputOption
|
||||
return self::VALUE_NEGATABLE === (self::VALUE_NEGATABLE & $this->mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|bool|int|float|array|null $default
|
||||
*/
|
||||
public function setDefault($default = null)
|
||||
public function setDefault(string|bool|int|float|array $default = null)
|
||||
{
|
||||
if (self::VALUE_NONE === (self::VALUE_NONE & $this->mode) && null !== $default) {
|
||||
throw new LogicException('Cannot set a default value when using InputOption::VALUE_NONE mode.');
|
||||
@@ -194,30 +187,24 @@ class InputOption
|
||||
|
||||
/**
|
||||
* Returns the default value.
|
||||
*
|
||||
* @return string|bool|int|float|array|null
|
||||
*/
|
||||
public function getDefault()
|
||||
public function getDefault(): string|bool|int|float|array|null
|
||||
{
|
||||
return $this->default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the description text.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription()
|
||||
public function getDescription(): string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the given option equals this one.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function equals(self $option)
|
||||
public function equals(self $option): bool
|
||||
{
|
||||
return $option->getName() === $this->getName()
|
||||
&& $option->getShortcut() === $this->getShortcut()
|
||||
|
||||
16
vendor/symfony/console/Logger/ConsoleLogger.php
vendored
16
vendor/symfony/console/Logger/ConsoleLogger.php
vendored
@@ -30,7 +30,7 @@ class ConsoleLogger extends AbstractLogger
|
||||
public const ERROR = 'error';
|
||||
|
||||
private $output;
|
||||
private $verbosityLevelMap = [
|
||||
private array $verbosityLevelMap = [
|
||||
LogLevel::EMERGENCY => OutputInterface::VERBOSITY_NORMAL,
|
||||
LogLevel::ALERT => OutputInterface::VERBOSITY_NORMAL,
|
||||
LogLevel::CRITICAL => OutputInterface::VERBOSITY_NORMAL,
|
||||
@@ -40,7 +40,7 @@ class ConsoleLogger extends AbstractLogger
|
||||
LogLevel::INFO => OutputInterface::VERBOSITY_VERY_VERBOSE,
|
||||
LogLevel::DEBUG => OutputInterface::VERBOSITY_DEBUG,
|
||||
];
|
||||
private $formatLevelMap = [
|
||||
private array $formatLevelMap = [
|
||||
LogLevel::EMERGENCY => self::ERROR,
|
||||
LogLevel::ALERT => self::ERROR,
|
||||
LogLevel::CRITICAL => self::ERROR,
|
||||
@@ -50,7 +50,7 @@ class ConsoleLogger extends AbstractLogger
|
||||
LogLevel::INFO => self::INFO,
|
||||
LogLevel::DEBUG => self::INFO,
|
||||
];
|
||||
private $errored = false;
|
||||
private bool $errored = false;
|
||||
|
||||
public function __construct(OutputInterface $output, array $verbosityLevelMap = [], array $formatLevelMap = [])
|
||||
{
|
||||
@@ -61,10 +61,8 @@ class ConsoleLogger extends AbstractLogger
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function log($level, $message, array $context = [])
|
||||
public function log($level, $message, array $context = []): void
|
||||
{
|
||||
if (!isset($this->verbosityLevelMap[$level])) {
|
||||
throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level));
|
||||
@@ -89,10 +87,8 @@ class ConsoleLogger extends AbstractLogger
|
||||
|
||||
/**
|
||||
* Returns true when any messages have been logged at error levels.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasErrored()
|
||||
public function hasErrored(): bool
|
||||
{
|
||||
return $this->errored;
|
||||
}
|
||||
@@ -110,7 +106,7 @@ class ConsoleLogger extends AbstractLogger
|
||||
|
||||
$replacements = [];
|
||||
foreach ($context as $key => $val) {
|
||||
if (null === $val || \is_scalar($val) || (\is_object($val) && method_exists($val, '__toString'))) {
|
||||
if (null === $val || \is_scalar($val) || $val instanceof \Stringable) {
|
||||
$replacements["{{$key}}"] = $val;
|
||||
} elseif ($val instanceof \DateTimeInterface) {
|
||||
$replacements["{{$key}}"] = $val->format(\DateTime::RFC3339);
|
||||
|
||||
@@ -16,14 +16,12 @@ namespace Symfony\Component\Console\Output;
|
||||
*/
|
||||
class BufferedOutput extends Output
|
||||
{
|
||||
private $buffer = '';
|
||||
private string $buffer = '';
|
||||
|
||||
/**
|
||||
* Empties buffer and returns its content.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function fetch()
|
||||
public function fetch(): string
|
||||
{
|
||||
$content = $this->buffer;
|
||||
$this->buffer = '';
|
||||
|
||||
12
vendor/symfony/console/Output/ConsoleOutput.php
vendored
12
vendor/symfony/console/Output/ConsoleOutput.php
vendored
@@ -30,7 +30,7 @@ use Symfony\Component\Console\Formatter\OutputFormatterInterface;
|
||||
class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface
|
||||
{
|
||||
private $stderr;
|
||||
private $consoleSectionOutputs = [];
|
||||
private array $consoleSectionOutputs = [];
|
||||
|
||||
/**
|
||||
* @param int $verbosity The verbosity level (one of the VERBOSITY constants in OutputInterface)
|
||||
@@ -94,7 +94,7 @@ class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getErrorOutput()
|
||||
public function getErrorOutput(): OutputInterface
|
||||
{
|
||||
return $this->stderr;
|
||||
}
|
||||
@@ -110,10 +110,8 @@ class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface
|
||||
/**
|
||||
* Returns true if current environment supports writing console output to
|
||||
* STDOUT.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function hasStdoutSupport()
|
||||
protected function hasStdoutSupport(): bool
|
||||
{
|
||||
return false === $this->isRunningOS400();
|
||||
}
|
||||
@@ -121,10 +119,8 @@ class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface
|
||||
/**
|
||||
* Returns true if current environment supports writing console output to
|
||||
* STDERR.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function hasStderrSupport()
|
||||
protected function hasStderrSupport(): bool
|
||||
{
|
||||
return false === $this->isRunningOS400();
|
||||
}
|
||||
|
||||
@@ -21,10 +21,8 @@ interface ConsoleOutputInterface extends OutputInterface
|
||||
{
|
||||
/**
|
||||
* Gets the OutputInterface for errors.
|
||||
*
|
||||
* @return OutputInterface
|
||||
*/
|
||||
public function getErrorOutput();
|
||||
public function getErrorOutput(): OutputInterface;
|
||||
|
||||
public function setErrorOutput(OutputInterface $error);
|
||||
|
||||
|
||||
@@ -21,9 +21,9 @@ use Symfony\Component\Console\Terminal;
|
||||
*/
|
||||
class ConsoleSectionOutput extends StreamOutput
|
||||
{
|
||||
private $content = [];
|
||||
private $lines = 0;
|
||||
private $sections;
|
||||
private array $content = [];
|
||||
private int $lines = 0;
|
||||
private array $sections;
|
||||
private $terminal;
|
||||
|
||||
/**
|
||||
@@ -63,10 +63,8 @@ class ConsoleSectionOutput extends StreamOutput
|
||||
|
||||
/**
|
||||
* Overwrites the previous output with a new message.
|
||||
*
|
||||
* @param array|string $message
|
||||
*/
|
||||
public function overwrite($message)
|
||||
public function overwrite(string|iterable $message)
|
||||
{
|
||||
$this->clear();
|
||||
$this->writeln($message);
|
||||
|
||||
23
vendor/symfony/console/Output/NullOutput.php
vendored
23
vendor/symfony/console/Output/NullOutput.php
vendored
@@ -37,13 +37,10 @@ class NullOutput implements OutputInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFormatter()
|
||||
public function getFormatter(): OutputFormatterInterface
|
||||
{
|
||||
if ($this->formatter) {
|
||||
return $this->formatter;
|
||||
}
|
||||
// to comply with the interface we must return a OutputFormatterInterface
|
||||
return $this->formatter = new NullOutputFormatter();
|
||||
return $this->formatter ??= new NullOutputFormatter();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,7 +54,7 @@ class NullOutput implements OutputInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isDecorated()
|
||||
public function isDecorated(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -73,7 +70,7 @@ class NullOutput implements OutputInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getVerbosity()
|
||||
public function getVerbosity(): int
|
||||
{
|
||||
return self::VERBOSITY_QUIET;
|
||||
}
|
||||
@@ -81,7 +78,7 @@ class NullOutput implements OutputInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isQuiet()
|
||||
public function isQuiet(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -89,7 +86,7 @@ class NullOutput implements OutputInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isVerbose()
|
||||
public function isVerbose(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -97,7 +94,7 @@ class NullOutput implements OutputInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isVeryVerbose()
|
||||
public function isVeryVerbose(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -105,7 +102,7 @@ class NullOutput implements OutputInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isDebug()
|
||||
public function isDebug(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -113,7 +110,7 @@ class NullOutput implements OutputInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function writeln($messages, int $options = self::OUTPUT_NORMAL)
|
||||
public function writeln(string|iterable $messages, int $options = self::OUTPUT_NORMAL)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
@@ -121,7 +118,7 @@ class NullOutput implements OutputInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function write($messages, bool $newline = false, int $options = self::OUTPUT_NORMAL)
|
||||
public function write(string|iterable $messages, bool $newline = false, int $options = self::OUTPUT_NORMAL)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
20
vendor/symfony/console/Output/Output.php
vendored
20
vendor/symfony/console/Output/Output.php
vendored
@@ -29,7 +29,7 @@ use Symfony\Component\Console\Formatter\OutputFormatterInterface;
|
||||
*/
|
||||
abstract class Output implements OutputInterface
|
||||
{
|
||||
private $verbosity;
|
||||
private int $verbosity;
|
||||
private $formatter;
|
||||
|
||||
/**
|
||||
@@ -55,7 +55,7 @@ abstract class Output implements OutputInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFormatter()
|
||||
public function getFormatter(): OutputFormatterInterface
|
||||
{
|
||||
return $this->formatter;
|
||||
}
|
||||
@@ -71,7 +71,7 @@ abstract class Output implements OutputInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isDecorated()
|
||||
public function isDecorated(): bool
|
||||
{
|
||||
return $this->formatter->isDecorated();
|
||||
}
|
||||
@@ -87,7 +87,7 @@ abstract class Output implements OutputInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getVerbosity()
|
||||
public function getVerbosity(): int
|
||||
{
|
||||
return $this->verbosity;
|
||||
}
|
||||
@@ -95,7 +95,7 @@ abstract class Output implements OutputInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isQuiet()
|
||||
public function isQuiet(): bool
|
||||
{
|
||||
return self::VERBOSITY_QUIET === $this->verbosity;
|
||||
}
|
||||
@@ -103,7 +103,7 @@ abstract class Output implements OutputInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isVerbose()
|
||||
public function isVerbose(): bool
|
||||
{
|
||||
return self::VERBOSITY_VERBOSE <= $this->verbosity;
|
||||
}
|
||||
@@ -111,7 +111,7 @@ abstract class Output implements OutputInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isVeryVerbose()
|
||||
public function isVeryVerbose(): bool
|
||||
{
|
||||
return self::VERBOSITY_VERY_VERBOSE <= $this->verbosity;
|
||||
}
|
||||
@@ -119,7 +119,7 @@ abstract class Output implements OutputInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isDebug()
|
||||
public function isDebug(): bool
|
||||
{
|
||||
return self::VERBOSITY_DEBUG <= $this->verbosity;
|
||||
}
|
||||
@@ -127,7 +127,7 @@ abstract class Output implements OutputInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function writeln($messages, int $options = self::OUTPUT_NORMAL)
|
||||
public function writeln(string|iterable $messages, int $options = self::OUTPUT_NORMAL)
|
||||
{
|
||||
$this->write($messages, true, $options);
|
||||
}
|
||||
@@ -135,7 +135,7 @@ abstract class Output implements OutputInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function write($messages, bool $newline = false, int $options = self::OUTPUT_NORMAL)
|
||||
public function write(string|iterable $messages, bool $newline = false, int $options = self::OUTPUT_NORMAL)
|
||||
{
|
||||
if (!is_iterable($messages)) {
|
||||
$messages = [$messages];
|
||||
|
||||
@@ -33,19 +33,17 @@ interface OutputInterface
|
||||
/**
|
||||
* Writes a message to the output.
|
||||
*
|
||||
* @param string|iterable $messages The message as an iterable of strings or a single string
|
||||
* @param bool $newline Whether to add a newline
|
||||
* @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL
|
||||
* @param $newline Whether to add a newline
|
||||
* @param $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL
|
||||
*/
|
||||
public function write($messages, bool $newline = false, int $options = 0);
|
||||
public function write(string|iterable $messages, bool $newline = false, int $options = 0);
|
||||
|
||||
/**
|
||||
* Writes a message to the output and adds a newline at the end.
|
||||
*
|
||||
* @param string|iterable $messages The message as an iterable of strings or a single string
|
||||
* @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL
|
||||
* @param $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL
|
||||
*/
|
||||
public function writeln($messages, int $options = 0);
|
||||
public function writeln(string|iterable $messages, int $options = 0);
|
||||
|
||||
/**
|
||||
* Sets the verbosity of the output.
|
||||
@@ -54,38 +52,28 @@ interface OutputInterface
|
||||
|
||||
/**
|
||||
* Gets the current verbosity of the output.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getVerbosity();
|
||||
public function getVerbosity(): int;
|
||||
|
||||
/**
|
||||
* Returns whether verbosity is quiet (-q).
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isQuiet();
|
||||
public function isQuiet(): bool;
|
||||
|
||||
/**
|
||||
* Returns whether verbosity is verbose (-v).
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isVerbose();
|
||||
public function isVerbose(): bool;
|
||||
|
||||
/**
|
||||
* Returns whether verbosity is very verbose (-vv).
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isVeryVerbose();
|
||||
public function isVeryVerbose(): bool;
|
||||
|
||||
/**
|
||||
* Returns whether verbosity is debug (-vvv).
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isDebug();
|
||||
public function isDebug(): bool;
|
||||
|
||||
/**
|
||||
* Sets the decorated flag.
|
||||
@@ -94,17 +82,13 @@ interface OutputInterface
|
||||
|
||||
/**
|
||||
* Gets the decorated flag.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isDecorated();
|
||||
public function isDecorated(): bool;
|
||||
|
||||
public function setFormatter(OutputFormatterInterface $formatter);
|
||||
|
||||
/**
|
||||
* Returns current output formatter instance.
|
||||
*
|
||||
* @return OutputFormatterInterface
|
||||
*/
|
||||
public function getFormatter();
|
||||
public function getFormatter(): OutputFormatterInterface;
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ class StreamOutput extends Output
|
||||
*
|
||||
* @return bool true if the stream supports colorization, false otherwise
|
||||
*/
|
||||
protected function hasColorSupport()
|
||||
protected function hasColorSupport(): bool
|
||||
{
|
||||
// Follow https://no-color.org/
|
||||
if (isset($_SERVER['NO_COLOR']) || false !== getenv('NO_COLOR')) {
|
||||
|
||||
@@ -21,8 +21,8 @@ use Symfony\Component\Console\Formatter\OutputFormatterInterface;
|
||||
*/
|
||||
class TrimmedBufferOutput extends Output
|
||||
{
|
||||
private $maxLength;
|
||||
private $buffer = '';
|
||||
private int $maxLength;
|
||||
private string $buffer = '';
|
||||
|
||||
public function __construct(int $maxLength, ?int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = false, OutputFormatterInterface $formatter = null)
|
||||
{
|
||||
@@ -36,10 +36,8 @@ class TrimmedBufferOutput extends Output
|
||||
|
||||
/**
|
||||
* Empties buffer and returns its content.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function fetch()
|
||||
public function fetch(): string
|
||||
{
|
||||
$content = $this->buffer;
|
||||
$this->buffer = '';
|
||||
|
||||
@@ -20,17 +20,17 @@ use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||
*/
|
||||
class ChoiceQuestion extends Question
|
||||
{
|
||||
private $choices;
|
||||
private $multiselect = false;
|
||||
private $prompt = ' > ';
|
||||
private $errorMessage = 'Value "%s" is invalid';
|
||||
private array $choices;
|
||||
private bool $multiselect = false;
|
||||
private string $prompt = ' > ';
|
||||
private string $errorMessage = 'Value "%s" is invalid';
|
||||
|
||||
/**
|
||||
* @param string $question The question to ask to the user
|
||||
* @param array $choices The list of available choices
|
||||
* @param mixed $default The default answer to return
|
||||
*/
|
||||
public function __construct(string $question, array $choices, $default = null)
|
||||
public function __construct(string $question, array $choices, mixed $default = null)
|
||||
{
|
||||
if (!$choices) {
|
||||
throw new \LogicException('Choice question must have at least 1 choice available.');
|
||||
@@ -45,10 +45,8 @@ class ChoiceQuestion extends Question
|
||||
|
||||
/**
|
||||
* Returns available choices.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getChoices()
|
||||
public function getChoices(): array
|
||||
{
|
||||
return $this->choices;
|
||||
}
|
||||
@@ -60,7 +58,7 @@ class ChoiceQuestion extends Question
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMultiselect(bool $multiselect)
|
||||
public function setMultiselect(bool $multiselect): static
|
||||
{
|
||||
$this->multiselect = $multiselect;
|
||||
$this->setValidator($this->getDefaultValidator());
|
||||
@@ -70,20 +68,16 @@ class ChoiceQuestion extends Question
|
||||
|
||||
/**
|
||||
* Returns whether the choices are multiselect.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isMultiselect()
|
||||
public function isMultiselect(): bool
|
||||
{
|
||||
return $this->multiselect;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the prompt for choices.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPrompt()
|
||||
public function getPrompt(): string
|
||||
{
|
||||
return $this->prompt;
|
||||
}
|
||||
@@ -93,7 +87,7 @@ class ChoiceQuestion extends Question
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPrompt(string $prompt)
|
||||
public function setPrompt(string $prompt): static
|
||||
{
|
||||
$this->prompt = $prompt;
|
||||
|
||||
@@ -107,7 +101,7 @@ class ChoiceQuestion extends Question
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setErrorMessage(string $errorMessage)
|
||||
public function setErrorMessage(string $errorMessage): static
|
||||
{
|
||||
$this->errorMessage = $errorMessage;
|
||||
$this->setValidator($this->getDefaultValidator());
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Symfony\Component\Console\Question;
|
||||
*/
|
||||
class ConfirmationQuestion extends Question
|
||||
{
|
||||
private $trueAnswerRegex;
|
||||
private string $trueAnswerRegex;
|
||||
|
||||
/**
|
||||
* @param string $question The question to ask to the user
|
||||
|
||||
78
vendor/symfony/console/Question/Question.php
vendored
78
vendor/symfony/console/Question/Question.php
vendored
@@ -21,22 +21,22 @@ use Symfony\Component\Console\Exception\LogicException;
|
||||
*/
|
||||
class Question
|
||||
{
|
||||
private $question;
|
||||
private $attempts;
|
||||
private $hidden = false;
|
||||
private $hiddenFallback = true;
|
||||
private $autocompleterCallback;
|
||||
private $validator;
|
||||
private $default;
|
||||
private $normalizer;
|
||||
private $trimmable = true;
|
||||
private $multiline = false;
|
||||
private string $question;
|
||||
private ?int $attempts = null;
|
||||
private bool $hidden = false;
|
||||
private bool $hiddenFallback = true;
|
||||
private ?\Closure $autocompleterCallback = null;
|
||||
private ?\Closure $validator = null;
|
||||
private string|int|bool|null|float $default;
|
||||
private ?\Closure $normalizer = null;
|
||||
private bool $trimmable = true;
|
||||
private bool $multiline = false;
|
||||
|
||||
/**
|
||||
* @param string $question The question to ask to the user
|
||||
* @param string|bool|int|float|null $default The default answer to return if the user enters nothing
|
||||
*/
|
||||
public function __construct(string $question, $default = null)
|
||||
public function __construct(string $question, string|bool|int|float $default = null)
|
||||
{
|
||||
$this->question = $question;
|
||||
$this->default = $default;
|
||||
@@ -44,20 +44,16 @@ class Question
|
||||
|
||||
/**
|
||||
* Returns the question.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getQuestion()
|
||||
public function getQuestion(): string
|
||||
{
|
||||
return $this->question;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default answer.
|
||||
*
|
||||
* @return string|bool|int|float|null
|
||||
*/
|
||||
public function getDefault()
|
||||
public function getDefault(): string|bool|int|float|null
|
||||
{
|
||||
return $this->default;
|
||||
}
|
||||
@@ -75,7 +71,7 @@ class Question
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMultiline(bool $multiline): self
|
||||
public function setMultiline(bool $multiline): static
|
||||
{
|
||||
$this->multiline = $multiline;
|
||||
|
||||
@@ -84,10 +80,8 @@ class Question
|
||||
|
||||
/**
|
||||
* Returns whether the user response must be hidden.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isHidden()
|
||||
public function isHidden(): bool
|
||||
{
|
||||
return $this->hidden;
|
||||
}
|
||||
@@ -99,7 +93,7 @@ class Question
|
||||
*
|
||||
* @throws LogicException In case the autocompleter is also used
|
||||
*/
|
||||
public function setHidden(bool $hidden)
|
||||
public function setHidden(bool $hidden): static
|
||||
{
|
||||
if ($this->autocompleterCallback) {
|
||||
throw new LogicException('A hidden question cannot use the autocompleter.');
|
||||
@@ -112,10 +106,8 @@ class Question
|
||||
|
||||
/**
|
||||
* In case the response cannot be hidden, whether to fallback on non-hidden question or not.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isHiddenFallback()
|
||||
public function isHiddenFallback(): bool
|
||||
{
|
||||
return $this->hiddenFallback;
|
||||
}
|
||||
@@ -125,7 +117,7 @@ class Question
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setHiddenFallback(bool $fallback)
|
||||
public function setHiddenFallback(bool $fallback): static
|
||||
{
|
||||
$this->hiddenFallback = $fallback;
|
||||
|
||||
@@ -134,10 +126,8 @@ class Question
|
||||
|
||||
/**
|
||||
* Gets values for the autocompleter.
|
||||
*
|
||||
* @return iterable|null
|
||||
*/
|
||||
public function getAutocompleterValues()
|
||||
public function getAutocompleterValues(): ?iterable
|
||||
{
|
||||
$callback = $this->getAutocompleterCallback();
|
||||
|
||||
@@ -151,7 +141,7 @@ class Question
|
||||
*
|
||||
* @throws LogicException
|
||||
*/
|
||||
public function setAutocompleterValues(?iterable $values)
|
||||
public function setAutocompleterValues(?iterable $values): static
|
||||
{
|
||||
if (\is_array($values)) {
|
||||
$values = $this->isAssoc($values) ? array_merge(array_keys($values), array_values($values)) : array_values($values);
|
||||
@@ -186,13 +176,13 @@ class Question
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setAutocompleterCallback(callable $callback = null): self
|
||||
public function setAutocompleterCallback(callable $callback = null): static
|
||||
{
|
||||
if ($this->hidden && null !== $callback) {
|
||||
throw new LogicException('A hidden question cannot use the autocompleter.');
|
||||
}
|
||||
|
||||
$this->autocompleterCallback = $callback;
|
||||
$this->autocompleterCallback = null === $callback || $callback instanceof \Closure ? $callback : \Closure::fromCallable($callback);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -202,19 +192,17 @@ class Question
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setValidator(callable $validator = null)
|
||||
public function setValidator(callable $validator = null): static
|
||||
{
|
||||
$this->validator = $validator;
|
||||
$this->validator = null === $validator || $validator instanceof \Closure ? $validator : \Closure::fromCallable($validator);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the validator for the question.
|
||||
*
|
||||
* @return callable|null
|
||||
*/
|
||||
public function getValidator()
|
||||
public function getValidator(): ?callable
|
||||
{
|
||||
return $this->validator;
|
||||
}
|
||||
@@ -228,7 +216,7 @@ class Question
|
||||
*
|
||||
* @throws InvalidArgumentException in case the number of attempts is invalid
|
||||
*/
|
||||
public function setMaxAttempts(?int $attempts)
|
||||
public function setMaxAttempts(?int $attempts): static
|
||||
{
|
||||
if (null !== $attempts && $attempts < 1) {
|
||||
throw new InvalidArgumentException('Maximum number of attempts must be a positive value.');
|
||||
@@ -243,10 +231,8 @@ class Question
|
||||
* Gets the maximum number of attempts.
|
||||
*
|
||||
* Null means an unlimited number of attempts.
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getMaxAttempts()
|
||||
public function getMaxAttempts(): ?int
|
||||
{
|
||||
return $this->attempts;
|
||||
}
|
||||
@@ -258,9 +244,9 @@ class Question
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setNormalizer(callable $normalizer)
|
||||
public function setNormalizer(callable $normalizer): static
|
||||
{
|
||||
$this->normalizer = $normalizer;
|
||||
$this->normalizer = $normalizer instanceof \Closure ? $normalizer : \Closure::fromCallable($normalizer);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -269,10 +255,8 @@ class Question
|
||||
* Gets the normalizer for the response.
|
||||
*
|
||||
* The normalizer can ba a callable (a string), a closure or a class implementing __invoke.
|
||||
*
|
||||
* @return callable|null
|
||||
*/
|
||||
public function getNormalizer()
|
||||
public function getNormalizer(): ?callable
|
||||
{
|
||||
return $this->normalizer;
|
||||
}
|
||||
@@ -290,7 +274,7 @@ class Question
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setTrimmable(bool $trimmable): self
|
||||
public function setTrimmable(bool $trimmable): static
|
||||
{
|
||||
$this->trimmable = $trimmable;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ _sf_{{ COMMAND_NAME }}() {
|
||||
local cur prev words cword
|
||||
_get_comp_words_by_ref -n := cur prev words cword
|
||||
|
||||
local completecmd=("$sf_cmd" "_complete" "-sbash" "-c$cword" "-S{{ VERSION }}")
|
||||
local completecmd=("$sf_cmd" "_complete" "--no-interaction" "-sbash" "-c$cword" "-S{{ VERSION }}")
|
||||
for w in ${words[@]}; do
|
||||
w=$(printf -- '%b' "$w")
|
||||
# remove quotes from typed values
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Symfony\Component\Console\SignalRegistry;
|
||||
|
||||
final class SignalRegistry
|
||||
{
|
||||
private $signalHandlers = [];
|
||||
private array $signalHandlers = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
@@ -20,14 +20,14 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
*/
|
||||
class SingleCommandApplication extends Command
|
||||
{
|
||||
private $version = 'UNKNOWN';
|
||||
private $autoExit = true;
|
||||
private $running = false;
|
||||
private string $version = 'UNKNOWN';
|
||||
private bool $autoExit = true;
|
||||
private bool $running = false;
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setVersion(string $version): self
|
||||
public function setVersion(string $version): static
|
||||
{
|
||||
$this->version = $version;
|
||||
|
||||
@@ -39,7 +39,7 @@ class SingleCommandApplication extends Command
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setAutoExit(bool $autoExit): self
|
||||
public function setAutoExit(bool $autoExit): static
|
||||
{
|
||||
$this->autoExit = $autoExit;
|
||||
|
||||
|
||||
23
vendor/symfony/console/Style/OutputStyle.php
vendored
23
vendor/symfony/console/Style/OutputStyle.php
vendored
@@ -38,10 +38,7 @@ abstract class OutputStyle implements OutputInterface, StyleInterface
|
||||
$this->output->write(str_repeat(\PHP_EOL, $count));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ProgressBar
|
||||
*/
|
||||
public function createProgressBar(int $max = 0)
|
||||
public function createProgressBar(int $max = 0): ProgressBar
|
||||
{
|
||||
return new ProgressBar($this->output, $max);
|
||||
}
|
||||
@@ -49,7 +46,7 @@ abstract class OutputStyle implements OutputInterface, StyleInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function write($messages, bool $newline = false, int $type = self::OUTPUT_NORMAL)
|
||||
public function write(string|iterable $messages, bool $newline = false, int $type = self::OUTPUT_NORMAL)
|
||||
{
|
||||
$this->output->write($messages, $newline, $type);
|
||||
}
|
||||
@@ -57,7 +54,7 @@ abstract class OutputStyle implements OutputInterface, StyleInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function writeln($messages, int $type = self::OUTPUT_NORMAL)
|
||||
public function writeln(string|iterable $messages, int $type = self::OUTPUT_NORMAL)
|
||||
{
|
||||
$this->output->writeln($messages, $type);
|
||||
}
|
||||
@@ -73,7 +70,7 @@ abstract class OutputStyle implements OutputInterface, StyleInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getVerbosity()
|
||||
public function getVerbosity(): int
|
||||
{
|
||||
return $this->output->getVerbosity();
|
||||
}
|
||||
@@ -89,7 +86,7 @@ abstract class OutputStyle implements OutputInterface, StyleInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isDecorated()
|
||||
public function isDecorated(): bool
|
||||
{
|
||||
return $this->output->isDecorated();
|
||||
}
|
||||
@@ -105,7 +102,7 @@ abstract class OutputStyle implements OutputInterface, StyleInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFormatter()
|
||||
public function getFormatter(): OutputFormatterInterface
|
||||
{
|
||||
return $this->output->getFormatter();
|
||||
}
|
||||
@@ -113,7 +110,7 @@ abstract class OutputStyle implements OutputInterface, StyleInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isQuiet()
|
||||
public function isQuiet(): bool
|
||||
{
|
||||
return $this->output->isQuiet();
|
||||
}
|
||||
@@ -121,7 +118,7 @@ abstract class OutputStyle implements OutputInterface, StyleInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isVerbose()
|
||||
public function isVerbose(): bool
|
||||
{
|
||||
return $this->output->isVerbose();
|
||||
}
|
||||
@@ -129,7 +126,7 @@ abstract class OutputStyle implements OutputInterface, StyleInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isVeryVerbose()
|
||||
public function isVeryVerbose(): bool
|
||||
{
|
||||
return $this->output->isVeryVerbose();
|
||||
}
|
||||
@@ -137,7 +134,7 @@ abstract class OutputStyle implements OutputInterface, StyleInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isDebug()
|
||||
public function isDebug(): bool
|
||||
{
|
||||
return $this->output->isDebug();
|
||||
}
|
||||
|
||||
42
vendor/symfony/console/Style/StyleInterface.php
vendored
42
vendor/symfony/console/Style/StyleInterface.php
vendored
@@ -35,45 +35,33 @@ interface StyleInterface
|
||||
|
||||
/**
|
||||
* Formats informational text.
|
||||
*
|
||||
* @param string|array $message
|
||||
*/
|
||||
public function text($message);
|
||||
public function text(string|array $message);
|
||||
|
||||
/**
|
||||
* Formats a success result bar.
|
||||
*
|
||||
* @param string|array $message
|
||||
*/
|
||||
public function success($message);
|
||||
public function success(string|array $message);
|
||||
|
||||
/**
|
||||
* Formats an error result bar.
|
||||
*
|
||||
* @param string|array $message
|
||||
*/
|
||||
public function error($message);
|
||||
public function error(string|array $message);
|
||||
|
||||
/**
|
||||
* Formats an warning result bar.
|
||||
*
|
||||
* @param string|array $message
|
||||
*/
|
||||
public function warning($message);
|
||||
public function warning(string|array $message);
|
||||
|
||||
/**
|
||||
* Formats a note admonition.
|
||||
*
|
||||
* @param string|array $message
|
||||
*/
|
||||
public function note($message);
|
||||
public function note(string|array $message);
|
||||
|
||||
/**
|
||||
* Formats a caution admonition.
|
||||
*
|
||||
* @param string|array $message
|
||||
*/
|
||||
public function caution($message);
|
||||
public function caution(string|array $message);
|
||||
|
||||
/**
|
||||
* Formats a table.
|
||||
@@ -82,33 +70,23 @@ interface StyleInterface
|
||||
|
||||
/**
|
||||
* Asks a question.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function ask(string $question, string $default = null, callable $validator = null);
|
||||
public function ask(string $question, string $default = null, callable $validator = null): mixed;
|
||||
|
||||
/**
|
||||
* Asks a question with the user input hidden.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function askHidden(string $question, callable $validator = null);
|
||||
public function askHidden(string $question, callable $validator = null): mixed;
|
||||
|
||||
/**
|
||||
* Asks for confirmation.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function confirm(string $question, bool $default = true);
|
||||
public function confirm(string $question, bool $default = true): bool;
|
||||
|
||||
/**
|
||||
* Asks a choice question.
|
||||
*
|
||||
* @param string|int|null $default
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function choice(string $question, array $choices, $default = null);
|
||||
public function choice(string $question, array $choices, mixed $default = null): mixed;
|
||||
|
||||
/**
|
||||
* Add newline(s).
|
||||
|
||||
66
vendor/symfony/console/Style/SymfonyStyle.php
vendored
66
vendor/symfony/console/Style/SymfonyStyle.php
vendored
@@ -42,7 +42,7 @@ class SymfonyStyle extends OutputStyle
|
||||
private $output;
|
||||
private $questionHelper;
|
||||
private $progressBar;
|
||||
private $lineLength;
|
||||
private int $lineLength;
|
||||
private $bufferedOutput;
|
||||
|
||||
public function __construct(InputInterface $input, OutputInterface $output)
|
||||
@@ -58,10 +58,8 @@ class SymfonyStyle extends OutputStyle
|
||||
|
||||
/**
|
||||
* Formats a message as a block of text.
|
||||
*
|
||||
* @param string|array $messages The message to write in the block
|
||||
*/
|
||||
public function block($messages, string $type = null, string $style = null, string $prefix = ' ', bool $padding = false, bool $escape = true)
|
||||
public function block(string|array $messages, string $type = null, string $style = null, string $prefix = ' ', bool $padding = false, bool $escape = true)
|
||||
{
|
||||
$messages = \is_array($messages) ? array_values($messages) : [$messages];
|
||||
|
||||
@@ -113,7 +111,7 @@ class SymfonyStyle extends OutputStyle
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function text($message)
|
||||
public function text(string|array $message)
|
||||
{
|
||||
$this->autoPrependText();
|
||||
|
||||
@@ -125,10 +123,8 @@ class SymfonyStyle extends OutputStyle
|
||||
|
||||
/**
|
||||
* Formats a command comment.
|
||||
*
|
||||
* @param string|array $message
|
||||
*/
|
||||
public function comment($message)
|
||||
public function comment(string|array $message)
|
||||
{
|
||||
$this->block($message, null, null, '<fg=default;bg=default> // </>', false, false);
|
||||
}
|
||||
@@ -136,7 +132,7 @@ class SymfonyStyle extends OutputStyle
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function success($message)
|
||||
public function success(string|array $message)
|
||||
{
|
||||
$this->block($message, 'OK', 'fg=black;bg=green', ' ', true);
|
||||
}
|
||||
@@ -144,7 +140,7 @@ class SymfonyStyle extends OutputStyle
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function error($message)
|
||||
public function error(string|array $message)
|
||||
{
|
||||
$this->block($message, 'ERROR', 'fg=white;bg=red', ' ', true);
|
||||
}
|
||||
@@ -152,7 +148,7 @@ class SymfonyStyle extends OutputStyle
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function warning($message)
|
||||
public function warning(string|array $message)
|
||||
{
|
||||
$this->block($message, 'WARNING', 'fg=black;bg=yellow', ' ', true);
|
||||
}
|
||||
@@ -160,17 +156,15 @@ class SymfonyStyle extends OutputStyle
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function note($message)
|
||||
public function note(string|array $message)
|
||||
{
|
||||
$this->block($message, 'NOTE', 'fg=yellow', ' ! ');
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats an info message.
|
||||
*
|
||||
* @param string|array $message
|
||||
*/
|
||||
public function info($message)
|
||||
public function info(string|array $message)
|
||||
{
|
||||
$this->block($message, 'INFO', 'fg=green', ' ', true);
|
||||
}
|
||||
@@ -178,7 +172,7 @@ class SymfonyStyle extends OutputStyle
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function caution($message)
|
||||
public function caution(string|array $message)
|
||||
{
|
||||
$this->block($message, 'CAUTION', 'fg=white;bg=red', ' ! ', true);
|
||||
}
|
||||
@@ -219,10 +213,8 @@ class SymfonyStyle extends OutputStyle
|
||||
* * 'A title'
|
||||
* * ['key' => 'value']
|
||||
* * new TableSeparator()
|
||||
*
|
||||
* @param string|array|TableSeparator ...$list
|
||||
*/
|
||||
public function definitionList(...$list)
|
||||
public function definitionList(string|array|TableSeparator ...$list)
|
||||
{
|
||||
$headers = [];
|
||||
$row = [];
|
||||
@@ -250,7 +242,7 @@ class SymfonyStyle extends OutputStyle
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function ask(string $question, string $default = null, callable $validator = null)
|
||||
public function ask(string $question, string $default = null, callable $validator = null): mixed
|
||||
{
|
||||
$question = new Question($question, $default);
|
||||
$question->setValidator($validator);
|
||||
@@ -261,7 +253,7 @@ class SymfonyStyle extends OutputStyle
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function askHidden(string $question, callable $validator = null)
|
||||
public function askHidden(string $question, callable $validator = null): mixed
|
||||
{
|
||||
$question = new Question($question);
|
||||
|
||||
@@ -274,7 +266,7 @@ class SymfonyStyle extends OutputStyle
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function confirm(string $question, bool $default = true)
|
||||
public function confirm(string $question, bool $default = true): bool
|
||||
{
|
||||
return $this->askQuestion(new ConfirmationQuestion($question, $default));
|
||||
}
|
||||
@@ -282,7 +274,7 @@ class SymfonyStyle extends OutputStyle
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function choice(string $question, array $choices, $default = null)
|
||||
public function choice(string $question, array $choices, mixed $default = null): mixed
|
||||
{
|
||||
if (null !== $default) {
|
||||
$values = array_flip($choices);
|
||||
@@ -316,13 +308,13 @@ class SymfonyStyle extends OutputStyle
|
||||
{
|
||||
$this->getProgressBar()->finish();
|
||||
$this->newLine(2);
|
||||
$this->progressBar = null;
|
||||
unset($this->progressBar);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function createProgressBar(int $max = 0)
|
||||
public function createProgressBar(int $max = 0): ProgressBar
|
||||
{
|
||||
$progressBar = parent::createProgressBar($max);
|
||||
|
||||
@@ -345,18 +337,13 @@ class SymfonyStyle extends OutputStyle
|
||||
$this->newLine(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function askQuestion(Question $question)
|
||||
public function askQuestion(Question $question): mixed
|
||||
{
|
||||
if ($this->input->isInteractive()) {
|
||||
$this->autoPrependBlock();
|
||||
}
|
||||
|
||||
if (!$this->questionHelper) {
|
||||
$this->questionHelper = new SymfonyQuestionHelper();
|
||||
}
|
||||
$this->questionHelper ??= new SymfonyQuestionHelper();
|
||||
|
||||
$answer = $this->questionHelper->ask($this->input, $this, $question);
|
||||
|
||||
@@ -371,7 +358,7 @@ class SymfonyStyle extends OutputStyle
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function writeln($messages, int $type = self::OUTPUT_NORMAL)
|
||||
public function writeln(string|iterable $messages, int $type = self::OUTPUT_NORMAL)
|
||||
{
|
||||
if (!is_iterable($messages)) {
|
||||
$messages = [$messages];
|
||||
@@ -386,7 +373,7 @@ class SymfonyStyle extends OutputStyle
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function write($messages, bool $newline = false, int $type = self::OUTPUT_NORMAL)
|
||||
public function write(string|iterable $messages, bool $newline = false, int $type = self::OUTPUT_NORMAL)
|
||||
{
|
||||
if (!is_iterable($messages)) {
|
||||
$messages = [$messages];
|
||||
@@ -409,10 +396,8 @@ class SymfonyStyle extends OutputStyle
|
||||
|
||||
/**
|
||||
* Returns a new instance which makes use of stderr if available.
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function getErrorStyle()
|
||||
public function getErrorStyle(): self
|
||||
{
|
||||
return new self($this->input, $this->getErrorOutput());
|
||||
}
|
||||
@@ -428,11 +413,8 @@ class SymfonyStyle extends OutputStyle
|
||||
|
||||
private function getProgressBar(): ProgressBar
|
||||
{
|
||||
if (!$this->progressBar) {
|
||||
throw new RuntimeException('The ProgressBar is not started.');
|
||||
}
|
||||
|
||||
return $this->progressBar;
|
||||
return $this->progressBar
|
||||
?? throw new RuntimeException('The ProgressBar is not started.');
|
||||
}
|
||||
|
||||
private function autoPrependBlock(): void
|
||||
|
||||
14
vendor/symfony/console/Terminal.php
vendored
14
vendor/symfony/console/Terminal.php
vendored
@@ -13,16 +13,14 @@ namespace Symfony\Component\Console;
|
||||
|
||||
class Terminal
|
||||
{
|
||||
private static $width;
|
||||
private static $height;
|
||||
private static $stty;
|
||||
private static ?int $width = null;
|
||||
private static ?int $height = null;
|
||||
private static ?bool $stty = null;
|
||||
|
||||
/**
|
||||
* Gets the terminal width.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getWidth()
|
||||
public function getWidth(): int
|
||||
{
|
||||
$width = getenv('COLUMNS');
|
||||
if (false !== $width) {
|
||||
@@ -38,10 +36,8 @@ class Terminal
|
||||
|
||||
/**
|
||||
* Gets the terminal height.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getHeight()
|
||||
public function getHeight(): int
|
||||
{
|
||||
$height = getenv('LINES');
|
||||
if (false !== $height) {
|
||||
|
||||
@@ -47,7 +47,7 @@ class ApplicationTester
|
||||
*
|
||||
* @return int The command exit code
|
||||
*/
|
||||
public function run(array $input, array $options = [])
|
||||
public function run(array $input, array $options = []): int
|
||||
{
|
||||
$prevShellVerbosity = getenv('SHELL_VERBOSITY');
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ class CommandTester
|
||||
*
|
||||
* @return int The command exit code
|
||||
*/
|
||||
public function execute(array $input, array $options = [])
|
||||
public function execute(array $input, array $options = []): int
|
||||
{
|
||||
// set the command name automatically if the application requires
|
||||
// this argument and no command name was passed
|
||||
|
||||
39
vendor/symfony/console/Tester/TesterTrait.php
vendored
39
vendor/symfony/console/Tester/TesterTrait.php
vendored
@@ -23,25 +23,20 @@ use Symfony\Component\Console\Tester\Constraint\CommandIsSuccessful;
|
||||
*/
|
||||
trait TesterTrait
|
||||
{
|
||||
/** @var StreamOutput */
|
||||
private $output;
|
||||
private $inputs = [];
|
||||
private $captureStreamsIndependently = false;
|
||||
/** @var InputInterface */
|
||||
private array $inputs = [];
|
||||
private bool $captureStreamsIndependently = false;
|
||||
private $input;
|
||||
/** @var int */
|
||||
private $statusCode;
|
||||
private int $statusCode;
|
||||
|
||||
/**
|
||||
* Gets the display returned by the last execution of the command or application.
|
||||
*
|
||||
* @throws \RuntimeException If it's called before the execute method
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDisplay(bool $normalize = false)
|
||||
public function getDisplay(bool $normalize = false): string
|
||||
{
|
||||
if (null === $this->output) {
|
||||
if (!isset($this->output)) {
|
||||
throw new \RuntimeException('Output not initialized, did you execute the command before requesting the display?');
|
||||
}
|
||||
|
||||
@@ -60,10 +55,8 @@ trait TesterTrait
|
||||
* Gets the output written to STDERR by the application.
|
||||
*
|
||||
* @param bool $normalize Whether to normalize end of lines to \n or not
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getErrorOutput(bool $normalize = false)
|
||||
public function getErrorOutput(bool $normalize = false): string
|
||||
{
|
||||
if (!$this->captureStreamsIndependently) {
|
||||
throw new \LogicException('The error output is not available when the tester is run without "capture_stderr_separately" option set.');
|
||||
@@ -82,20 +75,16 @@ trait TesterTrait
|
||||
|
||||
/**
|
||||
* Gets the input instance used by the last execution of the command or application.
|
||||
*
|
||||
* @return InputInterface
|
||||
*/
|
||||
public function getInput()
|
||||
public function getInput(): InputInterface
|
||||
{
|
||||
return $this->input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the output instance used by the last execution of the command or application.
|
||||
*
|
||||
* @return OutputInterface
|
||||
*/
|
||||
public function getOutput()
|
||||
public function getOutput(): OutputInterface
|
||||
{
|
||||
return $this->output;
|
||||
}
|
||||
@@ -104,16 +93,10 @@ trait TesterTrait
|
||||
* Gets the status code returned by the last execution of the command or application.
|
||||
*
|
||||
* @throws \RuntimeException If it's called before the execute method
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getStatusCode()
|
||||
public function getStatusCode(): int
|
||||
{
|
||||
if (null === $this->statusCode) {
|
||||
throw new \RuntimeException('Status code not initialized, did you execute the command before requesting the status code?');
|
||||
}
|
||||
|
||||
return $this->statusCode;
|
||||
return $this->statusCode ?? throw new \RuntimeException('Status code not initialized, did you execute the command before requesting the status code?');
|
||||
}
|
||||
|
||||
public function assertCommandIsSuccessful(string $message = ''): void
|
||||
@@ -129,7 +112,7 @@ trait TesterTrait
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setInputs(array $inputs)
|
||||
public function setInputs(array $inputs): static
|
||||
{
|
||||
$this->inputs = $inputs;
|
||||
|
||||
|
||||
34
vendor/symfony/console/composer.json
vendored
34
vendor/symfony/console/composer.json
vendored
@@ -16,25 +16,22 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.2.5",
|
||||
"symfony/deprecation-contracts": "^2.1|^3",
|
||||
"php": ">=8.0.2",
|
||||
"symfony/polyfill-mbstring": "~1.0",
|
||||
"symfony/polyfill-php73": "^1.9",
|
||||
"symfony/polyfill-php80": "^1.16",
|
||||
"symfony/service-contracts": "^1.1|^2|^3",
|
||||
"symfony/string": "^5.1|^6.0"
|
||||
"symfony/string": "^5.4|^6.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/config": "^4.4|^5.0|^6.0",
|
||||
"symfony/event-dispatcher": "^4.4|^5.0|^6.0",
|
||||
"symfony/dependency-injection": "^4.4|^5.0|^6.0",
|
||||
"symfony/lock": "^4.4|^5.0|^6.0",
|
||||
"symfony/process": "^4.4|^5.0|^6.0",
|
||||
"symfony/var-dumper": "^4.4|^5.0|^6.0",
|
||||
"psr/log": "^1|^2"
|
||||
"symfony/config": "^5.4|^6.0",
|
||||
"symfony/event-dispatcher": "^5.4|^6.0",
|
||||
"symfony/dependency-injection": "^5.4|^6.0",
|
||||
"symfony/lock": "^5.4|^6.0",
|
||||
"symfony/process": "^5.4|^6.0",
|
||||
"symfony/var-dumper": "^5.4|^6.0",
|
||||
"psr/log": "^1|^2|^3"
|
||||
},
|
||||
"provide": {
|
||||
"psr/log-implementation": "1.0|2.0"
|
||||
"psr/log-implementation": "1.0|2.0|3.0"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/event-dispatcher": "",
|
||||
@@ -43,12 +40,11 @@
|
||||
"psr/log": "For using the console logger"
|
||||
},
|
||||
"conflict": {
|
||||
"psr/log": ">=3",
|
||||
"symfony/dependency-injection": "<4.4",
|
||||
"symfony/dotenv": "<5.1",
|
||||
"symfony/event-dispatcher": "<4.4",
|
||||
"symfony/lock": "<4.4",
|
||||
"symfony/process": "<4.4"
|
||||
"symfony/dependency-injection": "<5.4",
|
||||
"symfony/dotenv": "<5.4",
|
||||
"symfony/event-dispatcher": "<5.4",
|
||||
"symfony/lock": "<5.4",
|
||||
"symfony/process": "<5.4"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Symfony\\Component\\Console\\": "" },
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.1"
|
||||
"php": ">=8.0.2"
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
@@ -25,7 +25,7 @@
|
||||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-main": "2.5-dev"
|
||||
"dev-main": "3.0-dev"
|
||||
},
|
||||
"thanks": {
|
||||
"name": "symfony/contracts",
|
||||
|
||||
@@ -20,7 +20,7 @@ if (!function_exists('trigger_deprecation')) {
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
function trigger_deprecation(string $package, string $version, string $message, ...$args): void
|
||||
function trigger_deprecation(string $package, string $version, string $message, mixed ...$args): void
|
||||
{
|
||||
@trigger_error(($package || $version ? "Since $package $version: " : '').($args ? vsprintf($message, $args) : $message), \E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ use Psr\EventDispatcher\StoppableEventInterface;
|
||||
*/
|
||||
class Event implements StoppableEventInterface
|
||||
{
|
||||
private $propagationStopped = false;
|
||||
private bool $propagationStopped = false;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.2.5",
|
||||
"php": ">=8.0.2",
|
||||
"psr/event-dispatcher": "^1"
|
||||
},
|
||||
"suggest": {
|
||||
@@ -28,7 +28,7 @@
|
||||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-main": "2.5-dev"
|
||||
"dev-main": "3.0-dev"
|
||||
},
|
||||
"thanks": {
|
||||
"name": "symfony/contracts",
|
||||
|
||||
5
vendor/symfony/event-dispatcher/CHANGELOG.md
vendored
5
vendor/symfony/event-dispatcher/CHANGELOG.md
vendored
@@ -1,6 +1,11 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
6.0
|
||||
---
|
||||
|
||||
* Remove `LegacyEventDispatcherProxy`
|
||||
|
||||
5.4
|
||||
---
|
||||
|
||||
|
||||
@@ -33,29 +33,27 @@ class TraceableEventDispatcher implements EventDispatcherInterface, ResetInterfa
|
||||
protected $stopwatch;
|
||||
|
||||
/**
|
||||
* @var \SplObjectStorage<WrappedListener, array{string, string}>
|
||||
* @var \SplObjectStorage<WrappedListener, array{string, string}>|null
|
||||
*/
|
||||
private $callStack;
|
||||
private ?\SplObjectStorage $callStack = null;
|
||||
private $dispatcher;
|
||||
private $wrappedListeners;
|
||||
private $orphanedEvents;
|
||||
private array $wrappedListeners = [];
|
||||
private array $orphanedEvents = [];
|
||||
private $requestStack;
|
||||
private $currentRequestHash = '';
|
||||
private string $currentRequestHash = '';
|
||||
|
||||
public function __construct(EventDispatcherInterface $dispatcher, Stopwatch $stopwatch, LoggerInterface $logger = null, RequestStack $requestStack = null)
|
||||
{
|
||||
$this->dispatcher = $dispatcher;
|
||||
$this->stopwatch = $stopwatch;
|
||||
$this->logger = $logger;
|
||||
$this->wrappedListeners = [];
|
||||
$this->orphanedEvents = [];
|
||||
$this->requestStack = $requestStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function addListener(string $eventName, $listener, int $priority = 0)
|
||||
public function addListener(string $eventName, callable|array $listener, int $priority = 0)
|
||||
{
|
||||
$this->dispatcher->addListener($eventName, $listener, $priority);
|
||||
}
|
||||
@@ -71,7 +69,7 @@ class TraceableEventDispatcher implements EventDispatcherInterface, ResetInterfa
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function removeListener(string $eventName, $listener)
|
||||
public function removeListener(string $eventName, callable|array $listener)
|
||||
{
|
||||
if (isset($this->wrappedListeners[$eventName])) {
|
||||
foreach ($this->wrappedListeners[$eventName] as $index => $wrappedListener) {
|
||||
@@ -97,7 +95,7 @@ class TraceableEventDispatcher implements EventDispatcherInterface, ResetInterfa
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getListeners(string $eventName = null)
|
||||
public function getListeners(string $eventName = null): array
|
||||
{
|
||||
return $this->dispatcher->getListeners($eventName);
|
||||
}
|
||||
@@ -105,7 +103,7 @@ class TraceableEventDispatcher implements EventDispatcherInterface, ResetInterfa
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getListenerPriority(string $eventName, $listener)
|
||||
public function getListenerPriority(string $eventName, callable|array $listener): ?int
|
||||
{
|
||||
// we might have wrapped listeners for the event (if called while dispatching)
|
||||
// in that case get the priority by wrapper
|
||||
@@ -123,7 +121,7 @@ class TraceableEventDispatcher implements EventDispatcherInterface, ResetInterfa
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasListeners(string $eventName = null)
|
||||
public function hasListeners(string $eventName = null): bool
|
||||
{
|
||||
return $this->dispatcher->hasListeners($eventName);
|
||||
}
|
||||
@@ -168,10 +166,7 @@ class TraceableEventDispatcher implements EventDispatcherInterface, ResetInterfa
|
||||
return $event;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getCalledListeners(Request $request = null)
|
||||
public function getCalledListeners(Request $request = null): array
|
||||
{
|
||||
if (null === $this->callStack) {
|
||||
return [];
|
||||
@@ -189,10 +184,7 @@ class TraceableEventDispatcher implements EventDispatcherInterface, ResetInterfa
|
||||
return $called;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getNotCalledListeners(Request $request = null)
|
||||
public function getNotCalledListeners(Request $request = null): array
|
||||
{
|
||||
try {
|
||||
$allListeners = $this->getListeners();
|
||||
@@ -260,10 +252,8 @@ class TraceableEventDispatcher implements EventDispatcherInterface, ResetInterfa
|
||||
*
|
||||
* @param string $method The method name
|
||||
* @param array $arguments The method arguments
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call(string $method, array $arguments)
|
||||
public function __call(string $method, array $arguments): mixed
|
||||
{
|
||||
return $this->dispatcher->{$method}(...$arguments);
|
||||
}
|
||||
|
||||
@@ -21,26 +21,24 @@ use Symfony\Component\VarDumper\Caster\ClassStub;
|
||||
*/
|
||||
final class WrappedListener
|
||||
{
|
||||
private $listener;
|
||||
private $optimizedListener;
|
||||
private $name;
|
||||
private $called;
|
||||
private $stoppedPropagation;
|
||||
private string|array|object $listener;
|
||||
private ?\Closure $optimizedListener;
|
||||
private string $name;
|
||||
private bool $called = false;
|
||||
private bool $stoppedPropagation = false;
|
||||
private $stopwatch;
|
||||
private $dispatcher;
|
||||
private $pretty;
|
||||
private string $pretty;
|
||||
private $stub;
|
||||
private $priority;
|
||||
private static $hasClassStub;
|
||||
private ?int $priority = null;
|
||||
private static bool $hasClassStub;
|
||||
|
||||
public function __construct($listener, ?string $name, Stopwatch $stopwatch, EventDispatcherInterface $dispatcher = null)
|
||||
public function __construct(callable|array $listener, ?string $name, Stopwatch $stopwatch, EventDispatcherInterface $dispatcher = null)
|
||||
{
|
||||
$this->listener = $listener;
|
||||
$this->optimizedListener = $listener instanceof \Closure ? $listener : (\is_callable($listener) ? \Closure::fromCallable($listener) : null);
|
||||
$this->stopwatch = $stopwatch;
|
||||
$this->dispatcher = $dispatcher;
|
||||
$this->called = false;
|
||||
$this->stoppedPropagation = false;
|
||||
|
||||
if (\is_array($listener)) {
|
||||
$this->name = \is_object($listener[0]) ? get_debug_type($listener[0]) : $listener[0];
|
||||
@@ -66,12 +64,10 @@ final class WrappedListener
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
if (null === self::$hasClassStub) {
|
||||
self::$hasClassStub = class_exists(ClassStub::class);
|
||||
}
|
||||
self::$hasClassStub ??= class_exists(ClassStub::class);
|
||||
}
|
||||
|
||||
public function getWrappedListener()
|
||||
public function getWrappedListener(): callable|array
|
||||
{
|
||||
return $this->listener;
|
||||
}
|
||||
@@ -93,9 +89,7 @@ final class WrappedListener
|
||||
|
||||
public function getInfo(string $eventName): array
|
||||
{
|
||||
if (null === $this->stub) {
|
||||
$this->stub = self::$hasClassStub ? new ClassStub($this->pretty.'()', $this->listener) : $this->pretty.'()';
|
||||
}
|
||||
$this->stub ??= self::$hasClassStub ? new ClassStub($this->pretty.'()', $this->listener) : $this->pretty.'()';
|
||||
|
||||
return [
|
||||
'event' => $eventName,
|
||||
|
||||
@@ -21,25 +21,19 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
*/
|
||||
class AddEventAliasesPass implements CompilerPassInterface
|
||||
{
|
||||
private $eventAliases;
|
||||
private $eventAliasesParameter;
|
||||
private array $eventAliases;
|
||||
|
||||
public function __construct(array $eventAliases, string $eventAliasesParameter = 'event_dispatcher.event_aliases')
|
||||
public function __construct(array $eventAliases)
|
||||
{
|
||||
if (1 < \func_num_args()) {
|
||||
trigger_deprecation('symfony/event-dispatcher', '5.3', 'Configuring "%s" is deprecated.', __CLASS__);
|
||||
}
|
||||
|
||||
$this->eventAliases = $eventAliases;
|
||||
$this->eventAliasesParameter = $eventAliasesParameter;
|
||||
}
|
||||
|
||||
public function process(ContainerBuilder $container): void
|
||||
{
|
||||
$eventAliases = $container->hasParameter($this->eventAliasesParameter) ? $container->getParameter($this->eventAliasesParameter) : [];
|
||||
$eventAliases = $container->hasParameter('event_dispatcher.event_aliases') ? $container->getParameter('event_dispatcher.event_aliases') : [];
|
||||
|
||||
$container->setParameter(
|
||||
$this->eventAliasesParameter,
|
||||
'event_dispatcher.event_aliases',
|
||||
array_merge($eventAliases, $this->eventAliases)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -25,80 +25,51 @@ use Symfony\Contracts\EventDispatcher\Event;
|
||||
*/
|
||||
class RegisterListenersPass implements CompilerPassInterface
|
||||
{
|
||||
protected $dispatcherService;
|
||||
protected $listenerTag;
|
||||
protected $subscriberTag;
|
||||
protected $eventAliasesParameter;
|
||||
|
||||
private $hotPathEvents = [];
|
||||
private $hotPathTagName = 'container.hot_path';
|
||||
private $noPreloadEvents = [];
|
||||
private $noPreloadTagName = 'container.no_preload';
|
||||
|
||||
public function __construct(string $dispatcherService = 'event_dispatcher', string $listenerTag = 'kernel.event_listener', string $subscriberTag = 'kernel.event_subscriber', string $eventAliasesParameter = 'event_dispatcher.event_aliases')
|
||||
{
|
||||
if (0 < \func_num_args()) {
|
||||
trigger_deprecation('symfony/event-dispatcher', '5.3', 'Configuring "%s" is deprecated.', __CLASS__);
|
||||
}
|
||||
|
||||
$this->dispatcherService = $dispatcherService;
|
||||
$this->listenerTag = $listenerTag;
|
||||
$this->subscriberTag = $subscriberTag;
|
||||
$this->eventAliasesParameter = $eventAliasesParameter;
|
||||
}
|
||||
private array $hotPathEvents = [];
|
||||
private array $noPreloadEvents = [];
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setHotPathEvents(array $hotPathEvents)
|
||||
public function setHotPathEvents(array $hotPathEvents): static
|
||||
{
|
||||
$this->hotPathEvents = array_flip($hotPathEvents);
|
||||
|
||||
if (1 < \func_num_args()) {
|
||||
trigger_deprecation('symfony/event-dispatcher', '5.4', 'Configuring "$tagName" in "%s" is deprecated.', __METHOD__);
|
||||
$this->hotPathTagName = func_get_arg(1);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setNoPreloadEvents(array $noPreloadEvents): self
|
||||
public function setNoPreloadEvents(array $noPreloadEvents): static
|
||||
{
|
||||
$this->noPreloadEvents = array_flip($noPreloadEvents);
|
||||
|
||||
if (1 < \func_num_args()) {
|
||||
trigger_deprecation('symfony/event-dispatcher', '5.4', 'Configuring "$tagName" in "%s" is deprecated.', __METHOD__);
|
||||
$this->noPreloadTagName = func_get_arg(1);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
if (!$container->hasDefinition($this->dispatcherService) && !$container->hasAlias($this->dispatcherService)) {
|
||||
if (!$container->hasDefinition('event_dispatcher') && !$container->hasAlias('event_dispatcher')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$aliases = [];
|
||||
|
||||
if ($container->hasParameter($this->eventAliasesParameter)) {
|
||||
$aliases = $container->getParameter($this->eventAliasesParameter);
|
||||
if ($container->hasParameter('event_dispatcher.event_aliases')) {
|
||||
$aliases = $container->getParameter('event_dispatcher.event_aliases');
|
||||
}
|
||||
|
||||
$globalDispatcherDefinition = $container->findDefinition($this->dispatcherService);
|
||||
$globalDispatcherDefinition = $container->findDefinition('event_dispatcher');
|
||||
|
||||
foreach ($container->findTaggedServiceIds($this->listenerTag, true) as $id => $events) {
|
||||
foreach ($container->findTaggedServiceIds('kernel.event_listener', true) as $id => $events) {
|
||||
$noPreload = 0;
|
||||
|
||||
foreach ($events as $event) {
|
||||
$priority = $event['priority'] ?? 0;
|
||||
|
||||
if (!isset($event['event'])) {
|
||||
if ($container->getDefinition($id)->hasTag($this->subscriberTag)) {
|
||||
if ($container->getDefinition($id)->hasTag('kernel.event_subscriber')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -128,20 +99,20 @@ class RegisterListenersPass implements CompilerPassInterface
|
||||
$dispatcherDefinition->addMethodCall('addListener', [$event['event'], [new ServiceClosureArgument(new Reference($id)), $event['method']], $priority]);
|
||||
|
||||
if (isset($this->hotPathEvents[$event['event']])) {
|
||||
$container->getDefinition($id)->addTag($this->hotPathTagName);
|
||||
$container->getDefinition($id)->addTag('container.hot_path');
|
||||
} elseif (isset($this->noPreloadEvents[$event['event']])) {
|
||||
++$noPreload;
|
||||
}
|
||||
}
|
||||
|
||||
if ($noPreload && \count($events) === $noPreload) {
|
||||
$container->getDefinition($id)->addTag($this->noPreloadTagName);
|
||||
$container->getDefinition($id)->addTag('container.no_preload');
|
||||
}
|
||||
}
|
||||
|
||||
$extractingDispatcher = new ExtractingEventDispatcher();
|
||||
|
||||
foreach ($container->findTaggedServiceIds($this->subscriberTag, true) as $id => $tags) {
|
||||
foreach ($container->findTaggedServiceIds('kernel.event_subscriber', true) as $id => $tags) {
|
||||
$def = $container->getDefinition($id);
|
||||
|
||||
// We must assume that the class value has been correctly filled, even if the service is created by a factory
|
||||
@@ -179,13 +150,13 @@ class RegisterListenersPass implements CompilerPassInterface
|
||||
}
|
||||
|
||||
if (isset($this->hotPathEvents[$args[0]])) {
|
||||
$container->getDefinition($id)->addTag($this->hotPathTagName);
|
||||
$container->getDefinition($id)->addTag('container.hot_path');
|
||||
} elseif (isset($this->noPreloadEvents[$args[0]])) {
|
||||
++$noPreload;
|
||||
}
|
||||
}
|
||||
if ($noPreload && \count($extractingDispatcher->listeners) === $noPreload) {
|
||||
$container->getDefinition($id)->addTag($this->noPreloadTagName);
|
||||
$container->getDefinition($id)->addTag('container.no_preload');
|
||||
}
|
||||
$extractingDispatcher->listeners = [];
|
||||
ExtractingEventDispatcher::$aliases = [];
|
||||
@@ -203,7 +174,7 @@ class RegisterListenersPass implements CompilerPassInterface
|
||||
|| $type->isBuiltin()
|
||||
|| Event::class === ($name = $type->getName())
|
||||
) {
|
||||
throw new InvalidArgumentException(sprintf('Service "%s" must define the "event" attribute on "%s" tags.', $id, $this->listenerTag));
|
||||
throw new InvalidArgumentException(sprintf('Service "%s" must define the "event" attribute on "kernel.event_listener" tags.', $id));
|
||||
}
|
||||
|
||||
return $name;
|
||||
@@ -215,12 +186,12 @@ class RegisterListenersPass implements CompilerPassInterface
|
||||
*/
|
||||
class ExtractingEventDispatcher extends EventDispatcher implements EventSubscriberInterface
|
||||
{
|
||||
public $listeners = [];
|
||||
public array $listeners = [];
|
||||
|
||||
public static $aliases = [];
|
||||
public static $subscriber;
|
||||
public static array $aliases = [];
|
||||
public static string $subscriber;
|
||||
|
||||
public function addListener(string $eventName, $listener, int $priority = 0)
|
||||
public function addListener(string $eventName, callable|array $listener, int $priority = 0)
|
||||
{
|
||||
$this->listeners[] = [$eventName, $listener[1], $priority];
|
||||
}
|
||||
|
||||
@@ -31,9 +31,9 @@ use Symfony\Component\EventDispatcher\Debug\WrappedListener;
|
||||
*/
|
||||
class EventDispatcher implements EventDispatcherInterface
|
||||
{
|
||||
private $listeners = [];
|
||||
private $sorted = [];
|
||||
private $optimized;
|
||||
private array $listeners = [];
|
||||
private array $sorted = [];
|
||||
private array $optimized;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -49,7 +49,7 @@ class EventDispatcher implements EventDispatcherInterface
|
||||
{
|
||||
$eventName = $eventName ?? \get_class($event);
|
||||
|
||||
if (null !== $this->optimized) {
|
||||
if (isset($this->optimized)) {
|
||||
$listeners = $this->optimized[$eventName] ?? (empty($this->listeners[$eventName]) ? [] : $this->optimizeListeners($eventName));
|
||||
} else {
|
||||
$listeners = $this->getListeners($eventName);
|
||||
@@ -65,7 +65,7 @@ class EventDispatcher implements EventDispatcherInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getListeners(string $eventName = null)
|
||||
public function getListeners(string $eventName = null): array
|
||||
{
|
||||
if (null !== $eventName) {
|
||||
if (empty($this->listeners[$eventName])) {
|
||||
@@ -91,7 +91,7 @@ class EventDispatcher implements EventDispatcherInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getListenerPriority(string $eventName, $listener)
|
||||
public function getListenerPriority(string $eventName, callable|array $listener): ?int
|
||||
{
|
||||
if (empty($this->listeners[$eventName])) {
|
||||
return null;
|
||||
@@ -120,7 +120,7 @@ class EventDispatcher implements EventDispatcherInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasListeners(string $eventName = null)
|
||||
public function hasListeners(string $eventName = null): bool
|
||||
{
|
||||
if (null !== $eventName) {
|
||||
return !empty($this->listeners[$eventName]);
|
||||
@@ -138,7 +138,7 @@ class EventDispatcher implements EventDispatcherInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function addListener(string $eventName, $listener, int $priority = 0)
|
||||
public function addListener(string $eventName, callable|array $listener, int $priority = 0)
|
||||
{
|
||||
$this->listeners[$eventName][$priority][] = $listener;
|
||||
unset($this->sorted[$eventName], $this->optimized[$eventName]);
|
||||
@@ -147,7 +147,7 @@ class EventDispatcher implements EventDispatcherInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function removeListener(string $eventName, $listener)
|
||||
public function removeListener(string $eventName, callable|array $listener)
|
||||
{
|
||||
if (empty($this->listeners[$eventName])) {
|
||||
return;
|
||||
|
||||
@@ -50,21 +50,17 @@ interface EventDispatcherInterface extends ContractsEventDispatcherInterface
|
||||
*
|
||||
* @return array<callable[]|callable>
|
||||
*/
|
||||
public function getListeners(string $eventName = null);
|
||||
public function getListeners(string $eventName = null): array;
|
||||
|
||||
/**
|
||||
* Gets the listener priority for a specific event.
|
||||
*
|
||||
* Returns null if the event or the listener does not exist.
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getListenerPriority(string $eventName, callable $listener);
|
||||
public function getListenerPriority(string $eventName, callable $listener): ?int;
|
||||
|
||||
/**
|
||||
* Checks whether an event has any registered listeners.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasListeners(string $eventName = null);
|
||||
public function hasListeners(string $eventName = null): bool;
|
||||
}
|
||||
|
||||
50
vendor/symfony/event-dispatcher/GenericEvent.php
vendored
50
vendor/symfony/event-dispatcher/GenericEvent.php
vendored
@@ -34,7 +34,7 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
|
||||
* @param mixed $subject The subject of the event, usually an object or a callable
|
||||
* @param array $arguments Arguments to store in the event
|
||||
*/
|
||||
public function __construct($subject = null, array $arguments = [])
|
||||
public function __construct(mixed $subject = null, array $arguments = [])
|
||||
{
|
||||
$this->subject = $subject;
|
||||
$this->arguments = $arguments;
|
||||
@@ -42,10 +42,8 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
|
||||
|
||||
/**
|
||||
* Getter for subject property.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getSubject()
|
||||
public function getSubject(): mixed
|
||||
{
|
||||
return $this->subject;
|
||||
}
|
||||
@@ -53,11 +51,9 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
|
||||
/**
|
||||
* Get argument by key.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \InvalidArgumentException if key is not found
|
||||
*/
|
||||
public function getArgument(string $key)
|
||||
public function getArgument(string $key): mixed
|
||||
{
|
||||
if ($this->hasArgument($key)) {
|
||||
return $this->arguments[$key];
|
||||
@@ -69,11 +65,9 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
|
||||
/**
|
||||
* Add argument to event.
|
||||
*
|
||||
* @param mixed $value Value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setArgument(string $key, $value)
|
||||
public function setArgument(string $key, mixed $value): static
|
||||
{
|
||||
$this->arguments[$key] = $value;
|
||||
|
||||
@@ -82,10 +76,8 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
|
||||
|
||||
/**
|
||||
* Getter for all arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getArguments()
|
||||
public function getArguments(): array
|
||||
{
|
||||
return $this->arguments;
|
||||
}
|
||||
@@ -95,7 +87,7 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setArguments(array $args = [])
|
||||
public function setArguments(array $args = []): static
|
||||
{
|
||||
$this->arguments = $args;
|
||||
|
||||
@@ -104,10 +96,8 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
|
||||
|
||||
/**
|
||||
* Has argument.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasArgument(string $key)
|
||||
public function hasArgument(string $key): bool
|
||||
{
|
||||
return \array_key_exists($key, $this->arguments);
|
||||
}
|
||||
@@ -117,12 +107,9 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
|
||||
*
|
||||
* @param string $key Array key
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \InvalidArgumentException if key does not exist in $this->args
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($key)
|
||||
public function offsetGet(mixed $key): mixed
|
||||
{
|
||||
return $this->getArgument($key);
|
||||
}
|
||||
@@ -130,13 +117,9 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
|
||||
/**
|
||||
* ArrayAccess for argument setter.
|
||||
*
|
||||
* @param string $key Array key to set
|
||||
* @param mixed $value Value
|
||||
*
|
||||
* @return void
|
||||
* @param string $key Array key to set
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetSet($key, $value)
|
||||
public function offsetSet(mixed $key, mixed $value): void
|
||||
{
|
||||
$this->setArgument($key, $value);
|
||||
}
|
||||
@@ -145,11 +128,8 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
|
||||
* ArrayAccess for unset argument.
|
||||
*
|
||||
* @param string $key Array key
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetUnset($key)
|
||||
public function offsetUnset(mixed $key): void
|
||||
{
|
||||
if ($this->hasArgument($key)) {
|
||||
unset($this->arguments[$key]);
|
||||
@@ -160,11 +140,8 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
|
||||
* ArrayAccess has argument.
|
||||
*
|
||||
* @param string $key Array key
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetExists($key)
|
||||
public function offsetExists(mixed $key): bool
|
||||
{
|
||||
return $this->hasArgument($key);
|
||||
}
|
||||
@@ -174,8 +151,7 @@ class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate
|
||||
*
|
||||
* @return \ArrayIterator<string, mixed>
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function getIterator()
|
||||
public function getIterator(): \ArrayIterator
|
||||
{
|
||||
return new \ArrayIterator($this->arguments);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ class ImmutableEventDispatcher implements EventDispatcherInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function addListener(string $eventName, $listener, int $priority = 0)
|
||||
public function addListener(string $eventName, callable|array $listener, int $priority = 0)
|
||||
{
|
||||
throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.');
|
||||
}
|
||||
@@ -52,7 +52,7 @@ class ImmutableEventDispatcher implements EventDispatcherInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function removeListener(string $eventName, $listener)
|
||||
public function removeListener(string $eventName, callable|array $listener)
|
||||
{
|
||||
throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.');
|
||||
}
|
||||
@@ -68,7 +68,7 @@ class ImmutableEventDispatcher implements EventDispatcherInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getListeners(string $eventName = null)
|
||||
public function getListeners(string $eventName = null): array
|
||||
{
|
||||
return $this->dispatcher->getListeners($eventName);
|
||||
}
|
||||
@@ -76,7 +76,7 @@ class ImmutableEventDispatcher implements EventDispatcherInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getListenerPriority(string $eventName, $listener)
|
||||
public function getListenerPriority(string $eventName, callable|array $listener): ?int
|
||||
{
|
||||
return $this->dispatcher->getListenerPriority($eventName, $listener);
|
||||
}
|
||||
@@ -84,7 +84,7 @@ class ImmutableEventDispatcher implements EventDispatcherInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasListeners(string $eventName = null)
|
||||
public function hasListeners(string $eventName = null): bool
|
||||
{
|
||||
return $this->dispatcher->hasListeners($eventName);
|
||||
}
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
<?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\EventDispatcher;
|
||||
|
||||
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
|
||||
|
||||
trigger_deprecation('symfony/event-dispatcher', '5.1', '%s is deprecated, use the event dispatcher without the proxy.', LegacyEventDispatcherProxy::class);
|
||||
|
||||
/**
|
||||
* A helper class to provide BC/FC with the legacy signature of EventDispatcherInterface::dispatch().
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*
|
||||
* @deprecated since Symfony 5.1
|
||||
*/
|
||||
final class LegacyEventDispatcherProxy
|
||||
{
|
||||
public static function decorate(?EventDispatcherInterface $dispatcher): ?EventDispatcherInterface
|
||||
{
|
||||
return $dispatcher;
|
||||
}
|
||||
}
|
||||
22
vendor/symfony/event-dispatcher/composer.json
vendored
22
vendor/symfony/event-dispatcher/composer.json
vendored
@@ -16,27 +16,25 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.2.5",
|
||||
"symfony/deprecation-contracts": "^2.1|^3",
|
||||
"symfony/event-dispatcher-contracts": "^2|^3",
|
||||
"symfony/polyfill-php80": "^1.16"
|
||||
"php": ">=8.0.2",
|
||||
"symfony/event-dispatcher-contracts": "^2|^3"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/dependency-injection": "^4.4|^5.0|^6.0",
|
||||
"symfony/expression-language": "^4.4|^5.0|^6.0",
|
||||
"symfony/config": "^4.4|^5.0|^6.0",
|
||||
"symfony/error-handler": "^4.4|^5.0|^6.0",
|
||||
"symfony/http-foundation": "^4.4|^5.0|^6.0",
|
||||
"symfony/dependency-injection": "^5.4|^6.0",
|
||||
"symfony/expression-language": "^5.4|^6.0",
|
||||
"symfony/config": "^5.4|^6.0",
|
||||
"symfony/error-handler": "^5.4|^6.0",
|
||||
"symfony/http-foundation": "^5.4|^6.0",
|
||||
"symfony/service-contracts": "^1.1|^2|^3",
|
||||
"symfony/stopwatch": "^4.4|^5.0|^6.0",
|
||||
"symfony/stopwatch": "^5.4|^6.0",
|
||||
"psr/log": "^1|^2|^3"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/dependency-injection": "<4.4"
|
||||
"symfony/dependency-injection": "<5.4"
|
||||
},
|
||||
"provide": {
|
||||
"psr/event-dispatcher-implementation": "1.0",
|
||||
"symfony/event-dispatcher-implementation": "2.0"
|
||||
"symfony/event-dispatcher-implementation": "2.0|3.0"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/dependency-injection": "",
|
||||
|
||||
5
vendor/symfony/finder/CHANGELOG.md
vendored
5
vendor/symfony/finder/CHANGELOG.md
vendored
@@ -1,6 +1,11 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
6.0
|
||||
---
|
||||
|
||||
* Remove `Comparator::setTarget()` and `Comparator::setOperator()`
|
||||
|
||||
5.4.0
|
||||
-----
|
||||
|
||||
|
||||
67
vendor/symfony/finder/Comparator/Comparator.php
vendored
67
vendor/symfony/finder/Comparator/Comparator.php
vendored
@@ -16,80 +16,40 @@ namespace Symfony\Component\Finder\Comparator;
|
||||
*/
|
||||
class Comparator
|
||||
{
|
||||
private $target;
|
||||
private $operator = '==';
|
||||
private string $target;
|
||||
private string $operator;
|
||||
|
||||
public function __construct(string $target = null, string $operator = '==')
|
||||
public function __construct(string $target, string $operator = '==')
|
||||
{
|
||||
if (null === $target) {
|
||||
trigger_deprecation('symfony/finder', '5.4', 'Constructing a "%s" without setting "$target" is deprecated.', __CLASS__);
|
||||
if (!\in_array($operator, ['>', '<', '>=', '<=', '==', '!='])) {
|
||||
throw new \InvalidArgumentException(sprintf('Invalid operator "%s".', $operator));
|
||||
}
|
||||
|
||||
$this->target = $target;
|
||||
$this->doSetOperator($operator);
|
||||
$this->operator = $operator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the target value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTarget()
|
||||
public function getTarget(): string
|
||||
{
|
||||
if (null === $this->target) {
|
||||
trigger_deprecation('symfony/finder', '5.4', 'Calling "%s" without initializing the target is deprecated.', __METHOD__);
|
||||
}
|
||||
|
||||
return $this->target;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated set the target via the constructor instead
|
||||
*/
|
||||
public function setTarget(string $target)
|
||||
{
|
||||
trigger_deprecation('symfony/finder', '5.4', '"%s" is deprecated. Set the target via the constructor instead.', __METHOD__);
|
||||
|
||||
$this->target = $target;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the comparison operator.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOperator()
|
||||
public function getOperator(): string
|
||||
{
|
||||
return $this->operator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the comparison operator.
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @deprecated set the operator via the constructor instead
|
||||
*/
|
||||
public function setOperator(string $operator)
|
||||
{
|
||||
trigger_deprecation('symfony/finder', '5.4', '"%s" is deprecated. Set the operator via the constructor instead.', __METHOD__);
|
||||
|
||||
$this->doSetOperator('' === $operator ? '==' : $operator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests against the target.
|
||||
*
|
||||
* @param mixed $test A test value
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function test($test)
|
||||
public function test(mixed $test): bool
|
||||
{
|
||||
if (null === $this->target) {
|
||||
trigger_deprecation('symfony/finder', '5.4', 'Calling "%s" without initializing the target is deprecated.', __METHOD__);
|
||||
}
|
||||
|
||||
switch ($this->operator) {
|
||||
case '>':
|
||||
return $test > $this->target;
|
||||
@@ -105,13 +65,4 @@ class Comparator
|
||||
|
||||
return $test == $this->target;
|
||||
}
|
||||
|
||||
private function doSetOperator(string $operator): void
|
||||
{
|
||||
if (!\in_array($operator, ['>', '<', '>=', '<=', '==', '!='])) {
|
||||
throw new \InvalidArgumentException(sprintf('Invalid operator "%s".', $operator));
|
||||
}
|
||||
|
||||
$this->operator = $operator;
|
||||
}
|
||||
}
|
||||
|
||||
112
vendor/symfony/finder/Finder.php
vendored
112
vendor/symfony/finder/Finder.php
vendored
@@ -45,27 +45,27 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
public const IGNORE_DOT_FILES = 2;
|
||||
public const IGNORE_VCS_IGNORED_FILES = 4;
|
||||
|
||||
private $mode = 0;
|
||||
private $names = [];
|
||||
private $notNames = [];
|
||||
private $exclude = [];
|
||||
private $filters = [];
|
||||
private $depths = [];
|
||||
private $sizes = [];
|
||||
private $followLinks = false;
|
||||
private $reverseSorting = false;
|
||||
private $sort = false;
|
||||
private $ignore = 0;
|
||||
private $dirs = [];
|
||||
private $dates = [];
|
||||
private $iterators = [];
|
||||
private $contains = [];
|
||||
private $notContains = [];
|
||||
private $paths = [];
|
||||
private $notPaths = [];
|
||||
private $ignoreUnreadableDirs = false;
|
||||
private int $mode = 0;
|
||||
private array $names = [];
|
||||
private array $notNames = [];
|
||||
private array $exclude = [];
|
||||
private array $filters = [];
|
||||
private array $depths = [];
|
||||
private array $sizes = [];
|
||||
private bool $followLinks = false;
|
||||
private bool $reverseSorting = false;
|
||||
private \Closure|int|false $sort = false;
|
||||
private int $ignore = 0;
|
||||
private array $dirs = [];
|
||||
private array $dates = [];
|
||||
private array $iterators = [];
|
||||
private array $contains = [];
|
||||
private array $notContains = [];
|
||||
private array $paths = [];
|
||||
private array $notPaths = [];
|
||||
private bool $ignoreUnreadableDirs = false;
|
||||
|
||||
private static $vcsPatterns = ['.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg'];
|
||||
private static array $vcsPatterns = ['.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg'];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -74,10 +74,8 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
|
||||
/**
|
||||
* Creates a new Finder.
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function create()
|
||||
public static function create(): static
|
||||
{
|
||||
return new static();
|
||||
}
|
||||
@@ -87,7 +85,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function directories()
|
||||
public function directories(): static
|
||||
{
|
||||
$this->mode = Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES;
|
||||
|
||||
@@ -99,7 +97,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function files()
|
||||
public function files(): static
|
||||
{
|
||||
$this->mode = Iterator\FileTypeFilterIterator::ONLY_FILES;
|
||||
|
||||
@@ -122,7 +120,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
* @see DepthRangeFilterIterator
|
||||
* @see NumberComparator
|
||||
*/
|
||||
public function depth($levels)
|
||||
public function depth(string|int|array $levels): static
|
||||
{
|
||||
foreach ((array) $levels as $level) {
|
||||
$this->depths[] = new Comparator\NumberComparator($level);
|
||||
@@ -150,7 +148,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
* @see DateRangeFilterIterator
|
||||
* @see DateComparator
|
||||
*/
|
||||
public function date($dates)
|
||||
public function date(string|array $dates): static
|
||||
{
|
||||
foreach ((array) $dates as $date) {
|
||||
$this->dates[] = new Comparator\DateComparator($date);
|
||||
@@ -175,7 +173,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* @see FilenameFilterIterator
|
||||
*/
|
||||
public function name($patterns)
|
||||
public function name(string|array $patterns): static
|
||||
{
|
||||
$this->names = array_merge($this->names, (array) $patterns);
|
||||
|
||||
@@ -191,7 +189,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* @see FilenameFilterIterator
|
||||
*/
|
||||
public function notName($patterns)
|
||||
public function notName(string|array $patterns): static
|
||||
{
|
||||
$this->notNames = array_merge($this->notNames, (array) $patterns);
|
||||
|
||||
@@ -213,7 +211,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* @see FilecontentFilterIterator
|
||||
*/
|
||||
public function contains($patterns)
|
||||
public function contains(string|array $patterns): static
|
||||
{
|
||||
$this->contains = array_merge($this->contains, (array) $patterns);
|
||||
|
||||
@@ -235,7 +233,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* @see FilecontentFilterIterator
|
||||
*/
|
||||
public function notContains($patterns)
|
||||
public function notContains(string|array $patterns): static
|
||||
{
|
||||
$this->notContains = array_merge($this->notContains, (array) $patterns);
|
||||
|
||||
@@ -259,7 +257,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* @see FilenameFilterIterator
|
||||
*/
|
||||
public function path($patterns)
|
||||
public function path(string|array $patterns): static
|
||||
{
|
||||
$this->paths = array_merge($this->paths, (array) $patterns);
|
||||
|
||||
@@ -283,7 +281,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* @see FilenameFilterIterator
|
||||
*/
|
||||
public function notPath($patterns)
|
||||
public function notPath(string|array $patterns): static
|
||||
{
|
||||
$this->notPaths = array_merge($this->notPaths, (array) $patterns);
|
||||
|
||||
@@ -305,7 +303,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
* @see SizeRangeFilterIterator
|
||||
* @see NumberComparator
|
||||
*/
|
||||
public function size($sizes)
|
||||
public function size(string|int|array $sizes): static
|
||||
{
|
||||
foreach ((array) $sizes as $size) {
|
||||
$this->sizes[] = new Comparator\NumberComparator($size);
|
||||
@@ -327,7 +325,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* @see ExcludeDirectoryFilterIterator
|
||||
*/
|
||||
public function exclude($dirs)
|
||||
public function exclude(string|array $dirs): static
|
||||
{
|
||||
$this->exclude = array_merge($this->exclude, (array) $dirs);
|
||||
|
||||
@@ -343,7 +341,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* @see ExcludeDirectoryFilterIterator
|
||||
*/
|
||||
public function ignoreDotFiles(bool $ignoreDotFiles)
|
||||
public function ignoreDotFiles(bool $ignoreDotFiles): static
|
||||
{
|
||||
if ($ignoreDotFiles) {
|
||||
$this->ignore |= static::IGNORE_DOT_FILES;
|
||||
@@ -363,7 +361,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* @see ExcludeDirectoryFilterIterator
|
||||
*/
|
||||
public function ignoreVCS(bool $ignoreVCS)
|
||||
public function ignoreVCS(bool $ignoreVCS): static
|
||||
{
|
||||
if ($ignoreVCS) {
|
||||
$this->ignore |= static::IGNORE_VCS_FILES;
|
||||
@@ -381,7 +379,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function ignoreVCSIgnored(bool $ignoreVCSIgnored)
|
||||
public function ignoreVCSIgnored(bool $ignoreVCSIgnored): static
|
||||
{
|
||||
if ($ignoreVCSIgnored) {
|
||||
$this->ignore |= static::IGNORE_VCS_IGNORED_FILES;
|
||||
@@ -399,7 +397,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* @param string|string[] $pattern VCS patterns to ignore
|
||||
*/
|
||||
public static function addVCSPattern($pattern)
|
||||
public static function addVCSPattern(string|array $pattern)
|
||||
{
|
||||
foreach ((array) $pattern as $p) {
|
||||
self::$vcsPatterns[] = $p;
|
||||
@@ -419,7 +417,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* @see SortableIterator
|
||||
*/
|
||||
public function sort(\Closure $closure)
|
||||
public function sort(\Closure $closure): static
|
||||
{
|
||||
$this->sort = $closure;
|
||||
|
||||
@@ -435,7 +433,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* @see SortableIterator
|
||||
*/
|
||||
public function sortByName(bool $useNaturalSort = false)
|
||||
public function sortByName(bool $useNaturalSort = false): static
|
||||
{
|
||||
$this->sort = $useNaturalSort ? Iterator\SortableIterator::SORT_BY_NAME_NATURAL : Iterator\SortableIterator::SORT_BY_NAME;
|
||||
|
||||
@@ -451,7 +449,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* @see SortableIterator
|
||||
*/
|
||||
public function sortByType()
|
||||
public function sortByType(): static
|
||||
{
|
||||
$this->sort = Iterator\SortableIterator::SORT_BY_TYPE;
|
||||
|
||||
@@ -469,7 +467,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* @see SortableIterator
|
||||
*/
|
||||
public function sortByAccessedTime()
|
||||
public function sortByAccessedTime(): static
|
||||
{
|
||||
$this->sort = Iterator\SortableIterator::SORT_BY_ACCESSED_TIME;
|
||||
|
||||
@@ -481,7 +479,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function reverseSorting()
|
||||
public function reverseSorting(): static
|
||||
{
|
||||
$this->reverseSorting = true;
|
||||
|
||||
@@ -501,7 +499,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* @see SortableIterator
|
||||
*/
|
||||
public function sortByChangedTime()
|
||||
public function sortByChangedTime(): static
|
||||
{
|
||||
$this->sort = Iterator\SortableIterator::SORT_BY_CHANGED_TIME;
|
||||
|
||||
@@ -519,7 +517,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* @see SortableIterator
|
||||
*/
|
||||
public function sortByModifiedTime()
|
||||
public function sortByModifiedTime(): static
|
||||
{
|
||||
$this->sort = Iterator\SortableIterator::SORT_BY_MODIFIED_TIME;
|
||||
|
||||
@@ -536,7 +534,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* @see CustomFilterIterator
|
||||
*/
|
||||
public function filter(\Closure $closure)
|
||||
public function filter(\Closure $closure): static
|
||||
{
|
||||
$this->filters[] = $closure;
|
||||
|
||||
@@ -548,7 +546,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function followLinks()
|
||||
public function followLinks(): static
|
||||
{
|
||||
$this->followLinks = true;
|
||||
|
||||
@@ -562,7 +560,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function ignoreUnreadableDirs(bool $ignore = true)
|
||||
public function ignoreUnreadableDirs(bool $ignore = true): static
|
||||
{
|
||||
$this->ignoreUnreadableDirs = $ignore;
|
||||
|
||||
@@ -578,7 +576,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* @throws DirectoryNotFoundException if one of the directories does not exist
|
||||
*/
|
||||
public function in($dirs)
|
||||
public function in(string|array $dirs): static
|
||||
{
|
||||
$resolvedDirs = [];
|
||||
|
||||
@@ -607,8 +605,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* @throws \LogicException if the in() method has not been called
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function getIterator()
|
||||
public function getIterator(): \Iterator
|
||||
{
|
||||
if (0 === \count($this->dirs) && 0 === \count($this->iterators)) {
|
||||
throw new \LogicException('You must call one of in() or append() methods before iterating over a Finder.');
|
||||
@@ -651,7 +648,7 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
*
|
||||
* @throws \InvalidArgumentException when the given argument is not iterable
|
||||
*/
|
||||
public function append(iterable $iterator)
|
||||
public function append(iterable $iterator): static
|
||||
{
|
||||
if ($iterator instanceof \IteratorAggregate) {
|
||||
$this->iterators[] = $iterator->getIterator();
|
||||
@@ -673,10 +670,8 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
|
||||
/**
|
||||
* Check if any results were found.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasResults()
|
||||
public function hasResults(): bool
|
||||
{
|
||||
foreach ($this->getIterator() as $_) {
|
||||
return true;
|
||||
@@ -687,11 +682,8 @@ class Finder implements \IteratorAggregate, \Countable
|
||||
|
||||
/**
|
||||
* Counts all the results collected by the iterators.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function count()
|
||||
public function count(): int
|
||||
{
|
||||
return iterator_count($this->getIterator());
|
||||
}
|
||||
|
||||
4
vendor/symfony/finder/Glob.php
vendored
4
vendor/symfony/finder/Glob.php
vendored
@@ -37,10 +37,8 @@ class Glob
|
||||
{
|
||||
/**
|
||||
* Returns a regexp which is the equivalent of the glob pattern.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function toRegex(string $glob, bool $strictLeadingDot = true, bool $strictWildcardSlash = true, string $delimiter = '#')
|
||||
public static function toRegex(string $glob, bool $strictLeadingDot = true, bool $strictWildcardSlash = true, string $delimiter = '#'): string
|
||||
{
|
||||
$firstByte = true;
|
||||
$escaping = false;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user