File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99
1010final class JsonDecoder
1111{
12- public static function decode (string $ json , bool $ assoc = true ): mixed
12+ public static function decode (string $ json , bool $ assoc = true , int $ flags = 0 ): mixed
1313 {
1414 try {
15- return json_decode ($ json , $ assoc , 512 , JSON_THROW_ON_ERROR );
15+ return json_decode ($ json , $ assoc , 512 , JSON_THROW_ON_ERROR | $ flags );
1616 } catch (JsonException $ exception ) {
1717 throw InvalidJsonFormatException::wrappingException ($ exception );
1818 }
1919 }
2020
21- public static function decodeSilently (string $ json , bool $ assoc = true ): mixed
21+ public static function decodeSilently (string $ json , bool $ assoc = true , int $ flags = 0 ): mixed
2222 {
2323 try {
24- return self ::decode ($ json , $ assoc );
24+ return self ::decode ($ json , $ assoc, $ flags );
2525 } catch (InvalidJsonFormatException ) {
2626 return null ;
2727 }
2828 }
2929
30- public static function validate (string $ json ): bool
30+ /**
31+ * @phpstan-param 0|JSON_INVALID_UTF8_IGNORE $flags
32+ */
33+ public static function validate (string $ json , int $ flags = 0 ): bool
3134 {
32- return json_validate ($ json );
35+ return json_validate ($ json, 512 , $ flags );
3336 }
3437}
You can’t perform that action at this time.
0 commit comments