ID: 50275 Updated by: j...@php.net Reported By: msa at xtivate dot de -Status: Open +Status: Bogus Bug Type: Class/Object related Operating System: ubuntu PHP Version: 5.2.11 New Comment:
It was fixed to be consistent and inside class defining the properties it is perfectly okay to show protected variables. Also, protected != hidden, do you agree? :) (further discussion -> intern...@lists.php.net please) Previous Comments: ------------------------------------------------------------------------ [2009-11-23 20:03:31] msa at xtivate dot de Description: ------------ get_class_vars return is inconsistent. from inside the class it returnes the protected members as well as the public. from outside the class it returns only the public. until php 5.2.10 it only returned the public, not the non-public. (as is it specified in the documentation that it only returns the public...) so... now it does not only return the non-public when called from inside the actual class, but is inconsistent with the output that one gets calling outside of the class. this is a _major issiue_ in terms of scoping/inheritance/consitency. please change it back to the way it was before because that was a) consistent and b) in accordance with the spec ( "only public" ) Reproduce code: --------------- abstract class Vader{ protected $vaders_protected_var; } class Luke extends Vader { public $lukes_public_var; final function ShowVars(){ echo "<br> inside Luke:<br>"; print_r(get_class_vars(get_class($this))); } } $luke = new Luke(); $luke->ShowVars(); echo "<br> outside luke:<br>"; print_r( get_class_vars("Luke") ); Expected result: ---------------- inside Luke: Array ( [lukes_public_var] => ) outside luke: Array ( [lukes_public_var] => ) Actual result: -------------- inside Luke: Array ( [lukes_public_var] => [vaders_protected_var] => ) outside luke: Array ( [lukes_public_var] => ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=50275&edit=1