|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2019-08-08 21:48 UTC] requinix@php.net
-Status: Open
+Status: Not a bug
-Package: Arrays related
+Package: Scripting Engine problem
[2019-08-08 21:48 UTC] requinix@php.net
[2019-08-08 22:22 UTC] mpatnode at popsugar dot com
[2019-08-08 22:30 UTC] requinix@php.net
[2019-08-09 07:57 UTC] nikic@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Mon Jan 05 01:00:01 2026 UTC |
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) }