Skip to content

Commit 8e8a0b4

Browse files
committed
[json_decode] update function signature to match PHP 8.X, fixes #645
1 parent f19e1f4 commit 8e8a0b4

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/special_cases.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,15 @@
2424
* Wrapper for json_decode that throws when an error occurs.
2525
*
2626
* @param string $json JSON data to parse
27-
* @param bool $associative When true, returned objects will be converted
28-
* into associative arrays.
27+
* @param bool|null $associative true for arrays, false for objects, null to defer to $flags
2928
* @param int<1, max> $depth User specified recursion depth.
3029
* @param int $flags Bitmask of JSON decode options.
3130
*
3231
* @return mixed
3332
* @throws JsonException if the JSON cannot be decoded.
3433
* @link http://www.php.net/manual/en/function.json-decode.php
3534
*/
36-
function json_decode(string $json, bool $associative = false, int $depth = 512, int $flags = 0): mixed
35+
function json_decode(string $json, ?bool $associative = null, int $depth = 512, int $flags = 0): mixed
3736
{
3837
$data = \json_decode($json, $associative, $depth, $flags);
3938
if (!($flags & JSON_THROW_ON_ERROR) && JSON_ERROR_NONE !== json_last_error()) {

0 commit comments

Comments
 (0)