diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-01-06 16:22:17 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-02-11 12:33:23 +0100 |
commit | c141ee3f9c31276264dba886a880e6160b8cb4ea (patch) | |
tree | 93a75258445bfcda56ffacfdb6c024c757fcf4c4 | |
parent | 357fbc99028e6a9934740161a0f23a66ddaee3b4 (diff) | |
download | php-git-c141ee3f9c31276264dba886a880e6160b8cb4ea.tar.gz |
Allow arbitrary expressions in new/instanceof using () syntax
-rw-r--r-- | Zend/tests/varSyntax/new_instanceof_expr.phpt | 18 | ||||
-rw-r--r-- | Zend/zend_language_parser.y | 1 |
2 files changed, 19 insertions, 0 deletions
diff --git a/Zend/tests/varSyntax/new_instanceof_expr.phpt b/Zend/tests/varSyntax/new_instanceof_expr.phpt new file mode 100644 index 0000000000..475f7a9dae --- /dev/null +++ b/Zend/tests/varSyntax/new_instanceof_expr.phpt @@ -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) diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y index af8b67af5c..02dbd091dc 100644 --- a/Zend/zend_language_parser.y +++ b/Zend/zend_language_parser.y @@ -1078,6 +1078,7 @@ class_name: class_name_reference: class_name { $$ = $1; } | new_variable { $$ = $1; } + | '(' expr ')' { $$ = $2; } ; exit_expr: |