Re: [RFC] Deprecate implicitly nullable parameter type

From: Date: Mon, 22 Jan 2024 11:15:29 +0000
Subject: Re: [RFC] Deprecate implicitly nullable parameter type
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-122220@lists.php.net to get a copy of this message
On Mon, 22 Jan 2024 at 11:51, Gina P. Banyard <internals@gpb.moe> wrote: > Hello internals, > > Máté Kocsis and myself would like to propose deprecating implicitly > nullable parameter types. > > The RFC is available on the wiki at the following address: > https://wiki.php.net/rfc/deprecate-implicitly-nullable-types > > > Best regards, > > Gina P. Banyard > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > > I just encountered this language inconsistency when trying to remove nullable from a constructor-promoted property: ``` class MyClass { public function __construct( public ?string $title = null // removing "?" here causes "Fatal error: Cannot use null as default value" ) { $this->title = $title ?: resolveTitle(); } } ``` Which is fine, there's a simple workaround, it was just surprising.

« previous php.internals (#122220) next »