mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-25 11:38:44 +02:00
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:
@@ -28,6 +28,7 @@ use Symfony\Component\Console\Exception\RuntimeException;
|
||||
abstract class Input implements InputInterface, StreamableInputInterface
|
||||
{
|
||||
protected $definition;
|
||||
/** @var resource */
|
||||
protected $stream;
|
||||
protected $options = [];
|
||||
protected $arguments = [];
|
||||
@@ -44,7 +45,7 @@ abstract class Input implements InputInterface, StreamableInputInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @return void
|
||||
*/
|
||||
public function bind(InputDefinition $definition)
|
||||
{
|
||||
@@ -57,54 +58,45 @@ abstract class Input implements InputInterface, StreamableInputInterface
|
||||
|
||||
/**
|
||||
* Processes command line arguments.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
abstract protected function parse();
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @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)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isInteractive()
|
||||
public function isInteractive(): bool
|
||||
{
|
||||
return $this->interactive;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @return void
|
||||
*/
|
||||
public function setInteractive(bool $interactive)
|
||||
{
|
||||
$this->interactive = $interactive;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getArguments()
|
||||
public function getArguments(): array
|
||||
{
|
||||
return array_merge($this->definition->getArgumentDefaults(), $this->arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@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));
|
||||
@@ -114,9 +106,9 @@ abstract class Input implements InputInterface, StreamableInputInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @return void
|
||||
*/
|
||||
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));
|
||||
@@ -125,26 +117,17 @@ abstract class Input implements InputInterface, StreamableInputInterface
|
||||
$this->arguments[$name] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasArgument(string $name)
|
||||
public function hasArgument(string $name): bool
|
||||
{
|
||||
return $this->definition->hasArgument($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getOptions()
|
||||
public function getOptions(): array
|
||||
{
|
||||
return array_merge($this->definition->getOptionDefaults(), $this->options);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@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))) {
|
||||
@@ -162,9 +145,9 @@ abstract class Input implements InputInterface, StreamableInputInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @return void
|
||||
*/
|
||||
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;
|
||||
@@ -177,26 +160,23 @@ abstract class Input implements InputInterface, StreamableInputInterface
|
||||
$this->options[$name] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@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);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @param resource $stream
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setStream($stream)
|
||||
{
|
||||
@@ -204,7 +184,7 @@ abstract class Input implements InputInterface, StreamableInputInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @return resource
|
||||
*/
|
||||
public function getStream()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user