1--TEST-- 2list() can be used to destructure to string offsets, __set and ArrayAccess::offsetSet 3--FILE-- 4<?php 5 6class Obj { 7 public $values = []; 8 public function __set($name, $value) { 9 $this->values[$name] = $value; 10 } 11} 12 13class Arr implements ArrayAccess { 14 public $values = []; 15 public function offsetSet($name, $value) { 16 $this->values[$name] = $value; 17 } 18 public function offsetGet($name) {} 19 public function offsetExists($name) {} 20 public function offsetUnset($name) {} 21} 22 23$str = 'ab'; 24list($str[0], $str[1]) = ['x', 'y']; 25var_dump($str); 26 27$obj = new Obj; 28list($obj->foo, $obj->bar) = ['foo', 'bar']; 29var_dump($obj->values); 30 31$arr = new Arr; 32list($arr['foo'], $arr['bar']) = ['foo', 'bar']; 33var_dump($arr->values); 34 35?> 36--EXPECT-- 37string(2) "xy" 38array(2) { 39 ["foo"]=> 40 string(3) "foo" 41 ["bar"]=> 42 string(3) "bar" 43} 44array(2) { 45 ["foo"]=> 46 string(3) "foo" 47 ["bar"]=> 48 string(3) "bar" 49} 50