Am 26.11.2007 um 10:24 schrieb Alexey Zakhlestin:
On 11/26/07, Mike Lively <[EMAIL PROTECTED]> wrote:
class A {
public static function test() {
echo get_called_class()."\n";
}
}
class B extends A {
public static function test() {
parent::test();
}
}
A::test();
B::test();
will output:
A
B
I believe this first patch is the proper way to go. It feels
"natural", "intuitive", etc.
Definitely. However, given the arguments here, I was thinking this:
- static always points to the original callee, w/o being "broken" by
parent::
- get_called_class() should _not_ behave like shown above. It really
was not B that got called, but it was A, trough parent::
- a new get_static_class() method should return "B".
(essentially, get_called_class() returns the name of "self", while
get_static_class() returns the name of "static").
So:
class A {
public static function test() {
echo get_called_class() . get_static_class();
}
}
class B extends A {
public static function test() {
parent::test();
}
}
outputs:
AAAB
- David
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php