Hello internals,
i want to chnage the output of print_r() and var_dump() so that it
shows the class a private property was declared in. The problem is that at
the moment both only state that the property is private so that you cannot
see which class level it belongs to and if there is any derived class with
a private property having the same name you cannot distinguish them.
See patch attached.
Here is the output of the unpatched version:
php > class T {
php { protected $pro = 1;
php { private $pri = 2;
php { public $pub = 3;
php { }
ew T;
php > $o = new T;
php > print_r($o);
T Object
(
[pro:protected] => 1
[pri:private] => 2
[pub] => 3
)
php > class TT extends T {
php { private $pri = 4;
php { }
php > $oo = new TT;
php > print_r($oo);
TT Object
(
[pri:private] => 4
[pro:protected] => 1
[pri:private] => 2
[pub] => 3
)
php >
Here is the output of the patched version:
php > class T {
php { protected $pro = 1;
php { private $pri = 2;
php { public $pub = 3;
php { }
php > $o = new T;
php > print_r($o);
T Object
(
[pro:protected] => 1
[pri:private:T] => 2
[pub] => 3
)
php > class TT extends T {
php { private $pri = 4;
php { }
php > $oo = new TT;
php > print_r($oo);
TT Object
(
[pri:private:TT] => 4
[pro:protected] => 1
[pri:private:T] => 2
[pub] => 3
)
If nobody objects i'll apply this tomorrow.
--
Best regards,
Marcus mailto:[EMAIL PROTECTED]
Index: ext/standard/var.c
===================================================================
RCS file: /repository/php-src/ext/standard/var.c,v
retrieving revision 1.198
diff -u -p -d -r1.198 var.c
--- ext/standard/var.c 23 Feb 2005 11:17:52 -0000 1.198
+++ ext/standard/var.c 21 May 2005 14:28:56 -0000
@@ -81,7 +81,8 @@ static int php_object_property_dump(zval
if (class_name[0]=='*') {
ZEND_PUTS(":protected");
} else {
- ZEND_PUTS(":private");
+ ZEND_PUTS(":private:");
+ ZEND_PUTS(class_name);
}
} else {
php_printf("%*c[\"%s", level + 1, ' ', hash_key->arKey);
Index: Zend/zend.c
===================================================================
RCS file: /repository/ZendEngine2/zend.c,v
retrieving revision 1.300
diff -u -p -d -r1.300 zend.c
--- Zend/zend.c 18 May 2005 18:10:24 -0000 1.300
+++ Zend/zend.c 21 May 2005 14:28:57 -0000
@@ -133,7 +133,8 @@ static void print_hash(HashTable *ht, in
if (class_name[0]=='*') {
ZEND_PUTS(":protected");
} else {
- ZEND_PUTS(":private");
+ ZEND_PUTS(":private:");
+ ZEND_PUTS(class_name);
}
}
} else {
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php