mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Allow arbitrary expressions in new/instanceof using () syntax
This commit is contained in:
parent
357fbc9902
commit
c141ee3f9c
2 changed files with 19 additions and 0 deletions
18
Zend/tests/varSyntax/new_instanceof_expr.phpt
Normal file
18
Zend/tests/varSyntax/new_instanceof_expr.phpt
Normal 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)
|
|
@ -1078,6 +1078,7 @@ class_name:
|
|||
class_name_reference:
|
||||
class_name { $$ = $1; }
|
||||
| new_variable { $$ = $1; }
|
||||
| '(' expr ')' { $$ = $2; }
|
||||
;
|
||||
|
||||
exit_expr:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue