@@ -2287,7 +2287,7 @@ static inline zend_bool zend_is_unticked_stmt(zend_ast *ast) /* {{{ */
22872287{
22882288 return ast -> kind == ZEND_AST_STMT_LIST || ast -> kind == ZEND_AST_LABEL
22892289 || ast -> kind == ZEND_AST_PROP_DECL || ast -> kind == ZEND_AST_CLASS_CONST_DECL
2290- || ast -> kind == ZEND_AST_USE_TRAIT || ast -> kind == ZEND_AST_METHOD ;
2290+ || ast -> kind == ZEND_AST_USE_TRAIT || ast -> kind == ZEND_AST_METHOD || ast -> kind == ZEND_AST_METHOD_EX ;
22912291}
22922292/* }}} */
22932293
@@ -5634,9 +5634,8 @@ void zend_compile_closure_uses(zend_ast *ast) /* {{{ */
56345634}
56355635/* }}} */
56365636
5637- void zend_begin_method_decl ( zend_op_array * op_array , zend_string * name , zend_bool has_body ) /* {{{ */
5637+ void zend_begin_method_decl_ex ( zend_class_entry * ce , zend_op_array * op_array , zend_string * name , zend_bool has_body ) /* {{{ */
56385638{
5639- zend_class_entry * ce = CG (active_class_entry );
56405639 zend_bool in_interface = (ce -> ce_flags & ZEND_ACC_INTERFACE ) != 0 ;
56415640 zend_bool in_trait = (ce -> ce_flags & ZEND_ACC_TRAIT ) != 0 ;
56425641 zend_bool is_public = (op_array -> fn_flags & ZEND_ACC_PUBLIC ) != 0 ;
@@ -5677,7 +5676,11 @@ void zend_begin_method_decl(zend_op_array *op_array, zend_string *name, zend_boo
56775676
56785677 if (zend_hash_add_ptr (& ce -> function_table , lcname , op_array ) == NULL ) {
56795678 zend_error_noreturn (E_COMPILE_ERROR , "Cannot redeclare %s::%s()" ,
5680- ZSTR_VAL (ce -> name ), ZSTR_VAL (name ));
5679+ ZSTR_VAL (ce -> name ), ZSTR_VAL (name ));
5680+ }
5681+
5682+ if (ce -> type == ZEND_INTERNAL_CLASS ) {
5683+ zend_hash_add_ptr (CG (class_extension_functions ), lcname , ce );
56815684 }
56825685
56835686 if (in_interface ) {
@@ -5810,6 +5813,20 @@ void zend_begin_method_decl(zend_op_array *op_array, zend_string *name, zend_boo
58105813}
58115814/* }}} */
58125815
5816+ void zend_begin_method_decl_ex2 (zend_string * class_name , zend_op_array * op_array , zend_string * name , zend_bool has_body ) /* {{{ */
5817+ {
5818+ zend_class_entry * ce = zend_lookup_class (class_name );
5819+ zend_begin_method_decl_ex (ce , op_array , name , has_body );
5820+ }
5821+ /* }}} */
5822+
5823+ void zend_begin_method_decl (zend_op_array * op_array , zend_string * name , zend_bool has_body ) /* {{{ */
5824+ {
5825+ zend_class_entry * ce = CG (active_class_entry );
5826+ zend_begin_method_decl_ex (ce , op_array , name , has_body );
5827+ }
5828+ /* }}} */
5829+
58135830static void zend_begin_func_decl (znode * result , zend_op_array * op_array , zend_ast_decl * decl , zend_bool toplevel ) /* {{{ */
58145831{
58155832 zend_ast * params_ast = decl -> child [0 ];
@@ -5876,10 +5893,17 @@ void zend_compile_func_decl(znode *result, zend_ast *ast, zend_bool toplevel) /*
58765893{
58775894 zend_ast_decl * decl = (zend_ast_decl * ) ast ;
58785895 zend_ast * params_ast = decl -> child [0 ];
5879- zend_ast * uses_ast = decl -> child [ 1 ] ;
5896+ zend_ast * uses_ast ;
58805897 zend_ast * stmt_ast = decl -> child [2 ];
58815898 zend_ast * return_type_ast = decl -> child [3 ];
58825899 zend_bool is_method = decl -> kind == ZEND_AST_METHOD ;
5900+ zend_bool is_ex_method = decl -> kind == ZEND_AST_METHOD_EX ;
5901+
5902+ if (is_ex_method ){
5903+ uses_ast = NULL ;
5904+ } else {
5905+ uses_ast = decl -> child [1 ];
5906+ }
58835907
58845908 zend_op_array * orig_op_array = CG (active_op_array );
58855909 zend_op_array * op_array = zend_arena_alloc (& CG (arena ), sizeof (zend_op_array ));
@@ -5901,6 +5925,10 @@ void zend_compile_func_decl(znode *result, zend_ast *ast, zend_bool toplevel) /*
59015925 if (is_method ) {
59025926 zend_bool has_body = stmt_ast != NULL ;
59035927 zend_begin_method_decl (op_array , decl -> name , has_body );
5928+ } else if (is_ex_method ){
5929+ zend_bool has_body = stmt_ast != NULL ;
5930+ zend_string * class_name = zend_ast_get_str (decl -> child [1 ]);
5931+ zend_begin_method_decl_ex2 (class_name , op_array , decl -> name , has_body );
59045932 } else {
59055933 zend_begin_func_decl (result , op_array , decl , toplevel );
59065934 if (uses_ast ) {
@@ -8122,6 +8150,7 @@ void zend_compile_stmt(zend_ast *ast) /* {{{ */
81228150 break ;
81238151 case ZEND_AST_FUNC_DECL :
81248152 case ZEND_AST_METHOD :
8153+ case ZEND_AST_METHOD_EX :
81258154 zend_compile_func_decl (NULL , ast , 0 );
81268155 break ;
81278156 case ZEND_AST_PROP_DECL :
0 commit comments