@@ -3855,30 +3855,37 @@ static zend_never_inline zend_execute_data *zend_init_dynamic_call_string(zend_s
38553855 }
38563856
38573857 return zend_vm_stack_push_call_frame (ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_DYNAMIC ,
3858- fbc , num_args , called_scope , NULL );
3858+ fbc , num_args , called_scope );
38593859}
38603860/* }}} */
38613861
38623862static zend_never_inline zend_execute_data * zend_init_dynamic_call_object (zval * function , uint32_t num_args ) /* {{{ */
38633863{
38643864 zend_function * fbc ;
3865+ void * object_or_called_scope ;
38653866 zend_class_entry * called_scope ;
38663867 zend_object * object ;
38673868 uint32_t call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_DYNAMIC ;
38683869
38693870 if (EXPECTED (Z_OBJ_HANDLER_P (function , get_closure )) &&
38703871 EXPECTED (Z_OBJ_HANDLER_P (function , get_closure )(function , & called_scope , & fbc , & object ) == SUCCESS )) {
38713872
3873+ object_or_called_scope = called_scope ;
38723874 if (fbc -> common .fn_flags & ZEND_ACC_CLOSURE ) {
38733875 /* Delay closure destruction until its invocation */
38743876 GC_ADDREF (ZEND_CLOSURE_OBJECT (fbc ));
38753877 call_info |= ZEND_CALL_CLOSURE ;
38763878 if (fbc -> common .fn_flags & ZEND_ACC_FAKE_CLOSURE ) {
38773879 call_info |= ZEND_CALL_FAKE_CLOSURE ;
38783880 }
3881+ if (object ) {
3882+ call_info |= ZEND_CALL_HAS_THIS ;
3883+ object_or_called_scope = object ;
3884+ }
38793885 } else if (object ) {
3880- call_info |= ZEND_CALL_RELEASE_THIS ;
3886+ call_info |= ZEND_CALL_RELEASE_THIS | ZEND_CALL_HAS_THIS ;
38813887 GC_ADDREF (object ); /* For $this pointer */
3888+ object_or_called_scope = object ;
38823889 }
38833890 } else {
38843891 zend_throw_error (NULL , "Function name must be a string" );
@@ -3890,15 +3897,14 @@ static zend_never_inline zend_execute_data *zend_init_dynamic_call_object(zval *
38903897 }
38913898
38923899 return zend_vm_stack_push_call_frame (call_info ,
3893- fbc , num_args , called_scope , object );
3900+ fbc , num_args , object_or_called_scope );
38943901}
38953902/* }}} */
38963903
38973904static zend_never_inline zend_execute_data * zend_init_dynamic_call_array (zend_array * function , uint32_t num_args ) /* {{{ */
38983905{
38993906 zend_function * fbc ;
3900- zend_class_entry * called_scope ;
3901- zend_object * object ;
3907+ void * object_or_called_scope ;
39023908 uint32_t call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_DYNAMIC ;
39033909
39043910 if (zend_hash_num_elements (function ) == 2 ) {
@@ -3925,8 +3931,8 @@ static zend_never_inline zend_execute_data *zend_init_dynamic_call_array(zend_ar
39253931 }
39263932
39273933 if (Z_TYPE_P (obj ) == IS_STRING ) {
3928- object = NULL ;
3929- called_scope = zend_fetch_class_by_name ( Z_STR_P ( obj ), NULL , ZEND_FETCH_CLASS_DEFAULT | ZEND_FETCH_CLASS_EXCEPTION );
3934+ zend_class_entry * called_scope = zend_fetch_class_by_name ( Z_STR_P ( obj ), NULL , ZEND_FETCH_CLASS_DEFAULT | ZEND_FETCH_CLASS_EXCEPTION ) ;
3935+
39303936 if (UNEXPECTED (called_scope == NULL )) {
39313937 return NULL ;
39323938 }
@@ -3948,9 +3954,9 @@ static zend_never_inline zend_execute_data *zend_init_dynamic_call_array(zend_ar
39483954 return NULL ;
39493955 }
39503956 }
3957+ object_or_called_scope = called_scope ;
39513958 } else {
3952- called_scope = Z_OBJCE_P (obj );
3953- object = Z_OBJ_P (obj );
3959+ zend_object * object = Z_OBJ_P (obj );
39543960
39553961 fbc = Z_OBJ_HT_P (obj )-> get_method (& object , Z_STR_P (method ), NULL );
39563962 if (UNEXPECTED (fbc == NULL )) {
@@ -3961,10 +3967,11 @@ static zend_never_inline zend_execute_data *zend_init_dynamic_call_array(zend_ar
39613967 }
39623968
39633969 if ((fbc -> common .fn_flags & ZEND_ACC_STATIC ) != 0 ) {
3964- object = NULL ;
3970+ object_or_called_scope = object -> ce ;
39653971 } else {
3966- call_info |= ZEND_CALL_RELEASE_THIS ;
3972+ call_info |= ZEND_CALL_RELEASE_THIS | ZEND_CALL_HAS_THIS ;
39673973 GC_ADDREF (object ); /* For $this pointer */
3974+ object_or_called_scope = object ;
39683975 }
39693976 }
39703977 } else {
@@ -3977,7 +3984,7 @@ static zend_never_inline zend_execute_data *zend_init_dynamic_call_array(zend_ar
39773984 }
39783985
39793986 return zend_vm_stack_push_call_frame (call_info ,
3980- fbc , num_args , called_scope , object );
3987+ fbc , num_args , object_or_called_scope );
39813988}
39823989/* }}} */
39833990
0 commit comments