It's something I noticed, too. Consider this:
class A {
function a() { return $this::b(); }
function b() { return 1; }
}
class B extends A {
function b() { return 2; }
}
If I call
$b = new B();
echo $b->a();
No matter what combination of this, self, parent, ... - I could never get
B's property. I was led to believe that this is actually normal for OO
designs (is it? If so, ignore me). But it would be awesome if self or $this
(ONLY one of them, if they currently perform the same function) actually
referred to the top class - ie. B::b() in this case. Is this what this
suggestion would suggest?
Thanks,
Jevon
----- Original Message -----
From: "Adam Bregenzer" <[EMAIL PROTECTED]>
To: "Hans Lellelid" <[EMAIL PROTECTED]>
Cc: "Ferdinand Beyer" <[EMAIL PROTECTED]>; "Timm Friebe" <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
Sent: Wednesday, June 02, 2004 12:26 PM
Subject: Re: [PHP-DEV] Use of 'self' in static function in subclass
> On Tue, 2004-06-01 at 19:53, Hans Lellelid wrote:
> > Yeah +1 on self:: binding at runtime. I can't really imagine a case
> > where you would want to refer to 'self' as the class that contains the
> > method *and not* the overridden method in invoked class (if it exists).
> > Binding this at runtime will introduce many new design possibilities
> > with static classes and will also make self:: consistent with $this->
> > behavior for objects.
>
> +1, I agree completely. I think it is critical to have a way to be able
> to have a static method call another static method in the same class
> that respects inheritance. If a developer wanted a call to not respect
> inheritance the class's name can be used instead of self with the same
> results (increased code maintenance should the class name change
> notwithstanding).
>
> --
> Adam Bregenzer
> [EMAIL PROTECTED]
> http://adam.bregenzer.net/
>
> --
> 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