File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change 33 "description" : " Collections library for php language" ,
44 "minimum-stability" : " dev" ,
55 "license" : " MIT" ,
6- "version" : " 1.1.3 " ,
6+ "version" : " 1.1.4 " ,
77 "authors" : [
88 {
99 "name" : " Maxim Sokolovsky" ,
Original file line number Diff line number Diff line change @@ -76,11 +76,11 @@ public static function fromStrict(array $values): Collection
7676 */
7777 public static function fromIterable (iterable $ iterable ): Collection
7878 {
79+ if ($ iterable instanceof IteratorAggregate) {
80+ /** @noinspection PhpUnhandledExceptionInspection */
81+ $ iterable = $ iterable ->getIterator ();
82+ }
7983 if (self ::isStatePatternIterator ($ iterable )) {
80- if ($ iterable instanceof IteratorAggregate) {
81- /** @noinspection PhpUnhandledExceptionInspection */
82- $ iterable = $ iterable ->getIterator ();
83- }
8484 if (!$ iterable instanceof Iterator) {
8585 throw new UnsupportedException ('Only Iterator interface can be applied to IteratorCollection ' );
8686 }
@@ -104,13 +104,16 @@ private static function isStatePatternIterator(iterable $iterable): bool
104104 if (!is_object ($ iterable )) {
105105 return false ;
106106 }
107+ if (!method_exists ($ iterable , 'rewind ' )) {
108+ return false ;
109+ }
107110 $ i = 2 ;
108111 $ lastItem = null ;
109112 foreach ($ iterable as $ item ) {
110113 if ($ i === 0 ) {
111114 break ;
112115 }
113- if (is_object ($ item ) && $ item === $ lastItem && method_exists ( $ item , ' rewind ' ) ) {
116+ if (is_object ($ item ) && $ item === $ lastItem ) {
114117 return true ;
115118 }
116119 $ lastItem = $ item ;
You can’t perform that action at this time.
0 commit comments