Skip to content

Commit

Permalink
Container::getComponents() parameters are silently deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Feb 8, 2024
1 parent 7b1421a commit 5ebd8d9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions src/ComponentModel/Container.php
Expand Up @@ -178,12 +178,13 @@ protected function createComponent(string $name): ?IComponent


/**
* Iterates over descendants components.
* Returns immediate child components.
* @return iterable<int|string,IComponent>
*/
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) {
Expand All @@ -192,9 +193,9 @@ final public function getComponents(bool $deep = false, ?string $filterType = nu
return $iterator;
}

return $filterType === null
? $this->components
: array_filter($this->components, fn($item) => $item instanceof $filterType);
return $filterType
? array_filter($this->components, fn($item) => $item instanceof $filterType)
: $this->components;
}


Expand Down
4 changes: 2 additions & 2 deletions src/ComponentModel/IContainer.php
Expand Up @@ -35,8 +35,8 @@ function removeComponent(IComponent $component): void;
function getComponent(string $name): ?IComponent;

/**
* Iterates over descendants components.
* @return iterable<int|string,IComponent>
* Returns immediate child components.
* @return array<int|string,IComponent>
*/
function getComponents(): iterable;
}

0 comments on commit 5ebd8d9

Please sign in to comment.