Skip to content

Required but nullable arguments should be required to be specified in the config #271

@ondrejmirtes

Description

@ondrejmirtes

Let's say we have a constructor that looks like this:

	public function __construct(
		private ?string $singleReflectionFile
	)

And we have a service config that looks like this:

	-
		class: Foo

In this case nette/di will autowire the null value into this constructor parameter. But the the constructor parameter is required for a reason - I want the user to specify it. Omitting it is dangerous because the library can't assume that the user wants null in there, because they might not even know that I want them to specify the value. I want the user to explicitly pass a value.

I realize this is a big BC break, but maybe the behaviour could be opt-in with some feature toggle before making it mandatory in the next major version.

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