# RFC: Fix list() behavior inconsistency

- Status: Implemented (PHP 7.0)
- Authors: Dmitry Stogov, dmitry@zend.com
- Date: 2014-09-11
- Version: 1.0
- Original: https://wiki.php.net/rfc/fix_list_behavior_inconsistency
- Page: https://externals.io/rfc/fix_list_behavior_inconsistency
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

## Votes

### Fix list() behavior inconsistency? (closed)

don't fix: 0 · disable string handling in all cases: 17 · enable string handling in all cases: 16

Voters: ab (enable string handling in all cases), aharvey (enable string handling in all cases), ajf (disable string handling in all cases), auroraeosrose (enable string handling in all cases), bukka (enable string handling in all cases), bwoebi (enable string handling in all cases), datibbaw (disable string handling in all cases), daverandom (enable string handling in all cases), derick (enable string handling in all cases), dmitry (enable string handling in all cases), fmk (enable string handling in all cases), gwynne (disable string handling in all cases), hywan (disable string handling in all cases), jedibc (disable string handling in all cases), kalle (disable string handling in all cases), kassner (disable string handling in all cases), keyur (disable string handling in all cases), klaussilveira (disable string handling in all cases), krakjoe (enable string handling in all cases), laruence (enable string handling in all cases), leigh (disable string handling in all cases), levim (enable string handling in all cases), lstrojny (disable string handling in all cases), mbeccati (disable string handling in all cases), mike (disable string handling in all cases), nikic (enable string handling in all cases), pajoye (disable string handling in all cases), patrickallaert (disable string handling in all cases), pierrick (enable string handling in all cases), rasmus (disable string handling in all cases), rdlowrey (enable string handling in all cases), remi (disable string handling in all cases), stas (enable string handling in all cases)

## Discussions on the mailing list

- [\[RFC\] Fix list() behavior inconsistency](https://externals.io/message/77150.md) — started on 2014-09-11, 6 messages
- [\[VOTE\] Fix list() behavior inconsistency](https://externals.io/message/77610.md) — started on 2014-09-25, 37 messages

---

## Introduction

According to [PHP documentation](http://php.net/manual/en/function.list.php) 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.

## Proposal

Make list() behave with strings in consistent way. There are two options:

### Disable string handling in all cases

This will disable undocumented feature and it may break some existing PHP code.

### Enable string handling in all cases

This 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 Changes

Both options may affect existing PHP code.

## Proposed PHP Version(s)

PHP7

## Vote

This project requires a 2/3 majority, between first and second or third options.

Voting started on 2014-09-25 and ends 2014-10-02.

**Vote: Fix list() behavior inconsistency?** — don't fix: 0 · disable string handling in all cases: 17 · enable string handling in all cases: 16 (closed)

## Implementation

Support for strings has been removed for all cases. Support for `ArrayAccess` has been added for all cases (previously it was not supported for temporary variables).

<https://github.com/php/php-src/commit/7c7b9184b1fdf7add1715079f22241bc1185fcb0>
