Re: late static binding php6
| From: | Etienne Kneuss | Date: | Sun, 18 Nov 2007 13:21:50 +0000 |
| Subject: | Re: late static binding php6 | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-33249@lists.php.net to get a copy of this message | ||
Hello,
this very subject was already discussed in a thread months ago. Basically,
it's a matter of choice whether fully established calls should break the
resolution or not. Both ways have drawbacks. Implementing both would require
yet another keyword and complications.
On Nov 18, 2007 12:27 PM, Gergely Hodicska <felho@avalon.aut.bme.hu> wrote:
> Hi!
>
>
> I read this thread, and I would like to ask if is there any decision
> about the behavior of inheritance?
>
> I wrote on my blog about late static binding
> (
>
> http://blog.felho.hu/what-is-new-in-php-53-part-2-late-static-binding.html
> ),
> and I came up with the following example:
>
> <?php
> class ActiveRecord
> {
> public static function findByPk($id)
> {
> $calledClass = get_called_class();
> // The magic remains...
> }
> }
>
> class Blog extends ActiveRecord
> {
> public static function findByPk($id)
> {
> // We want to log something.
>
> // Then the parent should do the magic.
> parent::findByPk($id);
> }
> }
>
> Blog::findByPk(1);
> ?>
>
>
> In think it would be nice if I could write codes like this. But in the
> current snapshot the value of $calledClass is ActiveRecord.
>
>
> Best Regards,
> Felhő
>
> --
> 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