Consider a different class for destructured array?
Would it be feasible to create a separate class for array destructuring? Like AssignmentArray_ or ListArray_.
Using a single class to represent two totally different scenarios (even though the syntax is very similar) is a bit of a challenge for static analysis.
Do you have a use case where this is important?
Oh, just the inconsistency that Array_ on the LHS of an assignment may have items that are null (like List_), but an Array_ on the RHS of an assignment is guaranteed to never have null items.
Could you share PHP code? It's easier to spot and test
@TomasVotruba
[$a, $b,,, $c] = [1, 2, 3, 4, 5];
I think the suggestion makes sense in general, but I'm going to punt on this for 4.0. I don't want to change types at this point.
Makes sense – I'm about 12 months late with this
Is this still relevant?
Yes
How should the nodes look like for?
[$a, $b,,, $c] = [1, 2, 3, 4, 5];
What do you think about using Expr\List_ for both list($x, $y) = $z and [$x, $y] = $z, together with an attribute that determines the actual style used (like kind on Expr\Array_)? That seems convenient in that you generally want to treat list() = and [] = the same, and it avoids an additional node type.
That would be really nice!