Re: Concerns over handling of bug #49105
| From: | Alexander Trauzzi | Date: | Thu, 30 Jul 2009 19:06:16 +0000 |
| Subject: | Re: Concerns over handling of bug #49105 | ||
| References: | 1 2 | Groups: | php.qa |
| Request: | Send a blank email to php-qa+get-65265@lists.php.net to get a copy of this message | ||
Hey,
Thanks for the response.
I haven't brought this up as an issue in late static binding. Although how
late static binding was viewed before it was implemented is almost identical
to the behaviour surrounding my current issue. I simply want to draw some
attention to how quickly this issue is being disregarded.
In my case, defining the variable isn't sufficient as subclassing of my
class is done by users of my library. Their subclass should automatically
have its own copy of the variable to work with and if my parent class wishes
to address its own, it would use self:: as opposed to static::.
It wouldn't make sense to force the subclass to redefine the variable when
the opportunity is there for it to copy it over from the parent. A subclass
isn't created so that it can operate on its parent. Again, resorting to the
bike/motorcycle analogy:
static::wheelsTurn();
Should that turn the wheels of the subclass or the parent class? Seems
silly, especially if the parent is abstract, it would be absurd for a child
class to impact the parent when the call is *explicitly* made to have it
affect the child.
The three scopes self::, static:: and parent:: allow for this to be
explicit. Why deny them their implied use? Why would any class even want
to refer to the parent property as a default when the static:: scope is
used? It's already saying "I want this in a runtime scope, not load time."
The two questions are:
1. Why wouldn't PHP want to duplicate properties in subclasses? Again,
especially given the abundance of useful scopes like parent:: static:: and
self::.
2. Why would a call to a static::$property fall through to the parent class?
- Alex
On Thu, Jul 30, 2009 at 1:11 PM, Stanislav Malyshev <stas@zend.com> wrote:
> Hi!
>
> If we apply some careful thought here, it's clear that subclasses should
>> be
>> making copies of all properties from their parent and when a parent wishes
>>
>
> No, it is not clear and it is not what PHP is doing. This also not related
> to LSB in any way - static inheritance always worked this way. If you need
> separate variable, you can easily do it - define another variable in the
> child class.
> --
> Stanislav Malyshev, Zend Software Architect
> stas@zend.com http://www.zend.com/
> (408)253-8829 MSN: stas@zend.com
>