From: Derick Rethans Date: Wed, 7 Jan 2009 14:35:50 +0000 (+0000) Subject: - Fixed bug #47027 (var_export doesn't show numeric indices on ArrayObject). X-Git-Tag: php-5.4.0alpha1~191^2~4612 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c1dec4858c954699220566fc8494b2609a7d36dc;p=php - Fixed bug #47027 (var_export doesn't show numeric indices on ArrayObject). --- diff --git a/ext/standard/tests/general_functions/bug47027.phpt b/ext/standard/tests/general_functions/bug47027.phpt new file mode 100644 index 0000000000..e4f5aae9dd --- /dev/null +++ b/ext/standard/tests/general_functions/bug47027.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #47027 (var_export doesn't show numeric indices on ArrayObject) +--FILE-- + "foo", "bar" => "baz")); +var_export ($ao); +?> +--EXPECT-- +ArrayObject::__set_state(array( + 2 => 'foo', + 'bar' => 'baz', +)) diff --git a/ext/standard/var.c b/ext/standard/var.c index 459a1fe3c0..6ec866c683 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -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; } /* }}} */