Bug #78387 [NEW]: references won't work for coalesce result
| From: | mpatnode at popsugar dot com | Date: | Thu, 08 Aug 2019 21:17:16 +0000 |
| Subject: | Bug #78387 [NEW]: references won't work for coalesce result | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-222144@lists.php.net to get a copy of this message | ||
From: mpatnode at popsugar dot com
Operating system: any
PHP version: 7.4.0beta2
Package: Arrays related
Bug Type: Bug
Bug description:references won't work for coalesce result
Description:
------------
Not sure if this is a bug, but the behavior is unexpected. If a
coalesce result is used in a foreach with a reference, the reference is
ignored.
If it's not legal syntax, then the reference should generate a warning
or notice.
Behaved the same on every PHP version I tested.
Test script:
---------------
$foo = ['bar1' => 1, 'bar2' => 2];
foreach ($foo ?? [] as &$bar) { $bar = 3; }
var_dump($foo)
Expected result:
----------------
array(2) {
'bar1' =>
int(3)
'bar2' =>
int(3)
}
Actual result:
--------------
array(2) {
'bar1' =>
int(1)
'bar2' =>
int(2)
}
--
Edit bug report at https://bugs.php.net/bug.php?id=78387&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=78387&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=78387&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=78387&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=78387&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=78387&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=78387&r=support
Expected behavior: https://bugs.php.net/fix.php?id=78387&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=78387&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=78387&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=78387&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=78387&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=78387&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=78387&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=78387&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=78387&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=78387&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=78387&r=mysqlcfg