Re: late static binding php6

From: Date: Mon, 19 Nov 2007 18:45:37 +0000
Subject: Re: late static binding php6
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-33351@lists.php.net to get a copy of this message
Stanislav Malyshev wrote: >>>> in that situation A::find(); would not be able to know it was being >>>> called by B::find() because parent:: is considered an explicit class >>>> name reference. >>> It will be, just not by means of parent::. >> I am missing something....then by what means? > > By means of using get_called_class() and then using this information > to call needed method of needed class. There is still a disconnect somewhere. <?php class A { static public function test() { echo get_called_class(); } } class B extends A { static public function test() { parent::test(); } } B::test(); ?> This will echo 'A'. So like I said you have no way here of telling that B:: was used. Now if you are talking about something like: <?php class A { static public function test($called_class) { echo $called_class; } } class B { static public function test() { parent::test(get_class()); } } ?> 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 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 php 6 without getting at least a strict error thrown (Please correct me if I am wrong, I don't have the latest php6 code at the moment.) ?>

« previous php.internals (#33351) next »