RE: [PHP-DEV] [patch] Late static bindings (LSB)
| From: | Dmitry Stogov | Date: | Wed, 19 Sep 2007 15:07:56 +0000 |
| Subject: | RE: [PHP-DEV] [patch] Late static bindings (LSB) | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-32386@lists.php.net to get a copy of this message | ||
Do you like to make it work for self::foo() and/or static::foo(), but not
for parent::foo() and NAME::foo()?
From my point of view it is little bit inconsistent, but anyway thank you
for idea.
Dmitry.
> -----Original Message-----
> From: Alexey Zakhlestin [mailto:indeyets@gmail.com]
> Sent: Wednesday, September 19, 2007 3:26 PM
> To: Dmitry Stogov
> Cc: Marcus Boerger; Lukas Kahwe Smith; Michael Lively;
> Etienne Kneuss; internals@lists.php.net; Stanislav Malyshev;
> Andi Gutmans
> Subject: Re: [PHP-DEV] [patch] Late static bindings (LSB)
>
>
> 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/
>