diff --git a/src/Framework/Constraint/Count.php b/src/Framework/Constraint/Count.php index 1ce9d3d0c23..194844c097c 100644 --- a/src/Framework/Constraint/Count.php +++ b/src/Framework/Constraint/Count.php @@ -106,7 +106,7 @@ protected function getCountOf($other) // moves pointer if ($key !== null) { $iterator->rewind(); - while ($key !== $iterator->key()) { + while ($iterator->valid() && $key !== $iterator->key()) { $iterator->next(); } }