Hi Marcus,

Thanks for the prompt reply and explanation. I have some further
questions though:

> If the base class had the property defined as private
> then the property is private to that specific class and not directly
> accessible by derived classes that is it's name gets prefixed with the class
> name.. So in:
> class A { private static $p; } class B extends A { private static $p; }
> we have two different properties:

Understood. But if we have two separate properties for the reason that
A::$p is not visible to B, then how about these cases?
class A { protected static $p; } class B extends A { protected static $p; }
class A { public static $p; } class B extends A { public static $p; }

In both of those cases, A::$p is visible to the derived class, but the
re-declaration results in A::$p and B::$p being two separate
properties (see pastebin.com/fca2cd5b and pastebin.com/f4f94b32d for a
demonstration). This is one of the reasons I find the case where we
end up with only one property value to be surprising.

Another reason is that, as illustrated in my previous post, PHP's
behaviour doesn't seem to correlate with the inheritance rules of
other languages I'm familiar with: you always end up with two distinct
static properties in Java, C++ and C# (though of course I understand
this fact on its own is does not mean PHP is wrong :).

Lastly, with overridden static methods, PHP always yields two distinct
methods, regardless of the visibility modifiers. See
http://pastebin.com/f27f009c4 . Granted, with methods any other
behaviour would be very odd indeed, but it does emphasize an
inconsistency between method and property inheritance rules in PHP.

So for now I continue to feel this is a little strange. Any further
explanations would be greatly appreciated. :)

Thanks,
Robin

> Best regards,
>  Marcus

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to