Skip to content

Commit 712fd74

Browse files
committed
Container::getComponent() removed arguments (BC break)
1 parent 0614c98 commit 712fd74

File tree

2 files changed

+8
-56
lines changed

2 files changed

+8
-56
lines changed

src/ComponentModel/Container.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -184,19 +184,17 @@ protected function createComponent(string $name): ?IComponent
184184
*/
185185
final public function getComponents(): iterable
186186
{
187+
if (func_get_args()[0] ?? null) {
188+
throw new DeprecatedException('Using Container::getComponents() with recursive flag is deprecated. Use getComponentTree() instead.');
189+
}
190+
187191
$filterType = func_get_args()[1] ?? null;
188-
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;
192+
if ($filterType) {
193+
trigger_error('Using Container::getComponents() with filter type is deprecated.', E_USER_DEPRECATED);
194+
return array_filter($this->components, fn($item) => $item instanceof $filterType);
195195
}
196196

197-
return $filterType
198-
? array_filter($this->components, fn($item) => $item instanceof $filterType)
199-
: $this->components;
197+
return $this->components;
200198
}
201199

202200

src/ComponentModel/RecursiveComponentIterator.php

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)