N°6934 - Symfony 6.4 - upgrade Symfony bundles to 6.4 (#580)

* Update Symfony lib to version ~6.4.0
* Update code missing return type
* Add an iTop general configuration entry to store application secret (Symfony mandatory parameter)
* Use dependency injection in ExceptionListener & UserProvider classes
This commit is contained in:
bdalsass
2023-12-05 13:56:56 +01:00
committed by GitHub
parent 863ab4560c
commit 27ce51ab07
1392 changed files with 44869 additions and 27799 deletions

View File

@@ -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 ?InputArgument $lastArrayArgument = null;
private ?InputArgument $lastOptionalArgument = null;
private array $options = [];
private array $negations = [];
private array $shortcuts = [];
/**
* @param array $definition An array of InputArgument and InputOption instance
@@ -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)
@@ -124,13 +132,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 +147,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 +160,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 +184,7 @@ class InputDefinition
/**
* @return array<string|bool|int|float|array|null>
*/
public function getArgumentDefaults()
public function getArgumentDefaults(): array
{
$values = [];
foreach ($this->arguments as $argument) {
@@ -202,6 +198,8 @@ class InputDefinition
* Sets the InputOption objects.
*
* @param InputOption[] $options An array of InputOption objects
*
* @return void
*/
public function setOptions(array $options = [])
{
@@ -215,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 = [])
{
@@ -224,6 +224,8 @@ class InputDefinition
}
/**
* @return void
*
* @throws LogicException When option given already exist
*/
public function addOption(InputOption $option)
@@ -262,11 +264,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 +280,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 +291,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 +314,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 +323,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 +367,8 @@ class InputDefinition
/**
* Gets the synopsis.
*
* @return string
*/
public function getSynopsis(bool $short = false)
public function getSynopsis(bool $short = false): string
{
$elements = [];