Johannes Schlüter wrote:
> Hi,
>
> and for me the current behavior feels right: The call to
> parrent::findByPk() is an independent call from the call before and
> calls an explicit class (the parent one)
>
>   
This makes no sense to me. It makes it COMPLETELY impossible to do any
form of slightly complicated inheritance and decorators go almost out
the window for statics. It's also slightly inconsistent from how
instance inheritance works.

class A
{
        public function test()
        {
                echo get_class($this)."\n";
        }
}

class B extends A
{
        public function test()
        {
                parent::test();
        }
}

$a = new A;
$b = new B;

$a->test();
$b->test();

I realize that instance calls are a completely different ball game than
static  calls but LSB was supposed to give us the same flexibility.

I would totally agree that <class name>::<static method>() should break
the caller chain, but in my opinion parent:: should just forward the
called class on. It would allow more complex forms of inheritance,
people that have the kind of OO background that this feature is intended
for I believe will easily understand what's going on. I think more often
than not if someone is going to use parent:: instinctively that they
would be intending the caller to be forwarded (ie: for decorators, also
see polymorphism?). If you REALLY wanted the parent class explicitely
called you can just use the class name.

Basically my point is that I don't believe parent:: should be considered
'fully established' to use Etienne's terminology.

-Mike Lively

> On Sun, 2007-11-18 at 14:21 +0100, "Etienne Kneuss" wrote:
>   
>> 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 <[EMAIL PROTECTED]> 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
>>>
>>>
>>>
>>>       
>>     
>
>   

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to