Closed
Description
Symfony version(s) affected
6.3.0-beta+
Description
When trying to obtain message from ProgressBar that was not set previously using setMessage
, the getMessage
method throws TypeError.
In ProgressBar.php line 188:
[TypeError]
Symfony\Component\Console\Helper\ProgressBar::getMessage(): Return value must be of type string, null
The workaround is to catch the TypeError but it is not elegant solution.
How to reproduce
$progressBar = new ProgressBar($output);
$progressBar->getMessage(); // throws TypeError
Possible Solution
- Change type hint of
ProgressBar->getMessage()
to?string
instead ofstring
, add$default
argument +?? $default
to the code. - Add method like
hasMessage(string $name = 'message')
to check if message is available
Additional Context
I have custom service that updates the progress bar only if necessary and thus I have to check if message that was supplied differs from the one that is already set:
https://github.com/cojedzie/cojedzie/blob/master/api/src/DataImport/ConsoleProgressReporter.php#L52-L55