Skip to content

Commit 56d18c8

Browse files
committed
avoid type errors
1 parent 4bf7f27 commit 56d18c8

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/PhpCollection/AbstractMap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ public function count()
294294

295295
public function getIterator()
296296
{
297-
return new \ArrayIterator($this->elements);
297+
return new \ArrayIterator($this->elements ?: []);
298298
}
299299

300300
protected function createNew(array $elements)

src/PhpCollection/AbstractSequence.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,11 +355,11 @@ public function count()
355355

356356
public function getIterator()
357357
{
358-
return new \ArrayIterator($this->elements);
358+
return new \ArrayIterator($this->elements ?: []);
359359
}
360360

361361
protected function createNew(array $elements)
362362
{
363363
return new static($elements);
364364
}
365-
}
365+
}

src/PhpCollection/Set.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function last()
5252

5353
public function getIterator()
5454
{
55-
return new \ArrayIterator(array_values($this->elements));
55+
return new \ArrayIterator(array_values($this->elements ?: []));
5656
}
5757

5858
public function addSet(SetInterface $set)
@@ -446,4 +446,4 @@ private function insertElement($elem, $hash)
446446
$this->elements[$index] = $elem;
447447
$this->lookup[$hash][] = $index;
448448
}
449-
}
449+
}

0 commit comments

Comments
 (0)