rfc:json_throw_on_error

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
rfc:json_throw_on_error [2017/09/24 15:01] ajfrfc:json_throw_on_error [2017/10/22 18:44] (current) – implement ajf
Line 3: Line 3:
   * Date: 2017-09-10   * Date: 2017-09-10
   * Author: Andrea Faulds   * Author: Andrea Faulds
-  * Status: Under Discussion+  * Status: Implemented (PHP 7.3)
   * First Published at: http://wiki.php.net/rfc/json_throw_on_error   * First Published at: http://wiki.php.net/rfc/json_throw_on_error
  
Line 16: Line 16:
 <php>JsonException</php> would be a new class that subclasses <php>Exception</php>. <php>JsonException</php> would be a new class that subclasses <php>Exception</php>.
  
-Note that when given an invalid depth parameter, <php>json_decode()</php> outputs a warning and returns NULL. This behaviour is unaffected by JSON_THROW_ON_ERROR because it does not affect the global error state at present, has no corresponding error code to throw an exception with, and is not dependent on user input. Similarly, parameter parsing errors continue to produce warnings (when not in strict mode) because their error behaviour cannot be conditioned on the value of a parameter being parsed. Both can be caught by a user error handler that converts errors to exceptions.+Note that when given an invalid depth parameter, <php>json_decode()</php> outputs a warning and returns NULL. This behaviour is unaffected by <php>JSON_THROW_ON_ERROR</php> because it does not affect the global error state at present, has no corresponding error code to throw an exception with, and is not dependent on user input. Similarly, parameter parsing errors continue to produce warnings (when not in strict mode) because their error behaviour cannot be conditioned on the value of a parameter being parsed. Both can be caught by a user error handler that converts errors to exceptions.
  
 At the present time, there would be no change to the default error behaviour. It would be worthwhile considering whether to eventually slowly deprecate not using <php>JSON_THROW_ON_ERROR</php> and then change the default behaviour, but this RFC does not do this. At the present time, there would be no change to the default error behaviour. It would be worthwhile considering whether to eventually slowly deprecate not using <php>JSON_THROW_ON_ERROR</php> and then change the default behaviour, but this RFC does not do this.
Line 42: Line 42:
 As mentioned earlier, it may be desirable to deprecate the default behaviour eventually. As mentioned earlier, it may be desirable to deprecate the default behaviour eventually.
  
-===== Proposed Voting Choices ===== +===== Vote ===== 
-This is not a language change, merely a small addition to the JSON extension, so it only technically requires a 50%+1 majority.+This is not a language change, merely a small addition to the JSON extension, so it only technically requires a 50%+1 majority. However, it's a 2/3 vote. It is a simple Yes/No vote on whether to accept this RFC and merge the patch.
  
-It would be a simple Yes/No vote on whether to accept this RFC and merge the patch.+Voting started 2017-09-25 and ended 2017-10-05. 
 + 
 +<doodle title="Accept and merge JSON_THROW_ON_ERROR for PHP 7.3?" auth="ajf" voteType="single" closed="true"> 
 +   * Yes 
 +   * No 
 +</doodle>
  
 ===== Patches and Tests ===== ===== Patches and Tests =====
Line 51: Line 56:
  
 ===== Implementation ===== ===== Implementation =====
 +
 +Merged in PHP 7.3: https://github.com/php/php-src/commit/e823770515bd0530bd3c09ea273c720b4df33734
 +
 After the project is implemented, this section should contain  After the project is implemented, this section should contain 
-  - the version(s) it was merged to 
-  - a link to the git commit(s) 
   - a link to the PHP manual entry for the feature   - a link to the PHP manual entry for the feature
-  - a link to the language specification section (if any) 
  
 ===== References ===== ===== References =====
rfc/json_throw_on_error.1506265296.txt.gz · Last modified: 2017/09/24 15:01 by ajf