xp-framework / compiler

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

Allow `new (<expr>)` as syntax #80

Closed thekid closed 4 years ago

thekid commented 4 years ago

See php/php-src#5061, merged Feb. 11th, 2020 and targeted for PHP 8.0

function factory() { return Date::class; }

$date= new (factory())();  // instance of Date class

Previously, a temporary variable would have been necessary:

function factory() { return Date::class; }

$class= factory();
$date= new $class();  // instance of Date class