Skip to content

Commit

Permalink
bug #35781 [Form] NumberToLocalizedStringTransformer return int if sc…
Browse files Browse the repository at this point in the history
…ale = 0 (VincentLanglet)

This PR was merged into the 3.4 branch.

Discussion
----------

[Form] NumberToLocalizedStringTransformer return int if scale = 0

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #35775
| License       | MIT
<!--
Replace this notice by a short README for your feature/bugfix. This will help people
understand your PR and can be used as a start for the documentation.

Additionally (see https://symfony.com/releases):
 - Always add tests and ensure they pass.
 - Never break backward compatibility (see https://symfony.com/bc).
 - 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 branch master.
-->

Commits
-------

2993fc9 Return int if scale = 0
  • Loading branch information
fabpot committed Feb 29, 2020
2 parents 7295d25 + 2993fc9 commit 34c2e96
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Expand Up @@ -282,7 +282,7 @@ private function round($number)
break;
}

$number /= $roundingCoef;
$number = 1 === $roundingCoef ? (int) $number : $number / $roundingCoef;
}

return $number;
Expand Down
Expand Up @@ -370,7 +370,7 @@ public function testReverseTransformWithRounding($scale, $input, $output, $round
{
$transformer = new NumberToLocalizedStringTransformer($scale, null, $roundingMode);

$this->assertEquals($output, $transformer->reverseTransform($input));
$this->assertSame($output, $transformer->reverseTransform($input));
}

public function testReverseTransformDoesNotRoundIfNoScale()
Expand Down

0 comments on commit 34c2e96

Please sign in to comment.