forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjson_object_as_array.php
More file actions
33 lines (25 loc) · 898 Bytes
/
json_object_as_array.php
File metadata and controls
33 lines (25 loc) · 898 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
namespace Analyser\JsonDecode;
use function PHPStan\Testing\assertType;
// @see https://3v4l.org/YFlHF
function ($mixed) {
$value = json_decode($mixed, null, 512, JSON_OBJECT_AS_ARRAY);
assertType('array|bool|float|int|string|null', $value);
};
function ($mixed) {
$flagsAsVariable = JSON_OBJECT_AS_ARRAY;
$value = json_decode($mixed, null, 512, $flagsAsVariable);
assertType('array|bool|float|int|string|null', $value);
};
function ($mixed) {
$value = json_decode($mixed, null, 512, JSON_OBJECT_AS_ARRAY | JSON_BIGINT_AS_STRING);
assertType('array|bool|float|int|string|null', $value);
};
function ($mixed) {
$value = json_decode($mixed, null);
assertType('array|bool|float|int|stdClass|string|null', $value);
};
function ($mixed, $unknownFlags) {
$value = json_decode($mixed, null, 512, $unknownFlags);
assertType('array|bool|float|int|stdClass|string|null', $value);
};