application icon indicating copy to clipboard operation
application copied to clipboard

#[Parameter]: throw if not set without default value

Open vrana opened this issue 7 months ago • 0 comments

  • new feature
  • BC break? yes
  • doc PR: n/a

I have this property:

	#[Parameter]
	public string $code;

If there's no ?code= in URL and I access $this->code then PHP dies with this fatal error:

Typed property Presenter::$code must not be accessed before initialization

I would prefer to behave it the same way as if there's a missing parameter with render(int $code) which is to throw InvalidArgumentException.

vrana avatar Aug 28 '25 12:08 vrana