Skip to content

Commit 46105cb

Browse files
committed
Container::getComponents() removed method parameters (BC break)
1 parent ca59dac commit 46105cb

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
@@ -179,19 +179,17 @@ protected function createComponent(string $name): ?IComponent
179179
*/
180180
final public function getComponents(): iterable
181181
{
182+
if (func_get_args()[0] ?? null) {
183+
throw new Nette\DeprecatedException('Using Container::getComponents() with recursive flag is deprecated. Use getComponentTree() instead.');
184+
}
185+
182186
$filterType = func_get_args()[1] ?? null;
183-
if (func_get_args()[0] ?? null) { // back compatibility
184-
$iterator = new RecursiveComponentIterator($this->components);
185-
$iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
186-
if ($filterType) {
187-
$iterator = new \CallbackFilterIterator($iterator, fn($item) => $item instanceof $filterType);
188-
}
189-
return $iterator;
187+
if ($filterType) {
188+
trigger_error('Using Container::getComponents() with filter type is deprecated.', E_USER_DEPRECATED);
189+
return array_filter($this->components, fn($item) => $item instanceof $filterType);
190190
}
191191

192-
return $filterType
193-
? array_filter($this->components, fn($item) => $item instanceof $filterType)
194-
: $this->components;
192+
return $this->components;
195193
}
196194

197195

src/ComponentModel/RecursiveComponentIterator.php

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

0 commit comments

Comments
 (0)