Edit report at http://bugs.php.net/bug.php?id=50892&edit=1

 ID:               50892
 Comment by:       php at b8r dot org
 Reported by:      EdwardDrapkin at gmail dot com
 Summary:          Protected members of non-congruent children classes
                   are visible
 Status:           Open
 Type:             Feature/Change Request
 Package:          Feature/Change Request
 Operating System: Irrelevant
 PHP Version:      5.3.1

 New Comment:

It causes more problems then the original poster notes.  We've run into
problems using __get and __set. Since php see's the member as "in scope"
for both classes, the __get and __set methods don't get called.


Previous Comments:
------------------------------------------------------------------------
[2010-02-02 03:28:51] col...@php.net

At a second glance, it really looks like it is wrong.



The visibility check should also be based on the object from which the 

properties are read.



As for my "it works that way in Java" argument, it contradicts the java


specifications: 

http://java.sun.com/docs/books/jls/third_edition/html/names.html#6.6.2.1

and hence is invalid. (Thanks oorza for pointing that out)



There is no design ground to accept that, it is a bug. The question that


remains is: is it worth to fix BC-wise?

------------------------------------------------------------------------
[2010-02-01 14:23:51] johan...@php.net

That's a fundamental part of a class based inheritance system.Changing
this won't only affect BC but also the fundamental design.

------------------------------------------------------------------------
[2010-02-01 14:15:28] col...@php.net

Even though it feels odd, it's how the checks are currently designed.



The same applies to i.e. Java. I guess we cannot change things here 

without introducing nasty and hard to track BC breaks.

------------------------------------------------------------------------
[2010-02-01 13:59:30] EdwardDrapkin at gmail dot com

I also wanted to point out I spoke to ekneuss at length about this
issue, in IRC, and he confirmed it.

------------------------------------------------------------------------
[2010-02-01 13:57:29] EdwardDrapkin at gmail dot com

I did "RTFM" and I understand that protected members are not SUPPOSED TO
BE ABLE to be accessed from anything but "within the class itself and by
inherited and parent classes."  The bug is that, when the calling scope
resolves and LOOKS LIKE the correct scope because it is an inherited
class, but is a _different inherited class_ of the same parent object in
which the protected member was declared, the engine allows access to
protected members from OUTSIDE THE CLASS.



In the example, both "bar" and "kid" extend foo, but "kid" should NOT
have access to bar's protected members, but it does, but its resolving
scope looks similar to the correct scope that would need to resolve.



This isn't an RTFM issue, it's a legitimate bug.  Did you read the
reproduce code?

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    http://bugs.php.net/bug.php?id=50892


-- 
Edit this bug report at http://bugs.php.net/bug.php?id=50892&edit=1

Reply via email to