bug #35781 [Form] NumberToLocalizedStringTransformer return int if scale = 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
-------
2993fc9fc5
Return int if scale = 0
This commit is contained in:
commit
34c2e96b08
@ -282,7 +282,7 @@ class NumberToLocalizedStringTransformer implements DataTransformerInterface
|
||||
break;
|
||||
}
|
||||
|
||||
$number /= $roundingCoef;
|
||||
$number = 1 === $roundingCoef ? (int) $number : $number / $roundingCoef;
|
||||
}
|
||||
|
||||
return $number;
|
||||
|
@ -370,7 +370,7 @@ class NumberToLocalizedStringTransformerTest extends TestCase
|
||||
{
|
||||
$transformer = new NumberToLocalizedStringTransformer($scale, null, $roundingMode);
|
||||
|
||||
$this->assertEquals($output, $transformer->reverseTransform($input));
|
||||
$this->assertSame($output, $transformer->reverseTransform($input));
|
||||
}
|
||||
|
||||
public function testReverseTransformDoesNotRoundIfNoScale()
|
||||
|
Reference in New Issue
Block a user