@@ -7271,7 +7271,7 @@ static uint32_t zend_add_dynamic_func_def(zend_op_array *def) {
7271
7271
return def_offset ;
7272
7272
}
7273
7273
7274
- static void zend_begin_func_decl (znode * result , zend_op_array * op_array , zend_ast_decl * decl , bool toplevel ) /* {{{ */
7274
+ static zend_string * zend_begin_func_decl (znode * result , zend_op_array * op_array , zend_ast_decl * decl , bool toplevel ) /* {{{ */
7275
7275
{
7276
7276
zend_string * unqualified_name , * name , * lcname ;
7277
7277
zend_op * opline ;
@@ -7305,23 +7305,20 @@ static void zend_begin_func_decl(znode *result, zend_op_array *op_array, zend_as
7305
7305
if (UNEXPECTED (zend_hash_add_ptr (CG (function_table ), lcname , op_array ) == NULL )) {
7306
7306
do_bind_function_error (lcname , op_array , 1 );
7307
7307
}
7308
- zend_observer_function_declared_notify (op_array , lcname );
7309
- zend_string_release_ex (lcname , 0 );
7310
- return ;
7311
- }
7312
-
7313
- uint32_t func_ref = zend_add_dynamic_func_def (op_array );
7314
- if (op_array -> fn_flags & ZEND_ACC_CLOSURE ) {
7315
- opline = zend_emit_op_tmp (result , ZEND_DECLARE_LAMBDA_FUNCTION , NULL , NULL );
7316
- opline -> op2 .num = func_ref ;
7317
7308
} else {
7318
- opline = get_next_op ();
7319
- opline -> opcode = ZEND_DECLARE_FUNCTION ;
7320
- opline -> op1_type = IS_CONST ;
7321
- LITERAL_STR (opline -> op1 , zend_string_copy (lcname ));
7322
- opline -> op2 .num = func_ref ;
7309
+ uint32_t func_ref = zend_add_dynamic_func_def (op_array );
7310
+ if (op_array -> fn_flags & ZEND_ACC_CLOSURE ) {
7311
+ opline = zend_emit_op_tmp (result , ZEND_DECLARE_LAMBDA_FUNCTION , NULL , NULL );
7312
+ opline -> op2 .num = func_ref ;
7313
+ } else {
7314
+ opline = get_next_op ();
7315
+ opline -> opcode = ZEND_DECLARE_FUNCTION ;
7316
+ opline -> op1_type = IS_CONST ;
7317
+ LITERAL_STR (opline -> op1 , zend_string_copy (lcname ));
7318
+ opline -> op2 .num = func_ref ;
7319
+ }
7323
7320
}
7324
- zend_string_release_ex ( lcname , 0 ) ;
7321
+ return lcname ;
7325
7322
}
7326
7323
/* }}} */
7327
7324
@@ -7333,7 +7330,7 @@ static void zend_compile_func_decl(znode *result, zend_ast *ast, bool toplevel)
7333
7330
zend_ast * stmt_ast = decl -> child [2 ];
7334
7331
zend_ast * return_type_ast = decl -> child [3 ];
7335
7332
bool is_method = decl -> kind == ZEND_AST_METHOD ;
7336
- zend_string * method_lcname = NULL ;
7333
+ zend_string * lcname = NULL ;
7337
7334
7338
7335
zend_class_entry * orig_class_entry = CG (active_class_entry );
7339
7336
zend_op_array * orig_op_array = CG (active_op_array );
@@ -7362,9 +7359,9 @@ static void zend_compile_func_decl(znode *result, zend_ast *ast, bool toplevel)
7362
7359
7363
7360
if (is_method ) {
7364
7361
bool has_body = stmt_ast != NULL ;
7365
- method_lcname = zend_begin_method_decl (op_array , decl -> name , has_body );
7362
+ lcname = zend_begin_method_decl (op_array , decl -> name , has_body );
7366
7363
} else {
7367
- zend_begin_func_decl (result , op_array , decl , toplevel );
7364
+ lcname = zend_begin_func_decl (result , op_array , decl , toplevel );
7368
7365
if (decl -> kind == ZEND_AST_ARROW_FUNC ) {
7369
7366
find_implicit_binds (& info , params_ast , stmt_ast );
7370
7367
compile_implicit_lexical_binds (& info , result , op_array );
@@ -7407,7 +7404,7 @@ static void zend_compile_func_decl(znode *result, zend_ast *ast, bool toplevel)
7407
7404
}
7408
7405
7409
7406
zend_compile_params (params_ast , return_type_ast ,
7410
- is_method && zend_string_equals_literal (method_lcname , ZEND_TOSTRING_FUNC_NAME ) ? IS_STRING : 0 );
7407
+ is_method && zend_string_equals_literal (lcname , ZEND_TOSTRING_FUNC_NAME ) ? IS_STRING : 0 );
7411
7408
if (CG (active_op_array )-> fn_flags & ZEND_ACC_GENERATOR ) {
7412
7409
zend_mark_function_as_generator ();
7413
7410
zend_emit_op (NULL , ZEND_GENERATOR_CREATE , NULL , NULL );
@@ -7436,8 +7433,7 @@ static void zend_compile_func_decl(znode *result, zend_ast *ast, bool toplevel)
7436
7433
if (is_method ) {
7437
7434
CG (zend_lineno ) = decl -> start_lineno ;
7438
7435
zend_check_magic_method_implementation (
7439
- CG (active_class_entry ), (zend_function * ) op_array , method_lcname , E_COMPILE_ERROR );
7440
- zend_string_release_ex (method_lcname , 0 );
7436
+ CG (active_class_entry ), (zend_function * ) op_array , lcname , E_COMPILE_ERROR );
7441
7437
}
7442
7438
7443
7439
/* put the implicit return on the really last line */
@@ -7452,6 +7448,12 @@ static void zend_compile_func_decl(znode *result, zend_ast *ast, bool toplevel)
7452
7448
/* Pop the loop variable stack separator */
7453
7449
zend_stack_del_top (& CG (loop_var_stack ));
7454
7450
7451
+ if (toplevel ) {
7452
+ zend_observer_function_declared_notify (op_array , lcname );
7453
+ }
7454
+
7455
+ zend_string_release_ex (lcname , 0 );
7456
+
7455
7457
CG (active_op_array ) = orig_op_array ;
7456
7458
CG (active_class_entry ) = orig_class_entry ;
7457
7459
}
0 commit comments