Re: RFC: blank() Function as a Complement to empty()
| From: | Hans Henrik Bergan | Date: | Mon, 07 Apr 2025 08:01:30 +0000 |
| Subject: | Re: RFC: blank() Function as a Complement to empty() | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-127067@lists.php.net to get a copy of this message | ||
>If this can still be implemented in userland you don't need logic integrated at low level
Afaik it cannot be implemented in userland today.
The closest you can get today is to use reference hacks, which
introduce side-effects, like if you do
function blank(&$value){...}
blank($_POST['foo'])
and foo doesn't exist, the & ref will *create* foo with null, like
var_dump($_POST); // array(0) {}
blank($_POST['foo']);
var_dump($_POST); // array(1) {["foo"]=>NULL}
But maybe we could make it possible like
function blank(#[\AllowUndeclared] $value){...}
var_dump($_POST); // array(0) {}
blank($_POST['foo']);
var_dump($_POST); // array(0) {}