From 4e0946a788b4ac42ea903b761c693ec7dd083a69 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Sun, 10 Dec 2023 15:59:43 +0100 Subject: [PATCH] Container::getComponents() parameters are silently deprecated --- src/ComponentModel/Container.php | 9 +++++---- src/ComponentModel/IContainer.php | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/ComponentModel/Container.php b/src/ComponentModel/Container.php index df3af13..ec74fa1 100644 --- a/src/ComponentModel/Container.php +++ b/src/ComponentModel/Container.php @@ -178,12 +178,13 @@ protected function createComponent(string $name): ?IComponent /** - * Iterates over descendants components. - * @return iterable + * Returns immediate child components. + * @return array */ - final public function getComponents(bool $deep = false, ?string $filterType = null): iterable + final public function getComponents(): iterable { - if ($deep) { + $filterType = func_get_args()[1] ?? null; + if (func_get_args()[0] ?? null) { // back compatibility $iterator = new RecursiveComponentIterator($this->components); $iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST); if ($filterType) { diff --git a/src/ComponentModel/IContainer.php b/src/ComponentModel/IContainer.php index 9ed605f..12cfb84 100644 --- a/src/ComponentModel/IContainer.php +++ b/src/ComponentModel/IContainer.php @@ -35,8 +35,8 @@ function removeComponent(IComponent $component): void; function getComponent(string $name): ?IComponent; /** - * Iterates over descendants components. - * @return iterable + * Returns immediate child components. + * @return array */ function getComponents(): iterable; }