You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
…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
Symfony version(s) affected: 3.4, 4.4, 5.0, ...
Description
When using the NumberType, the reverse transform method does:
Which means,
1
is submitted, an int should be set.1.0
is submitted, a float should be set.But then, a private function round is called and does:
Which means,
1
is submitted with scalenull
, an int will be set.1
is submitted with scale0
, a float will be set.1
is submitted with scale1
, a float will be set.1.0
is submitted with scalenull
, a float will be set.1.0
is submitted with scale0
, a float will be set.1.0
is submitted with scale1
, a float will be set.It's the same for IntegerToLocalizedStringTransformer since it extends NumberToLocalizedStringTransformer with scale 0.
Possible Solution
Update the private round function to cast the value to int if the scale is
0
.The text was updated successfully, but these errors were encountered: