Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 8.1k
Promote warnings to errors in array_flip()#4582
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -12,26 +12,39 @@ $trans = array("a" => 1, | ||
| 0 => "G", | ||
| 1 => "h", | ||
| 2 => "i"); | ||
| $trans = array_flip($trans); | ||
| try { | ||
| $trans = array_flip($trans); | ||
| } catch (\TypeError $e) { | ||
| echo $e->getMessage() . "\n"; | ||
| } | ||
| var_dump($trans); | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this | ||
| ?> | ||
| --EXPECTF-- | ||
| Warning: array_flip(): Can only flip STRING and INTEGER values! in %s on line %d | ||
| Warning: array_flip(): Can only flip STRING and INTEGER values! in %s on line %d | ||
| Warning: array_flip(): Can only flip STRING and INTEGER values! in %s on line %d | ||
| array(6) { | ||
| [1]=> | ||
| string(1) "b" | ||
| [2]=> | ||
| string(1) "c" | ||
| [0]=> | ||
| string(1) "z" | ||
| ["G"]=> | ||
| int(0) | ||
| ["h"]=> | ||
| DONE | ||
| --EXPECT-- | ||
| Can only flip STRING and INTEGER values! | ||
| array(10) { | ||
| ["a"]=> | ||
| int(1) | ||
| ["i"]=> | ||
| ["b"]=> | ||
| int(1) | ||
| ["c"]=> | ||
| int(2) | ||
| ["z"]=> | ||
| int(0) | ||
| ["d"]=> | ||
| bool(true) | ||
| ["E"]=> | ||
| bool(false) | ||
| ["F"]=> | ||
| NULL | ||
| [0]=> | ||
| string(1) "G" | ||
| [1]=> | ||
| string(1) "h" | ||
| [2]=> | ||
| string(1) "i" | ||
| } | ||
| DONE | ||
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.
We should also drop the ALLCAPS and the exclamation mark ... this is a very aggressive warning ;)
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.
@nikic I actually noticed that too and there are more exclamation marks which can be removed. I think a separate PR is better
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.
Should I do the same for array_count_values and group both of them in a single PR ?