-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
AbstractDumper: decimalPoint fails for pt-BR #46156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Which version of PHP are you using ? |
And which locale is configured on your system ? (the PHP locale as set through |
@stof I am running PHP 8.1.1, Windows 11. The locale is |
@stof while you asked, I remembered that PHP 8 performs float to string cast with locale-independent. So the $this->decimalPoint = PHP_VERSION_ID >= 80000
? '.'
: str_replace('1', '', (string) 1.1); https://wiki.php.net/rfc/locale_independent_float_to_string |
Good call, can you please send a PR on branch 4.4? |
To be independent from the float precision, the check should use substr instead of str_replace, see https://3v4l.org/fkpmo |
Well, for PHP 7, the usage of |
|
@stof @nicolas-grekas If it's possible for any of you, please do a PR. I don't have the project here. |
This PR was merged into the 4.4 branch. Discussion ---------- [VarDumper] Fix dumping floats on PHP8 | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #46156 | License | MIT | Doc PR | - Commits ------- 472072e [VarDumper] Fix dumping floats on PHP8
Checked! Now all is working fine. |
Symfony version(s) affected
6.0.6
Description
When I
dd(12.5)
, for instance, it is presented likefloat 12.5,0
.How to reproduce
dd(12.5)
Possible Solution
I can't help with a definitive solution, but I research where the problem is started, and is basically from
AbstractDumper
constructor, that depends onlocaleconv()
information. The float to string conversion occur inCliDumper::dumpScalar()
.For me, it returns:
The float dumper is something like:
But
(string) $value
returnsstring '12.5'
, that is incompatible tolocaleconv()
info.My suggestion is detect separator based on a float info directly. For instance:
Additional Context
No response
The text was updated successfully, but these errors were encountered: