Bug #67908 [Nab]: list($a, $b) = $a broken.

From: Date: Tue, 26 Aug 2014 20:04:38 +0000
Subject: Bug #67908 [Nab]: list($a, $b) = $a broken.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-187285@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67908&edit=1 ID: 67908 User updated by: arjen at react dot com Reported by: arjen at react dot com Summary: list($a, $b) = $a broken. 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: 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! Previous Comments: ------------------------------------------------------------------------ [2014-08-26 18:07:09] requinix@php.net 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 ------------------------------------------------------------------------ [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

« previous php.bugs (#187285) next »