rfc:lsb_parentself_forwarding

Differences

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

Link to this comparison view

Next revision
Previous revision
rfc:lsb_parentself_forwarding [2008/07/22 13:55]
colder created
rfc:lsb_parentself_forwarding [2017/09/22 13:28] (current)
Line 3: Line 3:
   * Date: 2008-07-22   * Date: 2008-07-22
   * Author: Etienne Kneuss <​colder@php.net>​   * Author: Etienne Kneuss <​colder@php.net>​
-  * Status: ​Accepted+  * Status: ​Implemented in PHP 5.3
  
 ===== Introduction ===== ===== Introduction =====
  
-This RFC covers the change that occured to Late Static Bindings (LSB) prior to it'​s ​first alpha release.+This RFC covers the change that occured to Late Static Bindings (LSB) prior to its first alpha release.
  
 ==== Terms and concepts ==== ==== Terms and concepts ====
  
-LSB works by passing the original call info to the function, used then by static:: or get_called_class to get the original class name used. This information will only be useful in case a {{fallback}} occurs, which takes place when you call a static method that only exists in one of the parent classes.+LSB works by passing the original call info to the function, used then by ''​static::'' ​or get_called_class to get the original class name used. This information will only be useful in case a ''​fallback'' ​occurs, which takes place when you call a static method that only exists in one of the parent classes.
 <code php> <code php>
 <?php <?php
Line 27: Line 27:
   echo C::who(); // C   echo C::who(); // C
 ?> ?>
-</​code ​php>+</​code>​
  
 Now let's say that you want to overwrite who in B, but still rely on A's who(): Now let's say that you want to overwrite who in B, but still rely on A's who():
Line 50: Line 50:
   echo C::who(); // ??   echo C::who(); // ??
 ?> ?>
-</​code ​php>+</​code>​
  
-Now, depending on how you call A's who() from B::who(), you might get different results for the c::who() call: +Now, depending on how you call A'​s ​''​who()'' ​from ''​B::who()''​, you might get different results for the ''​C::who()'' ​call: 
-  C, if the call was {{forwarding}} +  ​C, if the call was ''​forwarding''​ 
-  A, if the call wasn'​t ​{{forwarding}}.+  ​A, if the call wasn'​t ​''​forwarding''​.
  
 ===== The change ===== ===== The change =====
  
-Previously, A::who() and parent::​who() would be non-forwarding.+Previously, ​''​A::who()'' ​and ''​parent::​who()'' ​would be ''​non-forwarding''​. The only way to call A's who() with ''​forwarding''​ was to use an helper function: ''​forward_static_call()''​.
  
-===== Proposal ​and Patch =====+With the change, a difference between ''​parent::'' ​and ''​A::''​ is introduced, that is: ''​parent::''​ is ''​forwarding''​ while ''​A::''​ isn't. Basically, explicit calls are ''​non-forwarding'',​ but calls using keywords are.
  
-Nothing needs to be patched here. Just use this template at your discretion. +Note that ''​self::''​ will also be made to be ''​forwarding'',​ while ''<​nameoftheclass>​::''​ won't.
- +
-==== Rejected Features ==== +
- +
-Automated voting system. +
- +
-==== More about RFCs ==== +
- +
-http://​en.wikipedia.org/​wiki/​Request_for_Comments +
- +
-===== Changelog =====+
  
 +===== ML Discussion =====
  
 +http://​markmail.org/​message/​at3ypbykl6luwr6l
  
rfc/lsb_parentself_forwarding.1216734937.txt.gz · Last modified: 2017/09/22 13:28 (external edit)