composer update, composer corelibs update, admin pages update

This commit is contained in:
Clemens Schwaighofer
2023-05-31 16:17:14 +09:00
parent 513b115d57
commit 3d6b461b20
211 changed files with 10013 additions and 1461 deletions

View File

@@ -55,11 +55,17 @@ class ArgvInput extends Input
parent::__construct($definition);
}
/**
* @return void
*/
protected function setTokens(array $tokens)
{
$this->tokens = $tokens;
}
/**
* @return void
*/
protected function parse()
{
$parseOptions = true;
@@ -89,7 +95,7 @@ class ArgvInput extends Input
/**
* Parses a short option.
*/
private function parseShortOption(string $token)
private function parseShortOption(string $token): void
{
$name = substr($token, 1);
@@ -110,7 +116,7 @@ class ArgvInput extends Input
*
* @throws RuntimeException When option given doesn't exist
*/
private function parseShortOptionSet(string $name)
private function parseShortOptionSet(string $name): void
{
$len = \strlen($name);
for ($i = 0; $i < $len; ++$i) {
@@ -133,7 +139,7 @@ class ArgvInput extends Input
/**
* Parses a long option.
*/
private function parseLongOption(string $token)
private function parseLongOption(string $token): void
{
$name = substr($token, 2);
@@ -152,7 +158,7 @@ class ArgvInput extends Input
*
* @throws RuntimeException When too many arguments are given
*/
private function parseArgument(string $token)
private function parseArgument(string $token): void
{
$c = \count($this->arguments);
@@ -196,7 +202,7 @@ class ArgvInput extends Input
*
* @throws RuntimeException When option given doesn't exist
*/
private function addShortOption(string $shortcut, mixed $value)
private function addShortOption(string $shortcut, mixed $value): void
{
if (!$this->definition->hasShortcut($shortcut)) {
throw new RuntimeException(sprintf('The "-%s" option does not exist.', $shortcut));
@@ -210,7 +216,7 @@ class ArgvInput extends Input
*
* @throws RuntimeException When option given doesn't exist
*/
private function addLongOption(string $name, mixed $value)
private function addLongOption(string $name, mixed $value): void
{
if (!$this->definition->hasOption($name)) {
if (!$this->definition->hasNegation($name)) {

View File

@@ -113,6 +113,9 @@ class ArrayInput extends Input
return implode(' ', $params);
}
/**
* @return void
*/
protected function parse()
{
foreach ($this->parameters as $key => $value) {
@@ -134,7 +137,7 @@ class ArrayInput extends Input
*
* @throws InvalidOptionException When option given doesn't exist
*/
private function addShortOption(string $shortcut, mixed $value)
private function addShortOption(string $shortcut, mixed $value): void
{
if (!$this->definition->hasShortcut($shortcut)) {
throw new InvalidOptionException(sprintf('The "-%s" option does not exist.', $shortcut));
@@ -149,7 +152,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, mixed $value)
private function addLongOption(string $name, mixed $value): void
{
if (!$this->definition->hasOption($name)) {
if (!$this->definition->hasNegation($name)) {
@@ -182,7 +185,7 @@ class ArrayInput extends Input
*
* @throws InvalidArgumentException When argument given doesn't exist
*/
private function addArgument(string|int $name, mixed $value)
private function addArgument(string|int $name, mixed $value): void
{
if (!$this->definition->hasArgument($name)) {
throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));

View File

@@ -43,6 +43,9 @@ abstract class Input implements InputInterface, StreamableInputInterface
}
}
/**
* @return void
*/
public function bind(InputDefinition $definition)
{
$this->arguments = [];
@@ -54,17 +57,20 @@ abstract class Input implements InputInterface, StreamableInputInterface
/**
* Processes command line arguments.
*
* @return void
*/
abstract protected function parse();
/**
* @return void
*/
public function validate()
{
$definition = $this->definition;
$givenArguments = $this->arguments;
$missingArguments = array_filter(array_keys($definition->getArguments()), function ($argument) use ($definition, $givenArguments) {
return !\array_key_exists($argument, $givenArguments) && $definition->getArgument($argument)->isRequired();
});
$missingArguments = array_filter(array_keys($definition->getArguments()), fn ($argument) => !\array_key_exists($argument, $givenArguments) && $definition->getArgument($argument)->isRequired());
if (\count($missingArguments) > 0) {
throw new RuntimeException(sprintf('Not enough arguments (missing: "%s").', implode(', ', $missingArguments)));
@@ -76,6 +82,9 @@ abstract class Input implements InputInterface, StreamableInputInterface
return $this->interactive;
}
/**
* @return void
*/
public function setInteractive(bool $interactive)
{
$this->interactive = $interactive;
@@ -95,6 +104,9 @@ abstract class Input implements InputInterface, StreamableInputInterface
return $this->arguments[$name] ?? $this->definition->getArgument($name)->getDefault();
}
/**
* @return void
*/
public function setArgument(string $name, mixed $value)
{
if (!$this->definition->hasArgument($name)) {
@@ -131,6 +143,9 @@ abstract class Input implements InputInterface, StreamableInputInterface
return \array_key_exists($name, $this->options) ? $this->options[$name] : $this->definition->getOption($name)->getDefault();
}
/**
* @return void
*/
public function setOption(string $name, mixed $value)
{
if ($this->definition->hasNegation($name)) {
@@ -157,11 +172,19 @@ abstract class Input implements InputInterface, StreamableInputInterface
return preg_match('{^[\w-]+$}', $token) ? $token : escapeshellarg($token);
}
/**
* @param resource $stream
*
* @return void
*/
public function setStream($stream)
{
$this->stream = $stream;
}
/**
* @return resource
*/
public function getStream()
{
return $this->stream;

View File

@@ -37,7 +37,7 @@ class InputArgument
/**
* @param string $name The argument name
* @param int|null $mode The argument mode: self::REQUIRED or self::OPTIONAL
* @param int|null $mode The argument mode: a bit mask of self::REQUIRED, self::OPTIONAL and self::IS_ARRAY
* @param string $description A description text
* @param string|bool|int|float|array|null $default The default value (for self::OPTIONAL mode only)
* @param array|\Closure(CompletionInput,CompletionSuggestions):list<string|Suggestion> $suggestedValues The values used for input completion
@@ -91,6 +91,8 @@ class InputArgument
/**
* Sets the default value.
*
* @return void
*
* @throws LogicException When incorrect default value is given
*/
public function setDefault(string|bool|int|float|array $default = null)

View File

@@ -21,6 +21,8 @@ interface InputAwareInterface
{
/**
* Sets the Console Input.
*
* @return void
*/
public function setInput(InputInterface $input);
}

View File

@@ -46,6 +46,8 @@ class InputDefinition
/**
* Sets the definition of the input.
*
* @return void
*/
public function setDefinition(array $definition)
{
@@ -67,6 +69,8 @@ class InputDefinition
* Sets the InputArgument objects.
*
* @param InputArgument[] $arguments An array of InputArgument objects
*
* @return void
*/
public function setArguments(array $arguments = [])
{
@@ -81,6 +85,8 @@ class InputDefinition
* Adds an array of InputArgument objects.
*
* @param InputArgument[] $arguments An array of InputArgument objects
*
* @return void
*/
public function addArguments(?array $arguments = [])
{
@@ -92,6 +98,8 @@ class InputDefinition
}
/**
* @return void
*
* @throws LogicException When incorrect argument is given
*/
public function addArgument(InputArgument $argument)
@@ -190,6 +198,8 @@ class InputDefinition
* Sets the InputOption objects.
*
* @param InputOption[] $options An array of InputOption objects
*
* @return void
*/
public function setOptions(array $options = [])
{
@@ -203,6 +213,8 @@ class InputDefinition
* Adds an array of InputOption objects.
*
* @param InputOption[] $options An array of InputOption objects
*
* @return void
*/
public function addOptions(array $options = [])
{
@@ -212,6 +224,8 @@ class InputDefinition
}
/**
* @return void
*
* @throws LogicException When option given already exist
*/
public function addOption(InputOption $option)

View File

@@ -61,6 +61,8 @@ interface InputInterface
/**
* Binds the current Input instance with the given arguments and options.
*
* @return void
*
* @throws RuntimeException
*/
public function bind(InputDefinition $definition);
@@ -68,6 +70,8 @@ interface InputInterface
/**
* Validates the input.
*
* @return void
*
* @throws RuntimeException When not enough arguments are given
*/
public function validate();
@@ -91,6 +95,8 @@ interface InputInterface
/**
* Sets an argument value by name.
*
* @return void
*
* @throws InvalidArgumentException When argument given doesn't exist
*/
public function setArgument(string $name, mixed $value);
@@ -119,6 +125,8 @@ interface InputInterface
/**
* Sets an option value by name.
*
* @return void
*
* @throws InvalidArgumentException When option given doesn't exist
*/
public function setOption(string $name, mixed $value);
@@ -135,6 +143,8 @@ interface InputInterface
/**
* Sets the input interactivity.
*
* @return void
*/
public function setInteractive(bool $interactive);
}

View File

@@ -178,6 +178,9 @@ class InputOption
return self::VALUE_NEGATABLE === (self::VALUE_NEGATABLE & $this->mode);
}
/**
* @return void
*/
public function setDefault(string|bool|int|float|array $default = null)
{
if (1 > \func_num_args()) {

View File

@@ -25,6 +25,8 @@ interface StreamableInputInterface extends InputInterface
* This is mainly useful for testing purpose.
*
* @param resource $stream The input stream
*
* @return void
*/
public function setStream($stream);