#30408 [Opn->Fbk]: get_object_vars()
| From: | helly@php.net | Date: | Sat, 16 Oct 2004 19:21:15 +0000 |
| Subject: | #30408 [Opn->Fbk]: get_object_vars() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-67664@lists.php.net to get a copy of this message | ||
ID: 30408
Updated by: helly@php.net
Reported By: guth at fiifo dot u-psud dot fr
-Status: Open
+Status: Feedback
Bug Type: Class/Object related
-Operating System: Linux
+Operating System: *
PHP Version: 5.0.2
-Assigned To:
+Assigned To: helly
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5-STABLE-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5.0-win32-latest.zip
%.0.3-dev and 5.1.0-dev aka HEAD should behave in the same way, no
protected, private vars unless called from that scope. Please verify.
Previous Comments:
------------------------------------------------------------------------
[2004-10-16 17:28:30] guth at fiifo dot u-psud dot fr
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 ?
------------------------------------------------------------------------
[2004-10-12 11:16:30] derick@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5-win32-latest.zip
------------------------------------------------------------------------
[2004-10-12 11:03:26] 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" }
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=30408&edit=1