Skip to content

UnexpectedValueException with $throw = false on presenter->getComponent #295

@mskocik

Description

@mskocik

Version: 3.1.2

Bug Description

👉 Presenter with component that can return null under specific conditions.

// exprecting null being stored in $var
$var = $presenter->getComponent('ControlOrNull', false); 

// exception is being thrown in Nette\ComponentModel\Container::createComponent method

Despite setting $throw to false, exception is thrown.

Steps To Reproduce

class MyPresenter extends Presenter {
    public function createComponentControlOrNull(): ?Form
    {
        return null;
    }
}
$val = $presenter->getComponent('ControlOrNull', false); // no exception should be thrown
$vall === true; // should equal true

Expected Behavior

I am able to return null value from createComponent* methods.

Possible Solution

$throw property should be propagated to Nette\ComponentModel\Container::createComponent method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions