Skip to content

Conversation

@nickbeen
Copy link
Owner

What does this pull request do?

This PR fixes misleading progress indicators when both progress and maxProgress are equal to zero. Originally both values would reset to one to avoid a DivisionByZero error (#22).

Fixes #25

Why is this pull request needed?

This new behavior will show the correct progress values in situations where a programmatic loop has nothing to tick through.

This PR will be released within a new minor version since it changes to behavior of progress and maxProgress for anyone who explicitly checks these values in their code.

$progressBar = new ProgressBar(progress: 0, maxProgress: 0);
$progressBar->start();

while ($i <= 10) {
  continue; /* nothing to tick */
}

$progressBar->finish();

/* previous behavior */
1/1 [############################] 100% 

/* new behavior */
0/0 [############################] 100% 

How does this pull request work?

Values for progress and maxProgress no longer reset to one when both values are zero by default. When both values are zero, the percentage is automatically set to 100% without any calculation to avoid a DivisionByZero error.

@nickbeen nickbeen self-assigned this Aug 23, 2025
@nickbeen nickbeen added fixed For any bug fixes changed For changes in existing functionality labels Aug 23, 2025
@nickbeen nickbeen merged commit 0e9a7d3 into main Aug 23, 2025
10 of 11 checks passed
@nickbeen nickbeen deleted the zero-progress-bug branch August 23, 2025 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changed For changes in existing functionality fixed For any bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: When maxProgress is zero, finish() says it is one

2 participants