|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-11-23 21:26 UTC] jani@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 31 18:00:01 2025 UTC |
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] => )