Skip to content

Commit 51d824a

Browse files
committed
bug symfony#59069 [Console] Fix division by 0 error (Rindula)
This PR was squashed before being merged into the 6.4 branch. Discussion ---------- [Console] Fix division by 0 error | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Issues | Fix symfony#59067 <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead --> | License | MIT <!-- Replace this notice by a description of your feature/bugfix. This will help reviewers and should be a good start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against the latest branch. - For new features, provide some code snippets to help understand usage. - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry - Never break backward compatibility (see https://symfony.com/bc). --> Commits ------- ee400b0 [Console] Fix division by 0 error
2 parents 74e9163 + ee400b0 commit 51d824a

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ public function getEstimated(): float
229229

230230
public function getRemaining(): float
231231
{
232-
if (!$this->step) {
232+
if (0 === $this->step || $this->step === $this->startingStep) {
233233
return 0;
234234
}
235235

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,14 @@ public function testRegularTimeEstimation()
110110
);
111111
}
112112

113+
public function testRegularTimeRemainingWithDifferentStartAtAndCustomDisplay()
114+
{
115+
ProgressBar::setFormatDefinition('custom', ' %current%/%max% [%bar%] %percent:3s%% %remaining% %estimated%');
116+
$bar = new ProgressBar($output = $this->getOutputStream(), 1_200, 0);
117+
$bar->setFormat('custom');
118+
$bar->start(1_200, 600);
119+
}
120+
113121
public function testResumedTimeEstimation()
114122
{
115123
$bar = new ProgressBar($output = $this->getOutputStream(), 1_200, 0);

0 commit comments

Comments
 (0)