Introduction

PHP has had list() assignment and reference assignment for a long time. However, it is not currently possible to use reference assignment with list(). This RFC proposes this new syntax to cover this. The original requests for this feature date back at least 16 years now [1][2]. We will be focusing on the formers syntax proposal for this RFC.

(notice here that the reference exists on $array[1][0] since $a is still in scope after the foreach())

The predominant advantage of adding support for this is that it allows you to use reference assignment for multiple variables at once, which is not currently possible. The syntax here is different from the traditional assignment syntax which places the & before the right-side value, not the left-side value; the advantage here is that you can reference assign some, but not all of the variables in list().

The RFC also takes into account the possibility of objects being the r-val of the assignment implementing ArrayAccess.