I try to follow the procedure of: https://wiki.php.net/rfc/howto
Then I suggest you take a moment to think about what you're proposing to change, and write it out clearly, as in "I propose to make this code ... do this ... instead of this ..." At the moment, your messages contain a lot of open-ended questions, and examples that you can easily look up the current behaviour of yourself.
Keep in mind that there are millions of existing PHP applications which might be impacted by your change. In general, changing something which is currently an error is not a problem; but if the code currently succeeds, there is a chance that somebody somewhere is using it. You need to think about how the change will affect that existing code.
It seems to me that list() is not clearly specified.
Do you mean that the documentation of the feature is not clear? Or, that there are cases where it's behaviour is inconsistent in some way?
list() supports destructuring assignment for arrays. Do you have an opinion
on object destructuring ?
It might be interesting to allow an object on the right-hand side, and somehow specify properties to extract from it. I would be less interested in having an object on the left-hand side, which would presumably create an instance of stdClass, which I find pointless. Others might disagree.
Do you think seeing list() as the reciprocal of a function call is
interesting ?
As I said previously, I would now always spell both array creation and array destructuring with [] not with array() and list(). Neither have ever behaved like function calls, and I don't think thinking of them that way is helpful.
Instead, think of it as a way of specifying the content of an array, just like "hello $name" specifies the content of a string. Then think of array destructuring as the reverse of that construction:
$arr = [$a, $b];
[$a, $b] = $arr;
$arr = ['a' => $a, 'b' => $b];
['a' => $a, 'b' => $b] = $arr;
$arr = [1 => $b, 0 => $a];
[0 => $a, 1 => $b] = $arr;
$arr = [$a, $b]; // keys 0 and 1 assigned by default
[1 => $b, 0 => $a] = $arr;
$arr = [1 => $b, 0 => $a];
[$a, $b] = $arr; // keys 0 and 1 taken by default
$arr = ['a' => 1, $dynamicKey => 2];
[$dynamicKey => $two, 'a' => $one] = $arr;
Otherwise, how to use a default value, type hinting, nullable/optional
variable... It's not interesting ?
Some of those could be useful in both array creation and array destructuring, but it's not as simple as copying the syntax of a function signature. Again, I suggest you write down a specific feature you are proposing to add, and think about how it would work.
There are many things that could be done with but don't work. For example :
$array = [1, 2, 3];
[...$values] = [...$array];
I can see this would be useful as a "rest of the values" syntax, as in:
$arr = [1,2,3,4,5];
[$first, $second, ...$rest] = $arr;
It couldn't work as the exact inverse of construction, though; this is allowed:
$arr1 = [1, 2, 3];
$arr2 = [...$arr1, ...$arr1];
But this wouldn't make any sense:
$arr2 = [1, 2, 3, 1, 2, 3];
[...$arr1, ...$arr1] = $arr2;
Once again, a proposal of exactly how it would work would be interesting.
Regards,
--
Rowan Tommins
[IMSoP]