Closed
Description
Symfony version(s) affected
symfony/console - 5.4.3
Description
When $message
is null, this line breaks and throws warning.
https://github.com/symfony/console/blob/5.4/Formatter/OutputFormatter.php#L148
How to reproduce
<?php declare(strict_types = 1);
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
final class BrokenFormatterCommand extends Command
{
protected static $defaultName = 'broken-formatter';
/**
* @param InputInterface $input
* @param OutputInterface $output
*
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$output->writeln('ok');
// fails here
$output->writeln(null);
return 0;
}
}
Possible Solution
Change affected line to:
preg_match_all("#<(($openTagRegex) | /($closeTagRegex)?)>#ix", $message ?? '', $matches, \PREG_OFFSET_CAPTURE);
Additional Context
No response