rfc:lsb_parentself_forwarding
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
Previous revisionNext revision | |||
— | rfc:lsb_parentself_forwarding [2008/11/29 09:42] – Fix. sebastian | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Request for Comments: LSB, parent::/ | ||
+ | * Version: 1.0 | ||
+ | * Date: 2008-07-22 | ||
+ | * Author: Etienne Kneuss < | ||
+ | * Status: Accepted | ||
+ | |||
+ | ===== Introduction ===== | ||
+ | |||
+ | This RFC covers the change that occured to Late Static Bindings (LSB) prior to its first alpha release. | ||
+ | |||
+ | ==== Terms and concepts ==== | ||
+ | |||
+ | LSB works by passing the original call info to the function, used then by '' | ||
+ | <code php> | ||
+ | <?php | ||
+ | class A { | ||
+ | | ||
+ | return get_called_class(); | ||
+ | } | ||
+ | } | ||
+ | class B extends A { | ||
+ | |||
+ | } | ||
+ | class C extends B { | ||
+ | |||
+ | } | ||
+ | echo C::who(); // C | ||
+ | ?> | ||
+ | </ | ||
+ | |||
+ | Now let's say that you want to overwrite who in B, but still rely on A's who(): | ||
+ | |||
+ | <code php> | ||
+ | <?php | ||
+ | class A { | ||
+ | | ||
+ | return get_called_class(); | ||
+ | } | ||
+ | } | ||
+ | class B extends A { | ||
+ | | ||
+ | /* do stuff.. */ | ||
+ | |||
+ | /* call A's who() */ | ||
+ | | ||
+ | } | ||
+ | class C extends B { | ||
+ | |||
+ | } | ||
+ | echo C::who(); // ?? | ||
+ | ?> | ||
+ | </ | ||
+ | |||
+ | Now, depending on how you call A's '' | ||
+ | - C, if the call was '' | ||
+ | - A, if the call wasn't '' | ||
+ | |||
+ | ===== The change ===== | ||
+ | |||
+ | Previously, '' | ||
+ | |||
+ | With the change, a difference between '' | ||
+ | |||
+ | Note that '' | ||
+ | |||
+ | ===== ML Discussion ===== | ||
+ | |||
+ | http:// | ||
rfc/lsb_parentself_forwarding.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1