@@ -36,6 +36,7 @@ static YYSIZE_T zend_yytnamerr(char*, const char*);
3636#define YYMALLOC malloc
3737#define YYFREE free
3838#endif
39+ void * temp;
3940}
4041
4142%code requires {
@@ -252,7 +253,7 @@ static YYSIZE_T zend_yytnamerr(char*, const char*);
252253%token T_ERROR
253254
254255%type <ast> top_statement namespace_name name statement function_declaration_statement
255- %type <ast> class_declaration_statement class_body_statement class_short_ctor trait_declaration_statement legacy_namespace_name
256+ %type <ast> class_declaration_statement class_body_statement parent_ctr_call class_short_ctor trait_declaration_statement legacy_namespace_name
256257%type <ast> interface_declaration_statement interface_extends_list
257258%type <ast> group_use_declaration inline_use_declarations inline_use_declaration
258259%type <ast> mixed_group_use_declaration use_declaration unprefixed_use_declaration
@@ -605,21 +606,37 @@ class_declaration_statement:
605606 class_modifiers_optional T_CLASS { $<num>$ = CG(zend_lineno); } T_STRING
606607 class_short_ctor
607608 extends_from implements_list backup_doc_comment class_body_statement
608- {
609- zend_ast* stmts = zend_ast_create_list(0 , ZEND_AST_STMT_LIST, $5 , $9 );
609+ {
610+ zend_ast_decl *ctor = $5 ;
611+ if (ctor && ctor->child[2 ] && temp) {
612+ ctor->child[2 ] = zend_ast_list_add(ctor->child[2 ], temp);
613+ }
614+ zend_ast* stmts = zend_ast_create_list(2 , ZEND_AST_STMT_LIST, $5 , $9 );
610615 $$ = zend_ast_create_decl(ZEND_AST_CLASS, $1 , $<num>3 , $8 , zend_ast_get_str($4 ), $6 , $7 , stmts, NULL , NULL ); }
611616;
612617
613618class_short_ctor :
614619 ' (' parameter_list ' )'
615620 { $$ = zend_ast_create_decl(ZEND_AST_METHOD, ZEND_ACC_PUBLIC, CG(zend_lineno), NULL ,
616- ZSTR_KNOWN (ZEND_STR_CTOR), $2, NULL, zend_ast_create_list(0 , ZEND_AST_STMT_LIST), NULL, NULL);; }
621+ ZSTR_KNOWN (ZEND_STR_CTOR), $2, NULL, zend_ast_create_list(0 , ZEND_AST_STMT_LIST), NULL, NULL); }
617622 | %empty { $$ = NULL ; }
618623;
619624
620625class_body_statement :
621626 ' {' class_statement_list ' }' { $$ = $2 ; }
622627 | ' ;' { $$ = NULL ; }
628+ ;
629+
630+ parent_ctr_call :
631+ argument_list
632+ {
633+ zval zv; ZVAL_INTERNED_STR(&zv, ZSTR_KNOWN(ZEND_STR_PARENT));
634+ $$ = zend_ast_create(ZEND_AST_STATIC_CALL,
635+ zend_ast_create_zval_ex (&zv, ZEND_NAME_NOT_FQ),
636+ zend_ast_create_zval_from_str(ZSTR_KNOWN(ZEND_STR_CTOR)),
637+ $1); }
638+ | %empty { $$ = NULL ; }
639+ ;
623640
624641class_modifiers_optional :
625642 %empty { $$ = 0 ; }
@@ -685,7 +702,7 @@ enum_case_expr:
685702
686703extends_from :
687704 %empty { $$ = NULL ; }
688- | T_EXTENDS class_name { $$ = $2 ; }
705+ | T_EXTENDS class_name parent_ctr_call { $$ = $2 ; temp = $3 ; }
689706;
690707
691708interface_extends_list :
0 commit comments