Skip to content
Permalink
Browse files

Fix wrong dimensions when the first element is false.

  • Loading branch information...
yutmr committed Jan 6, 2017
1 parent 9eb07d5 commit 072d8cf8374ac1965d642944fb21495984493917
Showing with 8 additions and 1 deletion.
  1. +1 −1 src/Utility/Hash.php
  2. +7 −0 tests/TestCase/Utility/HashTest.php
@@ -837,7 +837,7 @@ public static function dimensions(array $data)
public static function maxDimensions(array $data)
{
$depth = [];
if (is_array($data) && reset($data) !== false) {
if (is_array($data) && !empty($data)) {
foreach ($data as $value) {
if (is_array($value)) {
$depth[] = static::maxDimensions($value) + 1;
@@ -506,6 +506,13 @@ public function testMaxDimensions()
];
$result = Hash::maxDimensions($data);
$this->assertEquals($result, 5);
$data = [
'1' => false,
'2' => ['2.1' => '2.1.1']
];
$result = Hash::maxDimensions($data);
$this->assertEquals($result, 2);
}
/**

0 comments on commit 072d8cf

Please sign in to comment.
You can’t perform that action at this time.