Skip to content

Commit 5f8a196

Browse files
committed
Merge branch '2.8' into 3.0
* 2.8: [Console] use ANSI escape sequences in ProgressBar overwrite method [HttpKernel] Fix wrong number of arguments in call of ExceptionListener::logException() [DependencyInjection] Remove YAML check in CrossCheckTest [Process] Consistently use getProcess() in tests [LDAP] Free the search result after a search to free memory [DependencyInjection] fix phpDoc
2 parents e72d509 + db31b56 commit 5f8a196

26 files changed

+43
-114
lines changed

src/Symfony/Component/Console/Helper/ProgressBar.php

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ class ProgressBar
4141
private $startTime;
4242
private $stepWidth;
4343
private $percent = 0.0;
44-
private $lastMessagesLength = 0;
4544
private $formatLineCount;
4645
private $messages;
4746
private $overwrite = true;
@@ -437,7 +436,7 @@ public function clear()
437436
$this->setRealFormat($this->internalFormat ?: $this->determineBestFormat());
438437
}
439438

440-
$this->overwrite(str_repeat("\n", $this->formatLineCount));
439+
$this->overwrite('');
441440
}
442441

443442
/**
@@ -477,37 +476,22 @@ private function setMaxSteps($max)
477476
*/
478477
private function overwrite($message)
479478
{
480-
$lines = explode("\n", $message);
481-
482-
// append whitespace to match the line's length
483-
if (null !== $this->lastMessagesLength) {
484-
foreach ($lines as $i => $line) {
485-
if ($this->lastMessagesLength > Helper::strlenWithoutDecoration($this->output->getFormatter(), $line)) {
486-
$lines[$i] = str_pad($line, $this->lastMessagesLength, "\x20", STR_PAD_RIGHT);
487-
}
488-
}
489-
}
490-
491479
if ($this->overwrite) {
492-
// move back to the beginning of the progress bar before redrawing it
480+
// Move the cursor to the beginning of the line
493481
$this->output->write("\x0D");
494-
} elseif ($this->step > 0) {
495-
// move to new line
496-
$this->output->writeln('');
497-
}
498482

499-
if ($this->formatLineCount) {
500-
$this->output->write(sprintf("\033[%dA", $this->formatLineCount));
501-
}
502-
$this->output->write(implode("\n", $lines));
483+
// Erase the line
484+
$this->output->write("\x1B[2K");
503485

504-
$this->lastMessagesLength = 0;
505-
foreach ($lines as $line) {
506-
$len = Helper::strlenWithoutDecoration($this->output->getFormatter(), $line);
507-
if ($len > $this->lastMessagesLength) {
508-
$this->lastMessagesLength = $len;
486+
// Erase previous lines
487+
if ($this->formatLineCount > 0) {
488+
$this->output->write(str_repeat("\x1B[1A\x1B[2K", $this->formatLineCount));
509489
}
490+
} elseif ($this->step > 0) {
491+
$this->output->writeln('');
510492
}
493+
494+
$this->output->write($message);
511495
}
512496

513497
private function determineBestFormat()

src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public function testOverwriteWithShorterLine()
233233
$this->generateOutput(' 0/50 [>---------------------------] 0%').
234234
$this->generateOutput(' 0/50 [>---------------------------] 0%').
235235
$this->generateOutput(' 1/50 [>---------------------------] 2%').
236-
$this->generateOutput(' 2/50 [=>--------------------------] '),
236+
$this->generateOutput(' 2/50 [=>--------------------------]'),
237237
stream_get_contents($output->getStream())
238238
);
239239
}
@@ -353,7 +353,7 @@ public function testClear()
353353
$this->assertEquals(
354354
$this->generateOutput(' 0/50 [>---------------------------] 0%').
355355
$this->generateOutput(' 25/50 [==============>-------------] 50%').
356-
$this->generateOutput(' '),
356+
$this->generateOutput(''),
357357
stream_get_contents($output->getStream())
358358
);
359359
}
@@ -551,9 +551,9 @@ public function testMultilineFormat()
551551
rewind($output->getStream());
552552
$this->assertEquals(
553553
$this->generateOutput(">---------------------------\nfoobar").
554-
$this->generateOutput("=========>------------------\nfoobar ").
555-
$this->generateOutput(" \n ").
556-
$this->generateOutput("============================\nfoobar "),
554+
$this->generateOutput("=========>------------------\nfoobar").
555+
"\x0D\x1B[2K\x1B[1A\x1B[2K".
556+
$this->generateOutput("============================\nfoobar"),
557557
stream_get_contents($output->getStream())
558558
);
559559
}
@@ -659,6 +659,6 @@ protected function generateOutput($expected)
659659
{
660660
$count = substr_count($expected, "\n");
661661

662-
return "\x0D".($count ? sprintf("\033[%dA", $count) : '').$expected;
662+
return "\x0D\x1B[2K".($count ? str_repeat("\x1B[1A\x1B[2K", $count) : '').$expected;
663663
}
664664
}

src/Symfony/Component/DependencyInjection/Alias.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ class Alias
1717
private $public;
1818

1919
/**
20-
* Constructor.
21-
*
2220
* @param string $id Alias identifier
2321
* @param bool $public If this alias is public
2422
*/

src/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ class AnalyzeServiceReferencesPass implements RepeatablePassInterface
3434
private $onlyConstructorArguments;
3535

3636
/**
37-
* Constructor.
38-
*
3937
* @param bool $onlyConstructorArguments Sets this Service Reference pass to ignore method calls
4038
*/
4139
public function __construct($onlyConstructorArguments = false)

src/Symfony/Component/DependencyInjection/Compiler/Compiler.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ class Compiler
2525
private $loggingFormatter;
2626
private $serviceReferenceGraph;
2727

28-
/**
29-
* Constructor.
30-
*/
3128
public function __construct()
3229
{
3330
$this->passConfig = new PassConfig();

src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ class PassConfig
3535
private $optimizationPasses;
3636
private $removingPasses;
3737

38-
/**
39-
* Constructor.
40-
*/
4138
public function __construct()
4239
{
4340
$this->mergePass = new MergeExtensionConfigurationPass();

src/Symfony/Component/DependencyInjection/Compiler/RepeatedPass.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ class RepeatedPass implements CompilerPassInterface
3232
private $passes;
3333

3434
/**
35-
* Constructor.
36-
*
3735
* @param RepeatablePassInterface[] $passes An array of RepeatablePassInterface objects
3836
*
3937
* @throws InvalidArgumentException when the passes don't implement RepeatablePassInterface

src/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraphEdge.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ class ServiceReferenceGraphEdge
2525
private $value;
2626

2727
/**
28-
* Constructor.
29-
*
3028
* @param ServiceReferenceGraphNode $sourceNode
3129
* @param ServiceReferenceGraphNode $destNode
3230
* @param string $value

src/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraphNode.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ class ServiceReferenceGraphNode
2929
private $value;
3030

3131
/**
32-
* Constructor.
33-
*
3432
* @param string $id The node identifier
3533
* @param mixed $value The node value
3634
*/

src/Symfony/Component/DependencyInjection/Container.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ class Container implements ResettableContainerInterface
7171
private $underscoreMap = array('_' => '', '.' => '_', '\\' => '_');
7272

7373
/**
74-
* Constructor.
75-
*
7674
* @param ParameterBagInterface $parameterBag A ParameterBagInterface instance
7775
*/
7876
public function __construct(ParameterBagInterface $parameterBag = null)

0 commit comments

Comments
 (0)