[php-src] Issue #9342: json_decode() not compliant with RFC8259

From: Date: Mon, 15 Aug 2022 12:57:55 +0000
Subject: [php-src] Issue #9342: json_decode() not compliant with RFC8259
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-242225@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/9342 Author: JBtje ### Description The following code: ```php var_dump( json_decode( null ) ); var_dump( json_decode( false ) ); var_dump( json_decode( true ) ); <?php ``` Resulted in this output: ``` PHP Deprecated: json_decode(): Passing null to parameter #1 ($json) of type string is deprecated NULL int(1) ``` But I expected this output instead: ``` NULL bool(false) bool(true) ``` https://datatracker.ietf.org/doc/rfc8259/ states ``` 3. Values A JSON value MUST be an object, array, number, or string, or one of the following three literal names: false null true The literal names MUST be lowercase. No other literal names are allowed. value = false / null / true / object / array / number / string false = %x66.61.6c.73.65 ; false null = %x6e.75.6c.6c ; null true = %x74.72.75.65 ; true ``` Relevant: - https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg - https://github.com/php/php-src/blob/master/ext/json/tests/001.phpt#L35 - https://github.com/php/php-src/blob/master/ext/json/tests/bug69187.phpt#L30 - https://github.com/php/php-src/blob/master/ext/json/tests/bug69187.phpt#L38 ### PHP Version PHP 8.1 ### Operating System _No response_

« previous php.bugs (#242225) next »