🔧
This commit is contained in:
19
vendor/symfony/console/Helper/ProgressBar.php
vendored
19
vendor/symfony/console/Helper/ProgressBar.php
vendored
@@ -183,9 +183,9 @@ final class ProgressBar
|
||||
$this->messages[$name] = $message;
|
||||
}
|
||||
|
||||
public function getMessage(string $name = 'message'): string
|
||||
public function getMessage(string $name = 'message'): ?string
|
||||
{
|
||||
return $this->messages[$name];
|
||||
return $this->messages[$name] ?? null;
|
||||
}
|
||||
|
||||
public function getStartTime(): int
|
||||
@@ -229,7 +229,7 @@ final class ProgressBar
|
||||
|
||||
public function getRemaining(): float
|
||||
{
|
||||
if (!$this->step) {
|
||||
if (0 === $this->step || $this->step === $this->startingStep) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -313,7 +313,7 @@ final class ProgressBar
|
||||
*
|
||||
* @return iterable<TKey, TValue>
|
||||
*/
|
||||
public function iterate(iterable $iterable, int $max = null): iterable
|
||||
public function iterate(iterable $iterable, ?int $max = null): iterable
|
||||
{
|
||||
$this->start($max ?? (is_countable($iterable) ? \count($iterable) : 0));
|
||||
|
||||
@@ -332,7 +332,7 @@ final class ProgressBar
|
||||
* @param int|null $max Number of steps to complete the bar (0 if indeterminate), null to leave unchanged
|
||||
* @param int $startAt The starting point of the bar (useful e.g. when resuming a previously started bar)
|
||||
*/
|
||||
public function start(int $max = null, int $startAt = 0): void
|
||||
public function start(?int $max = null, int $startAt = 0): void
|
||||
{
|
||||
$this->startTime = time();
|
||||
$this->step = $startAt;
|
||||
@@ -486,12 +486,21 @@ final class ProgressBar
|
||||
if ($this->output instanceof ConsoleSectionOutput) {
|
||||
$messageLines = explode("\n", $this->previousMessage);
|
||||
$lineCount = \count($messageLines);
|
||||
|
||||
$lastLineWithoutDecoration = Helper::removeDecoration($this->output->getFormatter(), end($messageLines) ?? '');
|
||||
|
||||
// When the last previous line is empty (without formatting) it is already cleared by the section output, so we don't need to clear it again
|
||||
if ('' === $lastLineWithoutDecoration) {
|
||||
--$lineCount;
|
||||
}
|
||||
|
||||
foreach ($messageLines as $messageLine) {
|
||||
$messageLineLength = Helper::width(Helper::removeDecoration($this->output->getFormatter(), $messageLine));
|
||||
if ($messageLineLength > $this->terminal->getWidth()) {
|
||||
$lineCount += floor($messageLineLength / $this->terminal->getWidth());
|
||||
}
|
||||
}
|
||||
|
||||
$this->output->clear($lineCount);
|
||||
} else {
|
||||
$lineCount = substr_count($this->previousMessage, "\n");
|
||||
|
||||
Reference in New Issue
Block a user