ID: 29509
Updated by: [EMAIL PROTECTED]
Reported By: ap at ath0 dot org
-Status: Open
+Status: Closed
Bug Type: Feature/Change Request
Operating System: Linux 2.6.7
PHP Version: 5.0.0
New Comment:
Fixed long time ago.
Previous Comments:
------------------------------------------------------------------------
[2004-08-03 19:45:11] ap at ath0 dot org
Description:
------------
When using get_class_vars() inside a class it does not act how it is
documented on php.net. But that is not the main problem. It seems as if
get_class_vars() is creating some strange identifiers in its resulting
array, making it effictively unusable.
I already found out, that protected members are prefixed by '*' and
private members are prepended with the classname, but the
identifier-string is longer, than it should be.
When accessing my test-program with a web-browser there are some weird
(probably multibyte) characters at the end of identifiers for protected
and private members, which don't show up in a terminal using the CLI
binary.
I'm not sure if this behaviour is expected (since it's not documented),
but there would be no point in having get_class_vars() returning
something that cannot be used subsequently.
And IMHO the Reflection-API behaves very differently; e.g. fetching
class attributes in at least 5 lines (via Reflaction API) vs. a
one-line call to fetch all attributes (via get_class_vars()).
Reproduce code:
---------------
class test {
public $foo1;
protected $foo2;
private $foo3;
public function __construct() {
$this->foo1 = 'public';
$this->foo2 = 'protected';
$this->foo3 = 'private';
}
}
$bar = array_keys(get_class_vars('test'));
var_dump($bar);
Expected result:
----------------
array(3) {
[0]=>
string(4) "foo1"
[1]=>
string(5) "*foo2"
[2]=>
string(8) "testfoo3"
}
Actual result:
--------------
array(3) {
[0]=>
string(4) "foo1"
[1]=>
string(7) "*foo2"
[2]=>
string(10) "testfoo3"
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=29509&edit=1