rfc:tostring_exceptions

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
rfc:tostring_exceptions [2019/04/30 13:27]
nikic Text tweaks and move to under discussion
rfc:tostring_exceptions [2019/06/14 12:12] (current)
theodorejb Change status to implemented
Line 2: Line 2:
   * Date: 2019-04-30   * Date: 2019-04-30
   * Author: Nikita Popov <​nikic@php.net>​   * Author: Nikita Popov <​nikic@php.net>​
-  * Status: ​Under Discussion+  * Status: ​Implemented (in PHP 7.4)
   * Target Version: PHP 7.4   * Target Version: PHP 7.4
   * Implementation:​ https://​github.com/​php/​php-src/​pull/​3887   * Implementation:​ https://​github.com/​php/​php-src/​pull/​3887
Line 9: Line 9:
  
 Throwing exceptions from ''​%%__toString()%%''​ is currently forbidden and will result in a fatal error. Throwing exceptions from ''​%%__toString()%%''​ is currently forbidden and will result in a fatal error.
-This makes it dangerous to call arbirary ​code inside ''​%%__toString()%%''​ and makes its use as a+This makes it dangerous to call arbitrary ​code inside ''​%%__toString()%%''​ and makes its use as a
 general API problematic. This RFC aims to remove this restriction. general API problematic. This RFC aims to remove this restriction.
  
Line 31: Line 31:
 </​PHP>​ </​PHP>​
  
-However, the sentiment in past discussions on this topic has been to not relax this restriction+In fact, Symfony [[https://​github.com/​symfony/​symfony/​blob/​1c110fa1f7e3e9f5daba73ad52d9f7e843a7b3ff/​src/​Symfony/​Component/​Debug/​ErrorHandler.php#​L457-L489|uses this loophole]] to work around the current limitation. Unfortunately this relies on the ''​$errcontext''​ parameter, which is going away in PHP 8. 
 + 
 +Despite this, the sentiment in past discussions on this topic has been to not relax this restriction
 until we have performed a comprehensive audit of string conversions across the codebase. This until we have performed a comprehensive audit of string conversions across the codebase. This
 has been done in the attached implementation [[https://​github.com/​php/​php-src/​pull/​3887|pull request]]. has been done in the attached implementation [[https://​github.com/​php/​php-src/​pull/​3887|pull request]].
Line 97: Line 99:
 ===== Vote ===== ===== Vote =====
  
-Allow exceptions from ''​%%__toString()%%'' ​in PHP 7.4? Yes/No.+Voting started 2019-05-22 and ends 2019-06-05. 
 + 
 +<doodle title="​Allow exceptions from __toString() in PHP 7.4?" auth="​nikic"​ voteType="​single"​ closed="​true">​ 
 +   ​* ​Yes 
 +   ​* ​No 
 +</​doodle>​
  
rfc/tostring_exceptions.1556630846.txt.gz · Last modified: 2019/04/30 13:27 by nikic