Skip to content

Commit

Permalink
ArrayHash: fixed bug in ArrayIterator [Closes #103]
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Mar 18, 2016
1 parent 35263bb commit 34ca4cd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Utils/ArrayHash.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static function from($arr, $recursive = TRUE)
*/
public function getIterator()
{
return new \RecursiveArrayIterator($this);
return new \RecursiveArrayIterator((array) $this);
}


Expand Down
9 changes: 9 additions & 0 deletions tests/Utils/ArrayHash.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,12 @@ test(function () { // undeclared fields
$row['undef'];
}, E_NOTICE, 'Undefined property: Nette\Utils\ArrayHash::$undef');
});


test(function () { // PHP 7 changed behavior https://3v4l.org/2A1pf
$hash = ArrayHash::from(array(1, 2, 3));
foreach ($hash as $key => $value) {
unset($hash->$key);
}
Assert::count(0, $hash);
});

0 comments on commit 34ca4cd

Please sign in to comment.