Allow arbitrary expressions in new/instanceof using () syntax

This commit is contained in:
Nikita Popov 2020-01-06 16:22:17 +01:00
parent 357fbc9902
commit c141ee3f9c
2 changed files with 19 additions and 0 deletions

View file

@ -0,0 +1,18 @@
--TEST--
new with an arbitrary expression
--FILE--
<?php
$class = 'class';
var_dump(new ('std'.$class));
var_dump(new ('std'.$class)());
$obj = new stdClass;
var_dump($obj instanceof ('std'.$class));
?>
--EXPECT--
object(stdClass)#1 (0) {
}
object(stdClass)#1 (0) {
}
bool(true)

View file

@ -1078,6 +1078,7 @@ class_name:
class_name_reference:
class_name { $$ = $1; }
| new_variable { $$ = $1; }
| '(' expr ')' { $$ = $2; }
;
exit_expr: