Re: late static binding php6
| From: | Mike Lively | Date: | Mon, 19 Nov 2007 19:21:33 +0000 |
| Subject: | Re: late static binding php6 | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-33353@lists.php.net to get a copy of this message | ||
Stanislav Malyshev wrote:
>> parent::test();
>
> What do you want parent::test() to mean?
>
>> This will echo 'A'. So like I said you have no way here of telling that
>> B:: was used.
>
> Because it wasn't. parent::test() means A::test(). 'parent::' means
> 'parent class of the class where this statement is' in PHP. For B,
> it's A.
Yes but B::test() was called to start the call chain and in this
situation I want the B::test() method to decorate A::test() and it just
isn't possible without allowing parent:: to forward the called class or
introducing a new keyword.
>
>> Then there are two problems (sort of). First problem being, then why
>> bother with lsb, you can do this already (which more so a 'wth' as
>
> If you can do it - do it.
I (and many other people) don't feel the need to do things this way and
it is slightly frustrating to see a patch implemented to allow us to
'sort of' do it cleanly but ultimately misses the mark. Especially when
it is probably a relatively minor change to support what we are asking
for. This is also a terrible argument to use against a new feature...but
that's an entirely separate matter.
>
>> opposed to a problem.) The second and much more prevelent problem is
>> that iirc you cannot do this kind of loose inheritance with statics in
>
> What is 'loose inheritance'?
By loose inheritance I mean extending and overwriting a method while
changing that method's parameter list.
I apologize, I grabbed php6 and appear to have not remembered things
quite right. I thought that you could not change the parameter list of
inherited static methods which is not the case in php6. Although you
WILL have a problem if you program to interfaces. If static public
test() is declared in an interface that A implements then you won't be
able to change the parameter list in B.