Bug #67908 [Opn->Nab]: list($a, $b) = $a broken.
Edit report at https://bugs.php.net/bug.php?id=67908&edit=1
ID: 67908
Updated by: requinix@php.net
Reported by: arjen at react dot com
Summary: list($a, $b) = $a broken.
-Status: Open
+Status: Not a bug
Type: Bug
Package: Scripting Engine problem
PHP Version: master-Git-2014-08-26 (Git)
Block user comment: N
Private report: N
New Comment:
That is exactly it except the change is desired; AST makes list() assign left to right instead of
the current behavior of right to left. Which, if I may say so, makes much more sense and removes one
of the oddest quirks in PHP.
https://wiki.php.net/rfc/abstract_syntax_tree#changes_to_list
Besides, the documentation specifically warns about that kind of structure resulting in undefined
behavior.
http://php.net/manual/en/function.list.php#refsect1-function.list-notes
If you haven't seen it already, you may be interested in reading the thread about AST on the
internals mailing list. The change to list() was (briefly) mentioned.
http://php.markmail.org/thread/br4ixewsnqitrx3n
Previous Comments:
------------------------------------------------------------------------
[2014-08-26 12:23:35] arjen at react dot com
Description:
------------
Probably in AST refactor.
Test script:
---------------
$a = array('a', 'b');
list($a, $b) = $a;
var_dump($a, $b);
Expected result:
----------------
string(1) "a"
string(1) "b"
Actual result:
--------------
string(1) "a"
string(0) ""
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=67908&edit=1
Thread (3 messages)