Skip to content

Commit e7e21d8

Browse files
committed
Container::getComponent() removed arguments (BC break)
1 parent 18541fd commit e7e21d8

File tree

2 files changed

+10
-57
lines changed

2 files changed

+10
-57
lines changed

src/ComponentModel/Container.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace Nette\ComponentModel;
1111

12+
use _PHPStan_f91572c4b\Nette\DeprecatedException;
1213
use Nette;
1314
use function array_filter, array_keys, array_map, array_merge, assert, explode, func_get_args, get_class_methods, method_exists, preg_filter, preg_match, reset, ucfirst;
1415

@@ -184,19 +185,17 @@ protected function createComponent(string $name): ?IComponent
184185
*/
185186
final public function getComponents(): iterable
186187
{
187-
$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;
188+
if (func_get_args()[0] ?? null) {
189+
throw new DeprecatedException('Using Container::getComponents() with recursive flag is deprecated. Use getComponentTree() instead.');
195190
}
196191

197-
return $filterType
198-
? array_filter($this->components, fn($item) => $item instanceof $filterType)
199-
: $this->components;
192+
$filterType = func_get_args()[1] ?? null;
193+
if ($filterType) {
194+
trigger_error('Using Container::getComponents() with filter type is deprecated.', E_USER_DEPRECATED);
195+
return array_filter($this->components, fn($item) => $item instanceof $filterType);
196+
}
197+
198+
return $this->components;
200199
}
201200

202201

src/ComponentModel/RecursiveComponentIterator.php

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

0 commit comments

Comments
 (0)