Re: [patch] Late static bindings (LSB)

From: Date: Wed, 19 Sep 2007 11:26:23 +0000
Subject: Re: [patch] Late static bindings (LSB)
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-32382@lists.php.net to get a copy of this message
oh… I guess I see it somehow the third way class A { function foo() { return get_called_class(); } } class B extends A { function bar1() { return self::foo(); // it is called using inheritance-rules } function bar2() { return A::foo(); // it is called directly! } } echo B::bar1(); // "B" echo B::bar2(); // "A" On 9/19/07, Dmitry Stogov <dmitry@zend.com> wrote: > So to clarify the question... > > <?php > class A { > function foo() { > return get_called_class(); > } > } > class B extends A { > function bar() { > return A::foo(); > } > } > class C extensa A { > function bar() { > return B::bar(); > } > } > echo B::foo(); // this must return "B". This is not a question, the question > is in the following two lines... > echo B::bar(); // this must return "B", because B::bar() calls to A::foo() > and A is parent of B, so "late static binding" still the same > echo C::bar(); // this must return "B" too, because C:bar() calls to > B::bar(), but B is not the parent of C, so the call to B::bar() is handled > in the same way as in the previous line. > ?> > > Is this the expected behavior? (I would prefer it. My previous patches > worked in this way). > > Or may be both lines must return "A"? (like Etienne's patches do, and like > my latest path does) > > Thanks. Dmitry. -- Alexey Zakhlestin http://blog.milkfarmsoft.com/

« previous php.internals (#32382) next »