|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-10-12 11:03 UTC] guth at fiifo dot u-psud dot fr
Description: ------------ I got another strange behaviour with classes functions. get_class_methods(Object $obj) returns private and protected methods. get_class_vars(string $class) returns private and protected properties. However, get_object_vars() doesn't. This method takes an Object parameter and I think that its behaviour should be the same as get_class_methods(Object $obj). This bug is "related" to bug #30381. Reproduce code: --------------- <?php class A { protected $plip; private function run() { } } class B extends A { } class hariCow extends B { private $plop = 'beta'; } $db = new hariCow; var_dump(get_class_vars('hariCow')); var_dump(get_object_vars($db)); var_dump(get_class_methods($db)); echo $db->run(); ?> Expected result: ---------------- array(2) { ["plop"]=> string(4) "beta" ["plip"]=> NULL } array(2) { ["plop"] => ... ["plip"] => ... } array(1) { [0]=> string(3) "run" } Actual result: -------------- array(2) { ["plop"]=> string(4) "beta" ["plip"]=> NULL } array(0) { } array(1) { [0]=> string(3) "run" } PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 16:00:02 2025 UTC |
I get : array(0) { } array(0) { } array(0) { } I think it's the best solution to print only public properties and methods for this cases. I saw that get_object_vars($this) prints private/protected properties, which is the best solution too. So works fine in 5.1.0-dev.. What will you do for the 5.0.* branch ?