Skip to content

Commit

Permalink
Merge branch '4.4' into 5.2
Browse files Browse the repository at this point in the history
* 4.4:
  Fix incompatible implicit float-to-int conversions
  [Translation] Don't pass null to strtoupper()
  cs fix
  [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 3685a3a + 9aa1eb4 commit 2f93c8c
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
Expand Up @@ -196,7 +196,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 @@ -270,7 +270,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
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
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 2f93c8c

Please sign in to comment.