File tree Expand file tree Collapse file tree 2 files changed +14
-52
lines changed
Expand file tree Collapse file tree 2 files changed +14
-52
lines changed Original file line number Diff line number Diff line change @@ -186,12 +186,7 @@ final public function getComponents(): iterable
186186 {
187187 $ filterType = func_get_args ()[1 ] ?? null ;
188188 if (func_get_args ()[0 ] ?? null ) { // back compatibility
189- $ iterator = new RecursiveComponentIterator ($ this ->components );
190- $ iterator = new \RecursiveIteratorIterator ($ iterator , \RecursiveIteratorIterator::SELF_FIRST );
191- if ($ filterType ) {
192- $ iterator = new \CallbackFilterIterator ($ iterator , fn ($ item ) => $ item instanceof $ filterType );
193- }
194- return $ iterator ;
189+ return $ this ->getComponentsRecursive ($ filterType );
195190 }
196191
197192 return $ filterType
@@ -200,6 +195,19 @@ final public function getComponents(): iterable
200195 }
201196
202197
198+ private function getComponentsRecursive (?string $ filterType ): \Generator
199+ {
200+ foreach ($ this ->components as $ name => $ component ) {
201+ if (!$ filterType || $ component instanceof $ filterType ) {
202+ yield $ name => $ component ;
203+ }
204+ if ($ component instanceof IContainer) {
205+ yield from $ component ->getComponentsRecursive ($ filterType );
206+ }
207+ }
208+ }
209+
210+
203211 /**
204212 * Retrieves the entire hierarchy of components, including all nested child components (depth-first).
205213 * @return list<IComponent>
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments