Skip to content

Commit

Permalink
avoid type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
schmittjoh committed Mar 21, 2022
1 parent 4bf7f27 commit 56d18c8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/PhpCollection/AbstractMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public function count()

public function getIterator()
{
return new \ArrayIterator($this->elements);
return new \ArrayIterator($this->elements ?: []);
}

protected function createNew(array $elements)
Expand Down
4 changes: 2 additions & 2 deletions src/PhpCollection/AbstractSequence.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,11 @@ public function count()

public function getIterator()
{
return new \ArrayIterator($this->elements);
return new \ArrayIterator($this->elements ?: []);
}

protected function createNew(array $elements)
{
return new static($elements);
}
}
}
4 changes: 2 additions & 2 deletions src/PhpCollection/Set.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function last()

public function getIterator()
{
return new \ArrayIterator(array_values($this->elements));
return new \ArrayIterator(array_values($this->elements ?: []));
}

public function addSet(SetInterface $set)
Expand Down Expand Up @@ -446,4 +446,4 @@ private function insertElement($elem, $hash)
$this->elements[$index] = $elem;
$this->lookup[$hash][] = $index;
}
}
}

0 comments on commit 56d18c8

Please sign in to comment.