Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6a51831

Browse filesBrowse files
committed
feature #9846 [Console] hide output of ProgressHelper when isDecorated is false (kbond)
This PR was merged into the 2.5-dev branch. Discussion ---------- [Console] hide output of ProgressHelper when isDecorated is false | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #9511 | License | MIT | Doc PR | n/a Commits ------- 006cb81 [Console] show no output in ProgressHelper when isDecorated is false (fixes #9511)
2 parents 8d39213 + 006cb81 commit 6a51831
Copy full SHA for 6a51831

File tree

Expand file treeCollapse file tree

2 files changed

+16
-3
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+16
-3
lines changed

‎src/Symfony/Component/Console/Helper/ProgressHelper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Helper/ProgressHelper.php
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Console\Helper;
1313

14+
use Symfony\Component\Console\Output\NullOutput;
1415
use Symfony\Component\Console\Output\OutputInterface;
1516

1617
/**
@@ -185,7 +186,9 @@ public function start(OutputInterface $output, $max = null)
185186
$this->startTime = time();
186187
$this->current = 0;
187188
$this->max = (int) $max;
188-
$this->output = $output;
189+
190+
// Disabling output when it does not support ANSI codes as it would result in a broken display anyway.
191+
$this->output = $output->isDecorated() ? $output : new NullOutput();
189192
$this->lastMessagesLength = 0;
190193
$this->barCharOriginal = '';
191194

‎src/Symfony/Component/Console/Tests/Helper/ProgressHelperTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tests/Helper/ProgressHelperTest.php
+12-2Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,19 @@ public function testPercentNotHundredBeforeComplete()
192192
$this->assertEquals($this->generateOutput(' 0/200 [>---------------------------] 0%').$this->generateOutput(' 199/200 [===========================>] 99%').$this->generateOutput(' 200/200 [============================] 100%'), stream_get_contents($output->getStream()));
193193
}
194194

195-
protected function getOutputStream()
195+
public function testNonDecoratedOutput()
196196
{
197-
return new StreamOutput(fopen('php://memory', 'r+', false));
197+
$progress = new ProgressHelper();
198+
$progress->start($output = $this->getOutputStream(false));
199+
$progress->advance();
200+
201+
rewind($output->getStream());
202+
$this->assertEquals('', stream_get_contents($output->getStream()));
203+
}
204+
205+
protected function getOutputStream($decorated = true)
206+
{
207+
return new StreamOutput(fopen('php://memory', 'r+', false), StreamOutput::VERBOSITY_NORMAL, $decorated);
198208
}
199209

200210
protected $lastMessagesLength;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.