Skip to content

Instantly share code, notes, and snippets.

@nikic nikic/derefable_new.diff Secret
Last active Sep 25, 2015

Embed
What would you like to do?
diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y
index c52c252..6c5be4c 100644
--- a/Zend/zend_language_parser.y
+++ b/Zend/zend_language_parser.y
@@ -251,7 +251,7 @@ static YYSIZE_T zend_yytnamerr(char*, const char*);
%type <ast> ctor_arguments alt_if_stmt_without_else trait_adaptation_list lexical_vars
%type <ast> lexical_var_list encaps_list array_pair_list non_empty_array_pair_list
%type <ast> assignment_list isset_variable type return_type
-%type <ast> identifier
+%type <ast> identifier dereferencable_new_expr
%type <num> returns_ref function is_reference is_variadic variable_modifiers
%type <num> method_modifiers non_empty_member_modifiers member_modifier
@@ -845,10 +845,16 @@ anonymous_class:
;
new_expr:
- T_NEW class_name_reference ctor_arguments
- { $$ = zend_ast_create(ZEND_AST_NEW, $2, $3); }
+ T_NEW class_name_reference
+ { $$ = zend_ast_create(ZEND_AST_NEW, $2, zend_ast_create_list(0, ZEND_AST_ARG_LIST)); }
| T_NEW anonymous_class
{ $$ = $2; }
+ | dereferencable_new_expr { $$ = $1; }
+;
+
+dereferencable_new_expr:
+ T_NEW class_name_reference argument_list
+ { $$ = zend_ast_create(ZEND_AST_NEW, $2, $3); }
;
expr_without_variable:
@@ -1097,6 +1103,7 @@ dereferencable:
variable { $$ = $1; }
| '(' expr ')' { $$ = $2; }
| dereferencable_scalar { $$ = $1; }
+ | dereferencable_new_expr { $$ = $1; }
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.