-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Yaml] deprecate comma separators in floats #18785
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand this regexp right, the deprecation error will be triggered for example for numbers like
123.45
but it shouldn't. We'd need to test explicitly the presence of the comma.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, the order of regexps should be changed, to match the standard regex first to handle the case of values matching the spec
This will require to duplicate the line
return (float) str_replace(array(',', '_'), '', $scalar);
instead of using a fallthrough, but this is not an issue.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These cases are already handled further up where we have the
is_numeric()
check (and we have tests covering that this is working).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @javiereguiluz said, this deprecation will be triggered with
123.45
, which is not correct. IMO, the*
should be replaced with a+
to ensure that a,
is indeed used.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, the
+
won't be enough ; we need to test that[0-9]+,[0-9]*(?:\.[0-9_]+)?
matches this I think (but I'm not too sure too)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Taluu but it's true what @xabbuh said: this is handled in the code above this
case:
and there are tests about this and they pass.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it should be triggered for
123.45_67
though (I think), as there are no cases for that above this case, and that is valid though. And I think a_
may have been forgotten in the part before the.
actually.IMO, we should do a
strpos
test to test that a,
is indeed in the match, and then only trigger the deprecationThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Taluu You are right. I opened #18858 which should fix this issue.
I think it's okay the way it is. We only introduced the
_
for 3.2 and I think people should not start mixing_
and,
then. If they want to use_
, they should just move away from,
as well.