File tree Expand file tree Collapse file tree 3 files changed +7
-8
lines changed Expand file tree Collapse file tree 3 files changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -8578,7 +8578,9 @@ static zend_op_array *zend_compile_func_decl_ex(
85788578 op_array -> fn_flags |= ZEND_ACC_PRELOADED ;
85798579 }
85808580
8581- if (CG (file_context ).current_namespace ) {
8581+ /* Only set namespace_name for standalone functions, not for methods.
8582+ * Methods get their namespace from the class name at runtime via zend_get_caller_namespace(). */
8583+ if (CG (file_context ).current_namespace && !CG (active_class_entry )) {
85828584 op_array -> namespace_name = zend_string_copy (CG (file_context ).current_namespace );
85838585 }
85848586
Original file line number Diff line number Diff line change @@ -609,10 +609,6 @@ static zend_op_array *zend_compile(int type)
609609 init_op_array (op_array, type, INITIAL_OP_ARRAY_SIZE);
610610 CG (active_op_array) = op_array;
611611
612- if (CG (file_context).current_namespace ) {
613- op_array->namespace_name = zend_string_copy (CG (file_context).current_namespace );
614- }
615-
616612 /* Use heap to not waste arena memory */
617613 op_array->fn_flags |= ZEND_ACC_HEAP_RT_CACHE;
618614
Original file line number Diff line number Diff line change @@ -567,6 +567,10 @@ ZEND_API void destroy_op_array(zend_op_array *op_array)
567567 zend_string_release_ex (op_array -> function_name , 0 );
568568 }
569569
570+ if (op_array -> namespace_name ) {
571+ zend_string_release_ex (op_array -> namespace_name , 0 );
572+ }
573+
570574 if (!op_array -> refcount || -- (* op_array -> refcount ) > 0 ) {
571575 return ;
572576 }
@@ -612,9 +616,6 @@ ZEND_API void destroy_op_array(zend_op_array *op_array)
612616 if (op_array -> doc_comment ) {
613617 zend_string_release_ex (op_array -> doc_comment , 0 );
614618 }
615- if (op_array -> namespace_name ) {
616- zend_string_release_ex (op_array -> namespace_name , 0 );
617- }
618619 if (op_array -> attributes ) {
619620 zend_hash_release (op_array -> attributes );
620621 }
You can’t perform that action at this time.
0 commit comments