Skip to content

Commit 3b5cdcc

Browse files
author
rjhdby
committed
Revert "Class extension functions"
This reverts commit fa8f991.
1 parent fa8f991 commit 3b5cdcc

File tree

7 files changed

+6
-59
lines changed

7 files changed

+6
-59
lines changed

Zend/zend.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -637,9 +637,6 @@ static void compiler_globals_ctor(zend_compiler_globals *compiler_globals) /* {{
637637
compiler_globals->static_members_table = NULL;
638638
}
639639
compiler_globals->script_encoding_list = NULL;
640-
641-
compiler_globals->class_extension_functions = (HashTable *) malloc(sizeof(HashTable));
642-
zend_hash_init_ex(compiler_globals->class_extension_functions, 8, NULL, NULL, 1, 1);
643640
}
644641
/* }}} */
645642

@@ -664,8 +661,6 @@ static void compiler_globals_dtor(zend_compiler_globals *compiler_globals) /* {{
664661
pefree((char*)compiler_globals->script_encoding_list, 1);
665662
}
666663
compiler_globals->last_static_member = 0;
667-
668-
zend_hash_destroy(compiler_globals->class_extension_functions);
669664
}
670665
/* }}} */
671666

Zend/zend_ast.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,6 @@ static ZEND_COLD void zend_ast_export_stmt(smart_str *str, zend_ast *ast, int in
11171117
case ZEND_AST_FOREACH:
11181118
case ZEND_AST_FUNC_DECL:
11191119
case ZEND_AST_METHOD:
1120-
case ZEND_AST_METHOD_EX:
11211120
case ZEND_AST_CLASS:
11221121
case ZEND_AST_USE_TRAIT:
11231122
case ZEND_AST_NAMESPACE:
@@ -1316,7 +1315,6 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
13161315
case ZEND_AST_FUNC_DECL:
13171316
case ZEND_AST_CLOSURE:
13181317
case ZEND_AST_METHOD:
1319-
case ZEND_AST_METHOD_EX:
13201318
decl = (zend_ast_decl *) ast;
13211319
if (decl->flags & ZEND_ACC_PUBLIC) {
13221320
smart_str_appends(str, "public ");

Zend/zend_ast.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ enum _zend_ast_kind {
4141
ZEND_AST_FUNC_DECL,
4242
ZEND_AST_CLOSURE,
4343
ZEND_AST_METHOD,
44-
ZEND_AST_METHOD_EX,
4544
ZEND_AST_CLASS,
4645

4746
/* list nodes */

Zend/zend_compile.c

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -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 || ast->kind == ZEND_AST_METHOD_EX;
2290+
|| ast->kind == ZEND_AST_USE_TRAIT || ast->kind == ZEND_AST_METHOD;
22912291
}
22922292
/* }}} */
22932293

@@ -5634,8 +5634,9 @@ void zend_compile_closure_uses(zend_ast *ast) /* {{{ */
56345634
}
56355635
/* }}} */
56365636

5637-
void zend_begin_method_decl_ex(zend_class_entry *ce, zend_op_array *op_array, zend_string *name, zend_bool has_body) /* {{{ */
5637+
void zend_begin_method_decl(zend_op_array *op_array, zend_string *name, zend_bool has_body) /* {{{ */
56385638
{
5639+
zend_class_entry *ce = CG(active_class_entry);
56395640
zend_bool in_interface = (ce->ce_flags & ZEND_ACC_INTERFACE) != 0;
56405641
zend_bool in_trait = (ce->ce_flags & ZEND_ACC_TRAIT) != 0;
56415642
zend_bool is_public = (op_array->fn_flags & ZEND_ACC_PUBLIC) != 0;
@@ -5676,11 +5677,7 @@ void zend_begin_method_decl_ex(zend_class_entry *ce, zend_op_array *op_array, ze
56765677

56775678
if (zend_hash_add_ptr(&ce->function_table, lcname, op_array) == NULL) {
56785679
zend_error_noreturn(E_COMPILE_ERROR, "Cannot redeclare %s::%s()",
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);
5680+
ZSTR_VAL(ce->name), ZSTR_VAL(name));
56845681
}
56855682

56865683
if (in_interface) {
@@ -5813,20 +5810,6 @@ void zend_begin_method_decl_ex(zend_class_entry *ce, zend_op_array *op_array, ze
58135810
}
58145811
/* }}} */
58155812

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-
58305813
static void zend_begin_func_decl(znode *result, zend_op_array *op_array, zend_ast_decl *decl, zend_bool toplevel) /* {{{ */
58315814
{
58325815
zend_ast *params_ast = decl->child[0];
@@ -5893,17 +5876,10 @@ void zend_compile_func_decl(znode *result, zend_ast *ast, zend_bool toplevel) /*
58935876
{
58945877
zend_ast_decl *decl = (zend_ast_decl *) ast;
58955878
zend_ast *params_ast = decl->child[0];
5896-
zend_ast *uses_ast;
5879+
zend_ast *uses_ast = decl->child[1];
58975880
zend_ast *stmt_ast = decl->child[2];
58985881
zend_ast *return_type_ast = decl->child[3];
58995882
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-
}
59075883

59085884
zend_op_array *orig_op_array = CG(active_op_array);
59095885
zend_op_array *op_array = zend_arena_alloc(&CG(arena), sizeof(zend_op_array));
@@ -5925,10 +5901,6 @@ void zend_compile_func_decl(znode *result, zend_ast *ast, zend_bool toplevel) /*
59255901
if (is_method) {
59265902
zend_bool has_body = stmt_ast != NULL;
59275903
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);
59325904
} else {
59335905
zend_begin_func_decl(result, op_array, decl, toplevel);
59345906
if (uses_ast) {
@@ -8150,7 +8122,6 @@ void zend_compile_stmt(zend_ast *ast) /* {{{ */
81508122
break;
81518123
case ZEND_AST_FUNC_DECL:
81528124
case ZEND_AST_METHOD:
8153-
case ZEND_AST_METHOD_EX:
81548125
zend_compile_func_decl(NULL, ast, 0);
81558126
break;
81568127
case ZEND_AST_PROP_DECL:

Zend/zend_execute_API.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -275,13 +275,6 @@ void shutdown_executor(void) /* {{{ */
275275
zend_llist_apply(&zend_extensions, (llist_apply_func_t) zend_extension_deactivator);
276276
} zend_end_try();
277277

278-
zend_class_entry *temp_ce;
279-
280-
ZEND_HASH_FOREACH_STR_KEY_PTR(CG(class_extension_functions), key, temp_ce) {
281-
zend_hash_del(&temp_ce->function_table, key);
282-
zend_string_release_ex(key, 0);
283-
} ZEND_HASH_FOREACH_END();
284-
285278
if (fast_shutdown) {
286279
/* Fast Request Shutdown
287280
* =====================

Zend/zend_globals.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ struct _zend_compiler_globals {
125125
zval **static_members_table;
126126
int last_static_member;
127127
#endif
128-
HashTable * class_extension_functions;
129128
};
130129

131130

Zend/zend_language_parser.y

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ static YYSIZE_T zend_yytnamerr(char*, const char*);
224224
/* Token used to force a parse error from the lexer */
225225
%token T_ERROR
226226

227-
%type <ast> top_statement namespace_name name statement function_declaration_statement class_extension_function_declaration_statement
227+
%type <ast> top_statement namespace_name name statement function_declaration_statement
228228
%type <ast> class_declaration_statement trait_declaration_statement
229229
%type <ast> interface_declaration_statement interface_extends_list
230230
%type <ast> group_use_declaration inline_use_declarations inline_use_declaration
@@ -308,7 +308,6 @@ name:
308308
top_statement:
309309
statement { $$ = $1; }
310310
| function_declaration_statement { $$ = $1; }
311-
| class_extension_function_declaration_statement { $$ = $1; }
312311
| class_declaration_statement { $$ = $1; }
313312
| trait_declaration_statement { $$ = $1; }
314313
| interface_declaration_statement { $$ = $1; }
@@ -490,13 +489,6 @@ function_declaration_statement:
490489
zend_ast_get_str($3), $6, NULL, $11, $8); CG(extra_fn_flags) = $9; }
491490
;
492491

493-
class_extension_function_declaration_statement:
494-
function returns_ref namespace_name T_OBJECT_OPERATOR T_STRING backup_doc_comment '(' parameter_list ')'
495-
return_type backup_fn_flags method_body backup_fn_flags
496-
{ $$ = zend_ast_create_decl(ZEND_AST_METHOD_EX, $2 | ZEND_ACC_PUBLIC | $13, $1, $6,
497-
zend_ast_get_str($5), $8, $3, $12, $10); CG(extra_fn_flags) = $11; }
498-
;
499-
500492
is_reference:
501493
/* empty */ { $$ = 0; }
502494
| '&' { $$ = ZEND_PARAM_REF; }

0 commit comments

Comments
 (0)