rfc:undefined_property_error_promotion

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:undefined_property_error_promotion [2022/04/21 21:32] marandallrfc:undefined_property_error_promotion [2022/05/06 18:22] (current) marandall
Line 3: Line 3:
   * Date: 2022-04-04   * Date: 2022-04-04
   * Author: Mark Randall, marandall@php.net   * Author: Mark Randall, marandall@php.net
-  * Status: Under Discussion+  * Status: Accepted
  
 ===== Introduction ===== ===== Introduction =====
Line 49: Line 49:
  
 <PHP> <PHP>
-if (!empty($obj->name)) { +if (isset($obj->name)) { 
   echo "Hello " . $obj->name;   echo "Hello " . $obj->name;
 } }
 </PHP> </PHP>
  
-There were several options to discuss: +To provide the most consistent handlingthis RFC proposes that stdClass will also throw an error if an undefined property is accessed.
- +
-  - Leave undefined properties as they are +
-  - Throw for accessing any undefined property except for stdClass +
-  - Throw for accessing any undefined property. +
- +
-Of these, the option with the most consistency is throwing for accessing any undefined property, including stdClass, and placing an expectation upon the programmer to use the existing undefined-aware language tools to check for a property being definedbefore attempting to read it. +
- +
-This RFC proposes that stdClass will also throw an error if an undefined property is accessed.+
  
 ===== Backward Incompatible Changes ===== ===== Backward Incompatible Changes =====
Line 79: Line 71:
 Voted started on 2022-04-22, ending 2022-05-05 Voted started on 2022-04-22, ending 2022-05-05
  
-<doodle title="Promote Undefined Property Access to Throw an Error?" auth="marandall" voteType="single" closed="false">+<doodle title="Promote Undefined Property Access to Throw an Error?" auth="marandall" voteType="single" closed="true">
    * Yes    * Yes
    * No    * No
 </doodle> </doodle>
  
 +Meta vote:
 +
 +<doodle title="Main reason for voting against undefined_property_error_promotion if you did?" auth="marandall" voteType="single" closed="true">
 +   * Backwards compatibility breaks
 +   * Would be in favour, but not in 9.0
 +   * Do not like stdClass behaviour
 +   * Something else
 +</doodle>
  
rfc/undefined_property_error_promotion.1650576778.txt.gz · Last modified: 2022/04/21 21:32 by marandall