Skip to content

Commit

Permalink
Dumper::toLine() improved dump of empty array
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jan 21, 2016
1 parent 436687d commit cf10fe1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Framework/Dumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static function toLine($var)
break;
}
$out .= ($k === $counter ? '' : self::toLine($k) . ' => ')
. (is_array($v) ? 'array(...)' : self::toLine($v));
. (is_array($v) && $v ? 'array(...)' : self::toLine($v));
$counter = is_int($k) ? max($k + 1, $counter) : $counter;
}
return "array($out)";
Expand Down
2 changes: 1 addition & 1 deletion tests/Framework/Dumper.toLine.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ if (PHP_VERSION_ID >= 50500) {
Assert::match('array()', Dumper::toLine(array()));
Assert::match("array(1, 2, 3, 4, 'x')", Dumper::toLine(array(1, 2, 3, 4, 'x')));
Assert::match('array(1 => 1, 2, 3)', Dumper::toLine(array(1 => 1, 2, 3)));
Assert::match("array('a' => array(...))", Dumper::toLine(array('a' => array(1, 2))));
Assert::match("array('a' => array(...), array())", Dumper::toLine(array('a' => array(1, 2), array())));
Assert::match("array('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', ...)", Dumper::toLine(array('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve')));

0 comments on commit cf10fe1

Please sign in to comment.