Hi!
- B1 and B2 both extend A. B2 is neither an ancestor nor a descendant of B1, but I suppose they could be considered to be part of the same class hierarchy because they are siblings. - f() is declared as protected in A and B1, but not declared at all in B2.
Which means there exists A::f(), B1::f() and B2::f() (being the same as A::f()), all of which are protected.
- The docs state: "Protected limits access to inherited and parent classes (and to the class that defines the item)" - http://php.net/manual/en/language.oop5.visibility.php . Currently, B1::f() is visible from B2.
A::f() is visible from B2, and B1 can not have access to f() more restricted than A since it's violate the Liskov principle - objects of B1 couldn't be used the same way as objects of A in all contexts.
Look at this also this way: suppose we had no B1::f. Then if we call f() from B2, we always get A::f() which is protected, so it works. Now we copy A::f definition to B1 verbatim - with same access, same everything. Should now code that calls f() on B1 start failing?
-- Stanislav Malyshev, Zend Software Architect [EMAIL PROTECTED] http://www.zend.com/ (408)253-8829 MSN: [EMAIL PROTECTED] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php