Skip to content

Commit

Permalink
Merge branch '5.2' into 5.3
Browse files Browse the repository at this point in the history
* 5.2:
  Fix incompatible implicit float-to-int conversions
  [Translation] Don't pass null to strtoupper()
  cs fix
  [String] Fix implicit float-to-int casts
  [DependencyInjection] Don't pass null to trim()
  Add return types to JsonSerializable implementations
  Fix Serializable deprecations triggered by token mocks
  Add missing security translations
  • Loading branch information
derrabus committed Jun 6, 2021
2 parents 7d2e068 + 2f93c8c commit da9c0be
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Helper/ProgressBar.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public function getProgressPercent(): float

public function getBarOffset(): float
{
return floor($this->max ? $this->percent * $this->barWidth : (null === $this->redrawFreq ? min(5, $this->barWidth / 15) * $this->writeCount : $this->step) % $this->barWidth);
return floor($this->max ? $this->percent * $this->barWidth : (null === $this->redrawFreq ? (int) (min(5, $this->barWidth / 15) * $this->writeCount) : $this->step) % $this->barWidth);
}

public function getEstimated(): float
Expand Down Expand Up @@ -280,7 +280,7 @@ public function setFormat(string $format)
/**
* Sets the redraw frequency.
*
* @param int|float $freq The frequency in steps
* @param int|null $freq The frequency in steps
*/
public function setRedrawFrequency(?int $freq)
{
Expand Down
2 changes: 1 addition & 1 deletion Helper/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ private function renderRowSeparator(int $type = self::SEPARATOR_MID, string $tit
$formattedTitle = sprintf($titleFormat, Helper::substr($title, 0, $limit - $formatLength - 3).'...');
}

$titleStart = ($markupLength - $titleLength) / 2;
$titleStart = intdiv($markupLength - $titleLength, 2);
if (false === mb_detect_encoding($markup, null, true)) {
$markup = substr_replace($markup, $formattedTitle, $titleStart, $titleLength);
} else {
Expand Down
2 changes: 1 addition & 1 deletion Tests/Helper/ProgressBarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ public function testRedrawFrequencyIsAtLeastOneIfZeroGiven()
public function testRedrawFrequencyIsAtLeastOneIfSmallerOneGiven()
{
$bar = new ProgressBar($output = $this->getOutputStream(), 0, 0);
$bar->setRedrawFrequency(0.9);
$bar->setRedrawFrequency(0);
$bar->start();
$bar->advance();

Expand Down

0 comments on commit da9c0be

Please sign in to comment.