Page MenuHomePhabricator

D9936.id23866.diff
No OneTemporary

D9936.id23866.diff

diff --git a/src/utils/__tests__/PhutilUtilsTestCase.php b/src/utils/__tests__/PhutilUtilsTestCase.php
--- a/src/utils/__tests__/PhutilUtilsTestCase.php
+++ b/src/utils/__tests__/PhutilUtilsTestCase.php
@@ -577,9 +577,9 @@
$this->assertEqual(
implode("\n", array(
'array(',
- ' 0 => 1,',
- ' 1 => 2,',
- ' 2 => 3,',
+ ' 1,',
+ ' 2,',
+ ' 3,',
')',
)),
phutil_var_export(array(1, 2, 3)));
@@ -594,7 +594,7 @@
$this->assertEqual(
implode("\n", array(
'array(',
- ' 0 => stdClass::__set_state(array(',
+ ' stdClass::__set_state(array(',
' )),',
')',
)),
diff --git a/src/utils/utils.php b/src/utils/utils.php
--- a/src/utils/utils.php
+++ b/src/utils/utils.php
@@ -1090,6 +1090,9 @@
return 'array()';
}
+ // Don't show keys for non-associative arrays.
+ $show_keys = (array_keys($var) !== range(0, count($var) - 1));
+
$output = array();
$output[] = 'array(';
@@ -1100,8 +1103,7 @@
$output[] = implode('', array(
str_repeat(' ', $indent),
- var_export($key, true),
- ' => ',
+ $show_keys ? var_export($key, true).' => ' : '',
str_replace(
"\n",
"\n".str_repeat(' ', $indent), phutil_var_export($value)),

File Metadata

Mime Type
text/plain
Expires
Mon, Aug 4, 7:39 AM (3 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
8906230
Default Alt Text
D9936.id23866.diff (1 KB)

Event Timeline