Re: Allowing NULL for some internal functions

From: Date: Mon, 07 Feb 2022 12:05:00 +0000
Subject: Re: Allowing NULL for some internal functions
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-116991@lists.php.net to get a copy of this message
On Mon, 7 Feb 2022 at 08:36, Mark Randall <marandall@php.net> wrote: > I understand your motivations in proposing them, but to my mind it goes > against the direction that PHP is developing, which I think is the right > one, where errors and likely errors result in stopping execution rather > than allowing it continue > Hi Mark, Thanks for responding. I'm not completely against this approach in general, but I'm trying to find the right balance. Back to my example; most frameworks return NULL when a user value is not provided via GET/POST/COOKIE (this is a useful feature), and many developers simply pass that nullable string through to functions like htmlspecialchars(), urlencode(), etc... I do not understand why this is an error so bad that it must result in a Fatal Error for everyone using PHP 9. As noted before, I can see how NULL might represent a problem in projects using strict_types, but I'm not proposing we change anything for them (also much more likely to be using static analysis). And specifically with NULL, strings in C are a "one-dimensional array of characters terminated by a null character", so you could say that NULL is very similar to an empty string - maybe that helps address the "pretend its a string" objection? Craig

« previous php.internals (#116991) next »