Re: Allowing NULL for some internal functions
| From: | Christian Schneider | Date: | Thu, 02 Dec 2021 17:14:44 +0000 |
| Subject: | Re: Allowing NULL for some internal functions | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-116559@lists.php.net to get a copy of this message | ||
Am 02.12.2021 um 16:19 schrieb Sara Golemon <pollita@php.net>:
> I would say that such applications should consider unifying their own
> types. $a = $_GET['q'] ?? ''; Is there a place in the application where
> empty string and null would have been distinct? i.e. Is a search for
> nothing different from not searching?
Being able to detect if a parameter was present and empty or it it was not present at all can be
useful. That is the whole point of null, even though some people dislike null :-)
In fact we ran into the same problem and are silencing certain notices, warnings and deprecations
because they get in the way of our code base. (Side-note: We are patching it instead of suppressing
it in an error handler as we saw a noticeable performance difference.)
For the curious, here is our patch:
perl -0777 -i.bak -pe 's#zend_error.*E_(NOTICE|WARNING|DEPRECATED).*(\n.*)?(Undefined|Attempt
to read property|Uninitialized string offset|Trying to access array offset on value of type|Passing
null to parameter)#if (0) $&#g; s#zend_type_error.*must be of type Countable#if(0)
$&#g' Zend/*.[ch] ext/spl/*.[ch] ext/opcache/jit/*.[ch]
I am *not* advocating that other people should do this, I'm just corroborating ;-)
Regards,
- Chris