diff --git a/composer.json b/composer.json index 5f2e011..983aa14 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "Collections library for php language", "minimum-stability": "dev", "license": "MIT", - "version": "1.1.2", + "version": "1.1.3", "authors": [ { "name": "Maxim Sokolovsky", diff --git a/src/WS/Utils/Collections/CollectionFactory.php b/src/WS/Utils/Collections/CollectionFactory.php index a4fb7e5..794938c 100644 --- a/src/WS/Utils/Collections/CollectionFactory.php +++ b/src/WS/Utils/Collections/CollectionFactory.php @@ -101,13 +101,16 @@ public static function empty(): Collection private static function isStatePatternIterator(iterable $iterable): bool { + if (!is_object($iterable)) { + return false; + } $i = 2; $lastItem = null; foreach ($iterable as $item) { if ($i === 0) { break; } - if (is_object($item) && $item === $lastItem) { + if (is_object($item) && $item === $lastItem && method_exists($item, 'rewind')) { return true; } $lastItem = $item;