|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2020-06-03 09:20 UTC] valentiny510 at gmail dot com
Description: ------------ The coalescing operator is one of the best life (or write) savers, and still in some situations became a bit redundant, assuming $b is not set... $a = $b ?? null; meaning "if is null, null, else null" And we have to do this only to avoid the errors flooding the log... (yes, I know we can disable it with error_reporting, but that will also disable other errors that we may want to see) Another good thing is the nullable type, but sadly it only apply to... types So, my request is to extend the "nullable" to other... things, like variables for instance, and I think will be a great life saver Ex: $a = ?$b; Seeing the above assignment, probably will be better to create a new operator, =? Meaning of course, assign the right side if isset, otherwise null Thank you PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 15:00:02 2025 UTC |
I just checked and realized that the SDTERR handler doesn't have if (!($code & error_reporting( ))) return; # Error silenced "@" Sorry, mea culpa... for the $a = @$b; example (third party software...) but still feels like I'm cheating somehow, because you know that the error happend, the parser triggered the error, but you just choose to silence it like you can silence many other errors, is not exactly the same as coalescing and I maintain the position with other symbols/operators