Hi all, thanks for thinking about this.

On 26/03/2008, Marcus Boerger <[EMAIL PROTECTED]> wrote:

> On 26/03/2008, Alexey Zakhlestin <[EMAIL PROTECTED]> wrote:
>
>  > use case for "protected" is similiar, but relates to cases when you
>  > have hierarchy of classes, which still have some common functionality,
>  > which might be usable for multi-instance operations
>
> Thanks. This is the exact way we see this. Anything that violates this rule
>  is a bug.

Ok, good. So to get back to the original question
(http://turl.ca/kfanjo), in the following case, should B1::f() be
visible from B2 in the code example below? Note that:

  - 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.
  - 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.

--> If this is a bug, Felipe's patch
(http://ecl.mediain.com.br/diff/protected.diff) fixes the issue. Let's
commit it! :)

--> If this is not a bug then the docs need to be clarified.
Furthermore, callbacks, is_callable(), lookups to the clone & destruct
magic methods and possibly property access should all be changed,
because they currently do not adhere to this rule (as illustrated in
the code snippets in http://turl.ca/kfanjo ).

The code:

<?php
class A {
        static protected function f() {return 'In A::f';}
}
class B1 extends A {
        static protected function f() {return 'In B1::f';}
}
class B2 extends A {
        static public function test() {echo B1::f();}  // Currently, this works.
}
B2::test();
?>

Regards,
Robin.

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

Reply via email to