rfc:debug-info

Differences

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

Link to this comparison view

Next revision
Previous revision
rfc:debug-info [2014/01/21 21:26] – created pollitarfc:debug-info [2017/09/22 13:28] (current) – external edit 127.0.0.1
Line 1: Line 1:
  
-====== PHP RFC: __debug_info() ====== +====== PHP RFC: __debugInfo() ====== 
-  * Version: 1.0+  * Version: 1.1
   * Date: 2014-01-21   * Date: 2014-01-21
   * Author: Sara Golemon, pollita@php.net   * Author: Sara Golemon, pollita@php.net
-  * Status: Under Discussion+  * Status: Accepted (implemented in 5.6)
   * First Published at: http://wiki.php.net/rfc/debug-info   * First Published at: http://wiki.php.net/rfc/debug-info
  
 ===== Proposal ===== ===== Proposal =====
  
-This RFC is for exposing the "get_debug_info" API already available to internal classes (written in C) to PHP classes via a magic method called <nowiki>__debug_info()</nowiki>.+This RFC is for exposing the "get_debug_info" API already available to internal classes (written in C) to PHP classes via a magic method called <nowiki>__debugInfo()</nowiki>.
  
 Example Usage: Example Usage:
Line 18: Line 18:
      
     // But all the stream meta data is     // But all the stream meta data is
-    public function __debug_info() {+    public function __debugInfo() {
       return $this->fp ? stream_get_meta_data($fp) : [];       return $this->fp ? stream_get_meta_data($fp) : [];
     }     }
Line 46: Line 46:
 ===== Impact to Existing Extensions ===== ===== Impact to Existing Extensions =====
  
-Existing fallback behavior for internal classes not overriding get_debug_info is preserved via chaining to get_properties when no __debug_info function is defined.+Existing fallback behavior for internal classes not overriding get_debug_info is preserved via chaining to get_properties when no <nowiki>__debugInfo</nowiki> function is defined.
  
 ===== Proposed PHP Version(s) ===== ===== Proposed PHP Version(s) =====
  
 5.next 5.next
 +
 +===== Alternates under discussion =====
 +
 +  * Rather than use <nowiki>__debugInfo() as the whole property info result, either merge it with the properties table or stuff it into a "__debugInfo"</nowiki> property and return it with the full properties table.
 +
 +IMO, this takes control away from the user and removes a particularly useful reason for having the <nowiki>__debugInfo() magic method in the first place.  Consider an object which points at itself (or more likely, another object which points back at the original).  This normally results in a recursive loop.  This is detected by the var_dump() routine, but only after a couple cycles.  A more intelligent __debugInfo() output could avoid any iterations of the loop.</nowiki>
 +
 +===== Potential expansions of scope =====
 +
 +  * Add ReflectionObject::getDebugInfo() to return the result of zend_object_handlers->get_debug_info as an array of ReflectionParameter objects
 +
 +===== Revision History =====
 +
 +  * 1.1 (2014-01-22) - Changed name from <nowiki>__debug_info to __debugInfo</nowiki> and added alternates/expansion headings
 +  * 1.0 (2014-01-21) - Initial Revision
 +
 +===== Vote 1 =====
 +
 +  * Vote start: 2014/02/03
 +  * Vote end: 2014/02/17
 +
 +Vote [YES] to merge the <nowiki>__debugInfo()</nowiki> patch.  See Vote 2 for options on what name it will have.
 +
 +<doodle title="Merge ___debugInfo()" auth="pollita" voteType="single" closed="true">
 +   * Yes (5.6)
 +   * Yes (5.7)
 +   * No
 +</doodle>
 +
 +===== Vote 2 =====
 +
 +  * Vote start: 2014/02/03
 +  * Vote end: 2014/02/17
 +
 +If Vote 1 passes, what should the userland magic method be called?
 +
 +<doodle title="Name ___debugInfo()" auth="pollita" voteType="single" closed="true">
 +   * __debugInfo()
 +   * __debug()
 +</doodle>
  
 ===== Implementation ===== ===== Implementation =====
rfc/debug-info.1390339570.txt.gz · Last modified: 2017/09/22 13:28 (external edit)