[RFC] Short list syntax #1849
| @@ -5,6 +5,8 @@ | ||
| list($a, list($b)) = array(new stdclass, array(new stdclass)); | ||
| var_dump($a, $b); | ||
| +[$a, [$b]] = array(new stdclass, array(new stdclass)); | ||
| +var_dump($a, $b); |
|
I've not added many [] tests, it's using the exactly same syntax (array_pair_list) in parser and the differences are abstracted away inside AST. You've added eight or so new error conditions and only one of them is currently covered. I'm asking about Oh, yeah,
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
|
Just wondering, have you thought of this weird edge case?
$a = "a";
$b = "b";
[$foo, $bar] = [$baz, $bat] = [$a, $b];It's pretty ambigious - kind of hard to even assess what that means or what that would do.
I don't know if there's a real use case where this would ever matter - I just thought of it so figured I'd bring it up in case there's a missing edge test-case or something.
Behaves the same as with list($foo, $bar) = list($baz, $bat) = [$a, $b];
Well, good, but a test-case to prove that fact probably wouldn't hurt? :-)
See: https://wiki.php.net/rfc/short_list_syntax