-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Disallow passing array as number to NumberFormatter::format() #5181
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
Conversation
Array to number conversion makes no sense here, and is likely to hide a programming error. Therefore we disallow passing an array in the first place.
7a939df
to
bf14447
Compare
Wouldn't it maybe be better to say that the value must be a scalar? Slight glimpse at the source code but non-stringable object should probably also throw. (and small drive-by but the invalid format should also throw a ValueError but that should probably be done while converting most of them from the extension) |
Eh, maybe accept |
I'm imagining some people might use strings directly but that does seem like a more reasonable choice indeed. |
@Girgias That's fine as long as they use weak types. For strict types a string should of course throw. |
Indeed, makes sense :) |
This port of `Z_PARAM_NUMBER` is particularly useful for `zend_parse_method_parameters()`.
We also remove two test cases, since these have been degenerated to ZPP tests.
Yes, makes perfect sense. |
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.
LG. As this is the only use of n
in (normal) zpp right now, I'd suggest adding an explicit test for the case where it throws.
Thanks! I've re-added the adapted bug48227.phpt, and applied as 6ee6097. |
Array to number conversion makes no sense here, and is likely to hide
a programming error. Therefore we disallow passing an array in the
first place.
This is a follow-up to #5141 (comment). Given PR #5092 is work in progress, I've not spend much time on constructing a good error message.