]> granicus.if.org Git - php/commitdiff
- MFH: Fixed bug #47027 (var_export doesn't show numeric indices on ArrayObject).
authorDerick Rethans <derick@php.net>
Wed, 7 Jan 2009 14:36:07 +0000 (14:36 +0000)
committerDerick Rethans <derick@php.net>
Wed, 7 Jan 2009 14:36:07 +0000 (14:36 +0000)
ext/standard/tests/general_functions/bug47027.phpt [new file with mode: 0644]
ext/standard/var.c

diff --git a/ext/standard/tests/general_functions/bug47027.phpt b/ext/standard/tests/general_functions/bug47027.phpt
new file mode 100644 (file)
index 0000000..e4f5aae
--- /dev/null
@@ -0,0 +1,12 @@
+--TEST--
+Bug #47027 (var_export doesn't show numeric indices on ArrayObject)
+--FILE--
+<?php
+$ao = new ArrayObject(array (2 => "foo", "bar" => "baz"));
+var_export ($ao);
+?>
+--EXPECT--
+ArrayObject::__set_state(array(
+   2 => 'foo',
+   'bar' => 'baz',
+))
index c99b7d3b0bdc65640901e2b7cd19ef0d8262a731..3f363cd5b2b3c369a2d29a78b7d12daa6b13bb21 100644 (file)
@@ -363,13 +363,15 @@ static int php_object_element_export(zval **zv TSRMLS_DC, int num_args, va_list
 
        level = va_arg(args, int);
 
+       php_printf("%*c", level + 1, ' ');
        if (hash_key->nKeyLength != 0) {
-               php_printf("%*c", level + 1, ' ');
                zend_unmangle_property_name(hash_key->arKey, hash_key->nKeyLength - 1, &class_name, &prop_name);
                php_printf(" '%s' => ", prop_name);
-               php_var_export(zv, level + 2 TSRMLS_CC);
-               PUTS (",\n");
+       } else {
+               php_printf(" %ld => ", hash_key->h);
        }
+       php_var_export(zv, level + 2 TSRMLS_CC);
+       PUTS (",\n");
        return 0;
 }
 /* }}} */