Skip to content

Commit

Permalink
tweak: handle nullable iterables
Browse files Browse the repository at this point in the history
closes #473
  • Loading branch information
g105b committed Nov 3, 2023
1 parent edbfd6b commit 53f767b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/DocumentBinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function bindData(
}
}

foreach($kvp as $key => $value) {
foreach($kvp ?? [] as $key => $value) {
$this->bindKeyValue($key, $value, $context);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ListBinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private function isKVP(mixed $item):bool {
private function isNested(mixed $item):bool {
if(is_array($item)) {
$key = array_key_first($item);
return is_int($key) || is_iterable($item[$key]);
return is_int($key) || (isset($item[$key]) && is_iterable($item[$key]));
}
elseif($item instanceof Iterator) {
return true;
Expand Down

0 comments on commit 53f767b

Please sign in to comment.