rfc:fix_list_behavior_inconsistency
PHP RFC: Fix list() behavior inconsistencyVersion: 1.0
Date: 2014-09-11
Author: Dmitry Stogov, dmitry@zend.com
Status: Implemented (in PHP 7)
According to PHP documentation list() construct doesn't work with strings. However in some cases it works.
$ php -r 'list($a,$b) = "aa";var_dump($a,$b);' NULL NULL $ php -r '$a[0]="ab"; list($a,$b) = $a[0]; var_dump($a,$b);' string(1) "a" string(1) "b"
This behavior caused by implementation feature and wasn't made on purpose.
ProposalMake list() behave with strings in consistent way. There are two options:
Disable string handling in all casesThis will disable undocumented feature and it may break some existing PHP code.
Enable string handling in all casesThis will make the following code work.
list($a,$b) = "str";
Instead of assignment NULL into $a and $b, it'll assign 's' and 't' characters. However, it also may break some existing PHP code.
Backward Incompatible ChangesBoth options may affect existing PHP code.
Proposed PHP Version(s)PHP7
VoteThis project requires a 2/3 majority, between first and second or third options.
Voting started on 2014-09-25 and ends 2014-10-02.
Implementationrfc/fix_list_behavior_inconsistency.txt ยท Last modified: 2025/04/03 13:08 by 127.0.0.1
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.3