Re: Allowing NULL for some internal functions

From: Date: Mon, 21 Feb 2022 09:04:16 +0000
Subject: Re: Allowing NULL for some internal functions
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-117085@lists.php.net to get a copy of this message
On 20.02.2022 at 21:38, Craig Francis wrote: > On Sat, 1 Jan 2022 at 23:17, Craig Francis <craig@craigfrancis.co.uk> wrote: > >> Draft RFC: >> https://wiki.php.net/rfc/allow_null >> > > > I've been over-complicating this... why should NULL be treated so > differently? > > <?php > $values = ['a', 1, 2.3, false, NULL]; > foreach ($values as $value) { > echo urlencode($value); > } > ?> > > It just struck me, this whole thing is about type coercion when not using > strict_types=1; and the 8.1 change has introduced an > inconstancy by > deprecating the coercion of NULL, a frequently used value. That "inconsistency" had been introduced with PHP 7.0.0, i.e. right when scalar type declarations have been introduced. Passing a null to a non-nullable parameter of a *userland* function throws a TypeError: <https://3v4l.org/lbF4h>. As of PHP 8.1.0, internal functions behave the same as userland function in this regard. -- Christoph M. Becker

« previous php.internals (#117085) next »