ID: 37212 User updated by: andreasblixt at msn dot com Reported By: andreasblixt at msn dot com Status: Open Bug Type: Class/Object related Operating System: Irrelevant PHP Version: 5.1.2 New Comment:
While looking for a workaround I found that the result of the test on a protected method instead of a protected property is different (successful): Workaround: ----------- Add a protected method in the same class in which the protected property is defined that returns the value of the property. Then call the method in place of attempting to access the property. Previous Comments: ------------------------------------------------------------------------ [2006-04-26 18:13:51] andreasblixt at msn dot com In addition to the above description I would like to add that the sub-classes CAN access each other's protected variables, if the accessing is done in a shared parent class. ------------------------------------------------------------------------ [2006-04-26 18:10:02] andreasblixt at msn dot com Description: ------------ In class structures where the sub-classes are extended non-linearly (i.e. multiple classes on the same tier), the sub-classes in different lines cannot access variables defined as protected in a shared parent class in eachother. Reproduce code: --------------- http://pastebin.com/683438 Expected result: ---------------- Tier3A accessing Tier3C... OK! ('Value from Tier3C') Tier3B accessing Tier3C... OK! ('Value from Tier3C') Actual result: -------------- Tier3A accessing Tier3C... OK! ('Value from Tier3C') Tier3B accessing Tier3C... Fatal error: Cannot access protected property Tier3C::$value in protected.php5 on line 31 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=37212&edit=1
