Skip to content

Container::getComponents() returns incorrect type #141

Open
@jtojnar

Description

@jtojnar

component-model 3.1.0 returns array Container::getComponents() when $deep === false:

nette/component-model@7f613ee

instead of Iterator:

* @phpstan-return ($filterType is null ? \Iterator<int|string, \Nette\ComponentModel\IComponent> : \Iterator<int|string, T>)
*/
public function getComponents(bool $deep = false, string $filterType = null): \Iterator

The return type should be something like

@phpstan-return (
    $deep is true
    ? ($filterType is null ? array<int|string, \Nette\ComponentModel\IComponent> : array<int|string, T>)
    : ($filterType is null ? \Iterator<int|string, \Nette\ComponentModel\IComponent> : \Iterator<int|string, T>)
)

I can open a PR but not sure what to do about older versions. Should I just add conflict with < 3.1.0?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions