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

@@ -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 $input;
/** @var int */
private $statusCode;
private StreamOutput $output;
private array $inputs = [];
private bool $captureStreamsIndependently = false;
private InputInterface $input;
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;
@@ -145,9 +128,9 @@ trait TesterTrait
* * verbosity: Sets the output verbosity flag
* * capture_stderr_separately: Make output of stdOut and stdErr separately available
*/
private function initOutput(array $options)
private function initOutput(array $options): void
{
$this->captureStreamsIndependently = \array_key_exists('capture_stderr_separately', $options) && $options['capture_stderr_separately'];
$this->captureStreamsIndependently = $options['capture_stderr_separately'] ?? false;
if (!$this->captureStreamsIndependently) {
$this->output = new StreamOutput(fopen('php://memory', 'w', false));
if (isset($options['decorated'])) {
@@ -169,12 +152,10 @@ trait TesterTrait
$reflectedOutput = new \ReflectionObject($this->output);
$strErrProperty = $reflectedOutput->getProperty('stderr');
$strErrProperty->setAccessible(true);
$strErrProperty->setValue($this->output, $errorOutput);
$reflectedParent = $reflectedOutput->getParentClass();
$streamProperty = $reflectedParent->getProperty('stream');
$streamProperty->setAccessible(true);
$streamProperty->setValue($this->output, fopen('php://memory', 'w', false));
}
}