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 a8e1131

Browse filesBrowse files
committed
fixed logic
1 parent 622c62d commit a8e1131
Copy full SHA for a8e1131

File tree

5 files changed

+12
-24
lines changed
Filter options

5 files changed

+12
-24
lines changed

‎src/Symfony/Component/Console/Application.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Application.php
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
3636
use Symfony\Component\Console\Exception\CommandNotFoundException;
3737
use Symfony\Component\Console\Exception\LogicException;
38-
use Symfony\Component\Console\Terminal;
3938
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
4039

4140
/**

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Helper/ProgressBar.php
+10-19Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -413,9 +413,7 @@ public function display()
413413
$this->setRealFormat($this->internalFormat ?: $this->determineBestFormat());
414414
}
415415

416-
$line = $this->buildLine();
417-
$line = $this->adjustLineWidthToTerminalWidth($line);
418-
$this->overwrite($line);
416+
$this->overwrite($this->buildLine());
419417
}
420418

421419
/**
@@ -601,7 +599,8 @@ private static function initFormats()
601599
*/
602600
private function buildLine()
603601
{
604-
return preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) {
602+
$regex = "{%([a-z\-_]+)(?:\:([^%]+))?%}i";
603+
$callback = function ($matches) {
605604
if ($formatter = $this::getPlaceholderFormatterDefinition($matches[1])) {
606605
$text = call_user_func($formatter, $this, $this->output);
607606
} elseif (isset($this->messages[$matches[1]])) {
@@ -615,25 +614,17 @@ private function buildLine()
615614
}
616615

617616
return $text;
618-
}, $this->format);
619-
}
617+
};
618+
$line = preg_replace_callback($regex, $callback, $this->format);
620619

621-
/**
622-
* @param string $line
623-
*
624-
* @return bool
625-
*/
626-
private function adjustLineWidthToTerminalWidth($line)
627-
{
628620
$lineLength = Helper::strlenWithoutDecoration($this->output->getFormatter(), $line);
629621
$terminalWidth = $this->terminal->getWidth();
630-
if ($lineLength > $terminalWidth) {
631-
$newBarWidth = $this->barWidth - $lineLength + $terminalWidth;
632-
$this->setBarWidth($newBarWidth);
633-
634-
return $this->buildLine();
622+
if ($lineLength <= $terminalWidth) {
623+
return $line;
635624
}
636625

637-
return $line;
626+
$this->setBarWidth($this->barWidth - $lineLength + $terminalWidth);
627+
628+
return preg_replace_callback($regex, $callback, $this->format);
638629
}
639630
}

‎src/Symfony/Component/Console/Style/SymfonyStyle.php

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

1212
namespace Symfony\Component\Console\Style;
1313

14-
use Symfony\Component\Console\Application;
1514
use Symfony\Component\Console\Exception\RuntimeException;
1615
use Symfony\Component\Console\Formatter\OutputFormatter;
1716
use Symfony\Component\Console\Helper\Helper;

‎src/Symfony/Component/Console/Terminal.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Terminal.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function getWidth()
3333
/**
3434
* Sets the terminal width.
3535
*
36-
* @param int
36+
* @param int $width
3737
*/
3838
public function setWidth($width)
3939
{
@@ -57,7 +57,7 @@ public function getHeight()
5757
/**
5858
* Sets the terminal height.
5959
*
60-
* @param int
60+
* @param int $height
6161
*/
6262
public function setHeight($height)
6363
{

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Symfony\Component\Console\Helper\ProgressBar;
1515
use Symfony\Component\Console\Helper\Helper;
1616
use Symfony\Component\Console\Output\StreamOutput;
17-
use Symfony\Component\Console\Terminal;
1817

1918
/**
2019
* @group time-sensitive

0 commit comments

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