Req #80222 [NEW]: Operator for !empty() - analog of `??`

From: Date: Mon, 12 Oct 2020 11:06:26 +0000
Subject: Req #80222 [NEW]: Operator for !empty() - analog of `??`
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-229558@lists.php.net to get a copy of this message
From: somerussian at ya dot ru Operating system: PHP version: Next Minor Version Package: *General Issues Bug Type: Feature/Change Request Bug description:Operator for !empty() - analog of ?? Description: ------------ There is already a Null Coalescing Operator (kind of a shortcut for isset()), which is very handy, because it allows write less and do more. So 2 lines in the example below would do the same: <?php $name = isset($data['name']) ? $data['name'] : 'noname'; $name = $data['name'] ?? 'noname'; ?> But it's also would be great to have similar operator for !empty(), e.g: <?php $name = !empty($data['name']) ? $data['name'] : 'noname'; $name = $data['name'] ??? 'noname'; ?> Not sure about the symbols for that new operator: ??? ?! !e (?) any other I miss this feature very much, and I guess lot's of people can't wait for it too. Is there a chance that we would have Empty Coalescing Operator in the next version of PHP? -- Edit bug report at https://bugs.php.net/bug.php?id=80222&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=80222&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=80222&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=80222&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=80222&r=needscript Try newer version: https://bugs.php.net/fix.php?id=80222&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=80222&r=support Expected behavior: https://bugs.php.net/fix.php?id=80222&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=80222&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=80222&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=80222&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=80222&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=80222&r=dst IIS Stability: https://bugs.php.net/fix.php?id=80222&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=80222&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=80222&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=80222&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=80222&r=mysqlcfg

« previous php.bugs (#229558) next »