@@ -106,18 +106,17 @@ void ClassImpl::callMethod(INTERNAL_FUNCTION_PARAMETERS)
106106 // the function could throw an exception
107107 try
108108 {
109- // wrap the return value
110- Value result (return_value, true );
111-
112109 // construct parameters
113110 ParametersImpl params (getThis (), ZEND_NUM_ARGS ());
114111
115112 // retrieve the base object
116113 Base *base = params.object ();
117114
118115 // is this a static, or a non-static call?
119- if (base) result = meta->callCall (base, name, params);
120- else result = meta->callCallStatic (name, params);
116+ Php::Value result = base ? meta->callCall (base, name, params) : meta->callCallStatic (name, params);
117+
118+ // return a full copy of the zval, and do not destruct it
119+ RETVAL_ZVAL (result._val , 1 , 0 );
121120 }
122121 catch (const NotImplemented &exception)
123122 {
@@ -151,17 +150,17 @@ void ClassImpl::callInvoke(INTERNAL_FUNCTION_PARAMETERS)
151150 // the function could throw an exception
152151 try
153152 {
154- // wrap the return value
155- Value result (return_value, true );
156-
157153 // construct parameters
158154 ParametersImpl params (getThis (), ZEND_NUM_ARGS ());
159155
160156 // retrieve the base object
161157 Base *base = params.object ();
162158
163159 // call the actual __invoke method on the base object
164- result = meta->callInvoke (base, params);
160+ auto result = meta->callInvoke (base, params);
161+
162+ // return a full copy of the zval, and do not destruct it
163+ RETVAL_ZVAL (result._val , 1 , 0 );
165164 }
166165 catch (const NotImplemented &exception)
167166 {
@@ -212,7 +211,7 @@ zend_function *ClassImpl::getMethod(zend_object **object, zend_string *method, c
212211 auto *function = &data->func ;
213212
214213 // set all properties
215- function->type = ZEND_INTERNAL_FUNCTION;
214+ function->type = ZEND_INTERNAL_FUNCTION;
216215 function->arg_flags [0 ] = 0 ;
217216 function->arg_flags [1 ] = 0 ;
218217 function->arg_flags [2 ] = 0 ;
@@ -256,7 +255,7 @@ zend_function *ClassImpl::getStaticMethod(zend_class_entry *entry, zend_string *
256255 auto *function = &data->func ;
257256
258257 // set all properties for the function
259- function->type = ZEND_INTERNAL_FUNCTION;
258+ function->type = ZEND_INTERNAL_FUNCTION;
260259 function->arg_flags [0 ] = 0 ;
261260 function->arg_flags [1 ] = 0 ;
262261 function->arg_flags [2 ] = 0 ;
@@ -300,7 +299,7 @@ int ClassImpl::getClosure(zval *object, zend_class_entry **entry_ptr, zend_funct
300299 auto *function = &data->func ;
301300
302301 // we're going to set all properties of the zend_internal_function struct
303- function->type = ZEND_INTERNAL_FUNCTION;
302+ function->type = ZEND_INTERNAL_FUNCTION;
304303 function->arg_flags [0 ] = 0 ;
305304 function->arg_flags [1 ] = 0 ;
306305 function->arg_flags [2 ] = 0 ;
0 commit comments