Closed
Description
Symfony version(s) affected
6.0.2
Description
Hi,
With Symfony/Console 6.0.2 and PHP 8.1, there is a depreciation on the method Symfony\Component\Console\Question\ChoiceQuestion::getDefaultValidator() (click on the link to see the line of the issue) :
PHP Deprecated : trim() : Passing null to parameter #1 ($string) of type string is deprecated.
This happens when the default value for the question is null
.
How to reproduce
// Method definition : https://github.com/symfony/console/blob/v6.0.2/Style/SymfonyStyle.php#L277
$io->choice('Select the queue to analyze', ['queue1', 'queue2', 'queue3']); // The 3rd argument must be `null`.
Possible Solution
We can simply cast the variable to string to fix the issue. Just like this at this line:
-$selectedChoices[$k] = trim($v);
+$selectedChoices[$k] = trim((string) $v);
Additional Context
No response