Re: late static binding php6
| From: | Etienne Kneuss | Date: | Sun, 25 Nov 2007 23:25:53 +0000 |
| Subject: | Re: late static binding php6 | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-33430@lists.php.net to get a copy of this message | ||
Hi,
On Nov 25, 2007 11:45 PM, Jeff Moore <jeff@procata.com> wrote:
>
> Hi,
>
> May I suggest renaming get_called_class() to get_static_class() to
> correspond with the use of the static:: keyword for late binding.
It was already kind of discussed, and get_called_class makes more sense IMO.
"static class" is not self-descriptive. The class returned is the class that
was initially
referenced for the call, as in the class "called" initially.
> parent:: and get_parent_class() [no parameters] should also correspond
> when used in a static method context.
They do, parent::foo(); should be the same as $class = get_parent_class();
$class::foo();
Of course, we can't make parent:: reference the parent class of the called
one, as it would break BC.
As in:
class A { }
class B extends A { public static function test() { echo get_class(new
parent), '-', get_parent_class(); } }
class C extends B { }
C::test(); // A-A and not B-B
>
>
> My preference is that parent:: be late binding. I would also like to
> see an early bound __parent__ constant along the lines of __class__.
>
> Best Regards,
>
> Jeff
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
--
Etienne Kneuss
http://www.colder.ch
Men never do evil so completely and cheerfully as
when they do it from a religious conviction.
-- Pascal