-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Description
Symfony version(s) affected: 4.1.0 and higher
Description
ConsoleSectionOutput
always writes with a newline even if explicitly set to false, eg.:
$section->write('foo', false);
since isDecorated()
always returns true
by default. Output behaves correctly if $section->setDecorated(false);
but all decoration is automatically gone which should not be the case.
How to reproduce
<?php
namespace App\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class TestCommand extends Command
{
protected function configure(): void
{
$this->setName('test-command');
parent::configure();
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
/** @var \Symfony\Component\Console\Output\ConsoleOutputInterface $output */
$section = $output->section();
for ($i = 0; $i < 100; $i++) {
$section->write('Element ' . (string) $i, false);
}
return 0;
}
}
Possible Solution
$newline
argument value should be taken into account in this method: https://github.com/symfony/console/blob/v4.1.0/Output/ConsoleSectionOutput.php#L97
Once confirmed I'm more than happy to create a PR that fixes it 🙂