File tree Expand file tree Collapse file tree 2 files changed +18
-14
lines changed
Expand file tree Collapse file tree 2 files changed +18
-14
lines changed Original file line number Diff line number Diff line change 99
1010namespace loophp \PhpUnitIterableAssertions \Constraint ;
1111
12- use loophp \iterators \IterableIterator ;
12+ use Iterator ;
13+ use loophp \iterators \IterableIteratorAggregate ;
14+ use loophp \iterators \MultipleIterableAggregate ;
1315use MultipleIterator ;
1416use PHPUnit \Framework \Constraint \Constraint ;
1517
@@ -45,12 +47,12 @@ public function toString(): string
4547 */
4648 protected function matches ($ other ): bool
4749 {
48- $ i1 = new IterableIterator ($ this ->subject );
49- $ i2 = new IterableIterator ($ other );
50+ [$ subject , $ other ] = array_map (
51+ static fn (iterable $ iterable ): Iterator => (new IterableIteratorAggregate ($ iterable ))->getIterator (),
52+ [$ this ->subject , $ other ]
53+ );
5054
51- $ mi = new MultipleIterator (MultipleIterator::MIT_NEED_ALL );
52- $ mi ->attachIterator ($ i1 );
53- $ mi ->attachIterator ($ i2 );
55+ $ mi = new MultipleIterableAggregate ([$ subject , $ other ], MultipleIterator::MIT_NEED_ALL );
5456
5557 $ index = 0 ;
5658
@@ -71,7 +73,7 @@ protected function matches($other): bool
7173 }
7274
7375 if (0 === $ this ->limit ) {
74- if ($ i1 ->valid () !== $ i2 ->valid ()) {
76+ if ($ subject ->valid () !== $ other ->valid ()) {
7577 return false ;
7678 }
7779 }
Original file line number Diff line number Diff line change 99
1010namespace loophp \PhpUnitIterableAssertions \Constraint ;
1111
12- use loophp \iterators \IterableIterator ;
12+ use Iterator ;
13+ use loophp \iterators \IterableIteratorAggregate ;
14+ use loophp \iterators \MultipleIterableAggregate ;
1315use MultipleIterator ;
1416use PHPUnit \Framework \Constraint \Constraint ;
1517
@@ -45,12 +47,12 @@ public function toString(): string
4547 */
4648 protected function matches ($ other ): bool
4749 {
48- $ i1 = new IterableIterator ($ this ->subject );
49- $ i2 = new IterableIterator ($ other );
50+ [$ subject , $ other ] = array_map (
51+ static fn (iterable $ iterable ): Iterator => (new IterableIteratorAggregate ($ iterable ))->getIterator (),
52+ [$ this ->subject , $ other ]
53+ );
5054
51- $ mi = new MultipleIterator (MultipleIterator::MIT_NEED_ALL );
52- $ mi ->attachIterator ($ i1 );
53- $ mi ->attachIterator ($ i2 );
55+ $ mi = new MultipleIterableAggregate ([$ subject , $ other ], MultipleIterator::MIT_NEED_ALL );
5456
5557 $ index = 0 ;
5658
@@ -71,7 +73,7 @@ protected function matches($other): bool
7173 }
7274
7375 if (0 === $ this ->limit ) {
74- if ($ i1 ->valid () !== $ i2 ->valid ()) {
76+ if ($ subject ->valid () !== $ other ->valid ()) {
7577 return true ;
7678 }
7779 }
You can’t perform that action at this time.
0 commit comments