File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ final class ArrayAdapter implements AdapterInterface
2424 /**
2525 * @param MessageInterface[]
2626 */
27- protected $ queue ;
27+ protected $ queue = [] ;
2828
2929 /**
3030 * @param MessageInterface[] $messages
@@ -49,9 +49,15 @@ public function acknowledge(array $messages)
4949 */
5050 public function dequeue (MessageFactoryInterface $ factory , $ limit )
5151 {
52- $ total = null === $ limit ? count ($ this ->queue ) : $ limit ;
52+ /**
53+ * If {@see $limit} is null then {@see LimitIterator} should be passed -1 as the count
54+ * to avoid throwing OutOfBoundsException.
55+ *
56+ * @link https://github.com/php/php-src/blob/php-5.6.12/ext/spl/internal/limititerator.inc#L60-L62
57+ */
58+ $ count = (null === $ limit ) ? -1 : $ limit ;
5359
54- return new LimitIterator (new ArrayIterator ($ this ->queue ), 0 , $ total );
60+ return new LimitIterator (new ArrayIterator ($ this ->queue ), 0 , $ count );
5561 }
5662
5763 /**
You can’t perform that action at this time.
0 commit comments