Skip to content

Missing return type inference from return $this #12

@JanTvrdik

Description

@JanTvrdik

The following code results in error "Call to an undefined method Nette\Forms\Controls\BaseControl::setItems()". This is because setRequired has annotation @return self. Changing the annotation to @return static does solve the problem. Ideally phpstan should notice return $this and infer the correct return type regardless of annotation.

$form->addSelect('currency')
    ->setRequired()
    ->setItems($currencyList);

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