#30659 [Fbk->Bgs]: get_class_vars() works incorrect
| From: | helly@php.net | Date: | Mon, 08 Nov 2004 10:13:54 +0000 |
| Subject: | #30659 [Fbk->Bgs]: get_class_vars() works incorrect | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-68798@lists.php.net to get a copy of this message | ||
ID: 30659
Updated by: helly@php.net
Reported By: mx at tut dot by
-Status: Feedback
+Status: Bogus
Bug Type: Class/Object related
Operating System: *
PHP Version: 5CVS-2004-11-02 (dev)
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
get_class_vars($this) returns the name of the derived class B where
$one is defined. You access the properties from class A. Since private
properties are only visible to the defining class - in this case B -
the error is correct.
Previous Comments:
------------------------------------------------------------------------
[2004-11-08 02:03:09] aaron at visualprose dot com
You can download a script that will reproduce this bug
here: http://visualprose.com/inheritance-bug.php.gz
. I
am experiencing this on Mac OS X 10.3.5 (client and
server) under PHP 5.0.2. This bug wasn't occuring under
PHP 5.0.0. Let me know if you need more info.
<:> Aaron Jensen
<:> aaron@visualprose.com
------------------------------------------------------------------------
[2004-11-03 01:01:15] helly@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.
A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc.
If possible, make the script source available online and provide
an URL to it here. Try avoid embedding huge scripts into the report.
One you get correct Acutal/Expected info come back.
------------------------------------------------------------------------
[2004-11-02 12:45:27] mx at tut dot by
Description:
------------
behavior of get_class_vars() changed between 13 Sep 2004 and 22 Oct
2004. Is it correct?
Reproduce code:
---------------
<?
class A {
private $user;
protected $group;
public $world;
function dump() {
print_r(get_object_vars($this));
}
}
class B extends A {
public $zoo;
}
$a = new B();
print_r(get_class_vars(get_class($a)));
print_r(get_object_vars($a));
$a->dump();
?>
Expected result:
----------------
Array ( [zoo] => [group] => [world] => )
Array ( [zoo] => [group] => [world] => )
Array ( [zoo] => [group] => [world] => )
Actual result:
--------------
Array ( [zoo] => [world] => )
Array ( [zoo] => [world] => )
Array ( [zoo] => [group] => [world] => )
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=30659&edit=1