#43054 [Com]: get_object_vars scope
| From: | felipensp at gmail dot com | Date: | Sat, 20 Oct 2007 19:35:10 +0000 |
| Subject: | #43054 [Com]: get_object_vars scope | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-118767@lists.php.net to get a copy of this message | ||
ID: 43054
Comment by: felipensp at gmail dot com
Reported By: pdobrigkeit at gmx dot de
Status: Open
Bug Type: Unknown/Other Function
Operating System: Windows XP
PHP Version: 5.2.4
New Comment:
This isn't a bug.
See http://br2.php.net/manual/en/language.oop5.visibility.php
Previous Comments:
------------------------------------------------------------------------
[2007-10-20 19:08:44] pdobrigkeit at gmx dot de
Description:
------------
Inherited Objects call a get_object_vars method in a parent. Scope
should be of the type of object actually calling the method, but private
members of the child do not recognized.
Reproduce code:
---------------
<?php
class Base {
function getObjectVars() {
print_r(get_object_vars($this));
}
}
class Child extends Base{
private $varA = 'VarA';
protected $varB = 'VarB';
public $varC = 'VarC';
function __construct() {
$this->getObjectVars();
}
}
$child = new Child();
?>
Expected result:
----------------
Array ([varA] => VarA [varB] => VarB [varC] => VarC )
Actual result:
--------------
Array ( [varB] => VarB [varC] => VarC )
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=43054&edit=1