xp-framework / compiler

Compiles future PHP to today's PHP.
19 stars 0 forks source link

Rewrite `list(&$a)= $expr` for PHP 7.0, 7.1 and 7.2 #144

Closed thekid closed 1 year ago

thekid commented 1 year ago

Implements #31 (w/o the foreach part). Previously, these statements would produce a parse error syntax error, unexpected '&', expecting ',' or ')'.

Works as follows:

// Input, either as list() or using the following shorthand form
[&$a, &$b]= $expr;

// Emitted code for PHP 7.3+
list(&$a, &$b)= $expr;

// Emitted code for PHP 7.0, 7.1 and 7.2
null === ($__t= &$expr) ? null : [$a= &$__t[0], $b= &$__t[1]];
thekid commented 1 year ago

Released in https://github.com/xp-framework/compiler/releases/tag/v8.7.0