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