|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67908 list($a, $b) = $a broken.
Submitted: 2014-08-26 12:23 UTC Modified: 2014-08-26 20:04 UTC
From: arjen at react dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: master-Git-2014-08-26 (Git) OS:
Private report: No CVE-ID: None
 [2014-08-26 12:23 UTC] arjen at react dot com
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) ""


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-08-26 18:07 UTC]
-Status: Open +Status: Not a bug
 [2014-08-26 18:07 UTC]
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.

Besides, the documentation specifically warns about that kind of structure resulting in undefined behavior.

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.
 [2014-08-26 20:04 UTC] arjen at react dot com
I see now.

I followed the RFC, but this specific case was mentioned and added to the RFC changes list  while I was on holidays. So I missed it, sorry!
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun May 26 03:01:26 2019 UTC