From: ap at ath0 dot org
Operating system: Linux 2.6.7
PHP version: 5.0.0
PHP Bug Type: Feature/Change Request
Bug description: get_class_vars() returns unusable information
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 bug report at http://bugs.php.net/?id=29509&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=29509&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=29509&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=29509&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=29509&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=29509&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=29509&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=29509&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=29509&r=support
Expected behavior: http://bugs.php.net/fix.php?id=29509&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=29509&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=29509&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=29509&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29509&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=29509&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=29509&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=29509&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=29509&r=float