-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consider named argument flags:JSON_THROW_ON_ERROR for json_ functions…
… as "Safe" Manually rebasing, adding unit tests, and fixing the tests, for #33
- Loading branch information
Showing
4 changed files
with
22 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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
5 changes: 5 additions & 0 deletions
5
...Rules/data/safe_json_decode_for_7.3.0.php → tests/Rules/data/safe_json_decode.php
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
<?php | ||
|
||
// Test various combinations of flags | ||
json_decode("{}", true, 512, JSON_THROW_ON_ERROR); | ||
json_decode("{}", true, 512, JSON_INVALID_UTF8_IGNORE | JSON_THROW_ON_ERROR); | ||
json_decode("{}", true, 512, JSON_INVALID_UTF8_IGNORE | JSON_OBJECT_AS_ARRAY | JSON_THROW_ON_ERROR); | ||
|
||
// Test raw integers too | ||
json_decode("{}", true, 512, 4194304); | ||
json_decode("{}", true, 512, 1048576 | 4194304); | ||
json_decode("{}", true, 512, 1048576 | 1 | 4194304); | ||
|
||
// Test named arguments instead of positional | ||
json_decode("{}", flags: JSON_THROW_ON_ERROR); |
This file contains 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