@@ -101,11 +101,7 @@ public function testLIFOOnly()
101101 $ this ->list ->insert ('foobar ' , new \stdClass ());
102102 $ this ->list ->insert ('barbaz ' , new \stdClass ());
103103
104- $ orders = [];
105-
106- foreach ($ this ->list as $ key => $ value ) {
107- $ orders [] = $ key ;
108- }
104+ $ orders = array_keys (iterator_to_array ($ this ->list ));
109105
110106 $ this ->assertEquals (['barbaz ' , 'foobar ' , 'baz ' , 'bar ' , 'foo ' ], $ orders );
111107 }
@@ -116,11 +112,7 @@ public function testPriorityOnly()
116112 $ this ->list ->insert ('bar ' , new \stdClass (), 0 );
117113 $ this ->list ->insert ('baz ' , new \stdClass (), 2 );
118114
119- $ order = [];
120-
121- foreach ($ this ->list as $ key => $ value ) {
122- $ orders [] = $ key ;
123- }
115+ $ orders = array_keys (iterator_to_array ($ this ->list ));
124116
125117 $ this ->assertEquals (['baz ' , 'foo ' , 'bar ' ], $ orders );
126118 }
@@ -131,11 +123,7 @@ public function testLIFOWithPriority()
131123 $ this ->list ->insert ('bar ' , new \stdClass (), 0 );
132124 $ this ->list ->insert ('baz ' , new \stdClass (), 1 );
133125
134- $ orders = [];
135-
136- foreach ($ this ->list as $ key => $ value ) {
137- $ orders [] = $ key ;
138- }
126+ $ orders = array_keys (iterator_to_array ($ this ->list ));
139127
140128 $ this ->assertEquals (['baz ' , 'bar ' , 'foo ' ], $ orders );
141129 }
@@ -147,11 +135,7 @@ public function testFIFOWithPriority()
147135 $ this ->list ->insert ('bar ' , new \stdClass (), 0 );
148136 $ this ->list ->insert ('baz ' , new \stdClass (), 1 );
149137
150- $ orders = [];
151-
152- foreach ($ this ->list as $ key => $ value ) {
153- $ orders [] = $ key ;
154- }
138+ $ orders = array_keys (iterator_to_array ($ this ->list ));
155139
156140 $ this ->assertEquals (['baz ' , 'foo ' , 'bar ' ], $ orders );
157141 }
@@ -165,11 +149,7 @@ public function testFIFOOnly()
165149 $ this ->list ->insert ('foobar ' , new \stdClass ());
166150 $ this ->list ->insert ('barbaz ' , new \stdClass ());
167151
168- $ orders = [];
169-
170- foreach ($ this ->list as $ key => $ value ) {
171- $ orders [] = $ key ;
172- }
152+ $ orders = array_keys (iterator_to_array ($ this ->list ));
173153
174154 $ this ->assertEquals (['foo ' , 'bar ' , 'baz ' , 'foobar ' , 'barbaz ' ], $ orders );
175155 }
@@ -180,11 +160,7 @@ public function testPriorityWithNegativesAndNull()
180160 $ this ->list ->insert ('bar ' , new \stdClass (), 1 );
181161 $ this ->list ->insert ('baz ' , new \stdClass (), -1 );
182162
183- $ orders = [];
184-
185- foreach ($ this ->list as $ key => $ value ) {
186- $ orders [] = $ key ;
187- }
163+ $ orders = array_keys (iterator_to_array ($ this ->list ));
188164
189165 $ this ->assertEquals (['bar ' , 'foo ' , 'baz ' ], $ orders );
190166 }
0 commit comments