]> granicus.if.org Git - php/commitdiff
- Fixed bug #47027 (var_export doesn't show numeric indices on ArrayObject).
authorDerick Rethans <derick@php.net>
Wed, 7 Jan 2009 14:35:50 +0000 (14:35 +0000)
committerDerick Rethans <derick@php.net>
Wed, 7 Jan 2009 14:35:50 +0000 (14:35 +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 459a1fe3c0b737e2accc2963e7d17d5eda726c9e..6ec866c68306cf6ca586dbdcf32d5d245fb8e1c9 100644 (file)
@@ -486,13 +486,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_u_unmangle_property_name(hash_key->type, hash_key->arKey, hash_key->nKeyLength - 1, &class_name, &prop_name);
                php_printf(" '%R' => ", hash_key->type, 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;
 }
 /* }}} */