Commit 3884053c04c for php
commit 3884053c04ccca6597657975342c4ea819890206
Author: Gina Peter Banyard <girgias@php.net>
Date: Tue Sep 29 16:20:29 2026 +0100
Zend: rename zend_object* parameter to "this_ptr" for zend_call_* functions (#23989)
To be more explicit in what the zend_object* represents.
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 9b865b7b5d2..db20926dd96 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -3791,13 +3791,13 @@ static bool zend_is_callable_check_class(zend_string *name, zend_class_entry *sc
const zend_class_entry *frame_scope = get_scope(frame);
fcc->calling_scope = ce;
if (frame_scope && !fcc->object) {
- zend_object *object = zend_get_this_object(frame);
+ zend_object *this_ptr = zend_get_this_object(frame);
- if (object &&
- instanceof_function(object->ce, frame_scope) &&
+ if (this_ptr &&
+ instanceof_function(this_ptr->ce, frame_scope) &&
instanceof_function(frame_scope, ce)) {
- fcc->object = object;
- fcc->called_scope = object->ce;
+ fcc->object = this_ptr;
+ fcc->called_scope = this_ptr->ce;
} else {
fcc->called_scope = ce;
}
@@ -3870,13 +3870,13 @@ static zend_always_inline bool zend_is_method_callable(zend_string *callable, co
if (ZSTR_HAS_CE_CACHE(class_name) && ZSTR_GET_CE_CACHE(class_name)) {
fcc->calling_scope = ZSTR_GET_CE_CACHE(class_name);
if (scope && !fcc->object) {
- zend_object *object = zend_get_this_object(frame);
+ zend_object *this_ptr = zend_get_this_object(frame);
- if (object &&
- instanceof_function(object->ce, scope) &&
+ if (this_ptr &&
+ instanceof_function(this_ptr->ce, scope) &&
instanceof_function(scope, fcc->calling_scope)) {
- fcc->object = object;
- fcc->called_scope = object->ce;
+ fcc->object = this_ptr;
+ fcc->called_scope = this_ptr->ce;
} else {
fcc->called_scope = fcc->calling_scope;
}
@@ -3982,10 +3982,10 @@ static zend_always_inline bool zend_is_method_callable(zend_string *callable, co
retval = true;
call_via_handler = (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) != 0;
if (call_via_handler && !fcc->object) {
- zend_object *object = zend_get_this_object(frame);
- if (object &&
- instanceof_function(object->ce, fcc->calling_scope)) {
- fcc->object = object;
+ zend_object *this_ptr = zend_get_this_object(frame);
+ if (this_ptr &&
+ instanceof_function(this_ptr->ce, fcc->calling_scope)) {
+ fcc->object = this_ptr;
}
}
}
diff --git a/Zend/zend_API.h b/Zend/zend_API.h
index 786ccafbb9d..5c408305220 100644
--- a/Zend/zend_API.h
+++ b/Zend/zend_API.h
@@ -60,7 +60,7 @@ typedef struct _zend_fcall_info_cache {
zend_function *function_handler;
zend_class_entry *calling_scope;
zend_class_entry *called_scope;
- zend_object *object; /* Instance of object for method calls */
+ zend_object *object; /* Pointer for object representing $this */
zend_object *closure; /* Closure reference, only if the callable *is* the object */
} zend_fcall_info_cache;
@@ -858,16 +858,16 @@ static zend_always_inline zend_result zend_call_function_with_return_value(
/* Call the provided zend_function with the given params.
* If retval_ptr is NULL, the return value is discarded.
- * If object is NULL, this must be a free function or static call.
+ * If this_ptr is NULL, this must be a free function or static call.
* called_scope must be provided for instance and static method calls. */
ZEND_API void zend_call_known_function_ex(
- zend_function *fn, zend_object *object, zend_class_entry *called_scope, zval *retval_ptr,
+ zend_function *fn, zend_object *this_ptr, zend_class_entry *called_scope, zval *retval_ptr,
uint32_t param_count, zval *params, HashTable *named_params, uint32_t consumed_args);
static zend_always_inline void zend_call_known_function(
- zend_function *fn, zend_object *object, zend_class_entry *called_scope, zval *retval_ptr,
+ zend_function *fn, zend_object *this_ptr, zend_class_entry *called_scope, zval *retval_ptr,
uint32_t param_count, zval *params, HashTable *named_params) {
- zend_call_known_function_ex(fn, object, called_scope, retval_ptr, param_count, params, named_params, 0);
+ zend_call_known_function_ex(fn, this_ptr, called_scope, retval_ptr, param_count, params, named_params, 0);
}
static zend_always_inline void zend_call_known_fcc_ex(
@@ -892,32 +892,32 @@ static zend_always_inline void zend_call_known_fcc(
/* Call the provided zend_function instance method on an object. */
static zend_always_inline void zend_call_known_instance_method(
- zend_function *fn, zend_object *object, zval *retval_ptr,
+ zend_function *fn, zend_object *this_ptr, zval *retval_ptr,
uint32_t param_count, zval *params)
{
- zend_call_known_function(fn, object, object->ce, retval_ptr, param_count, params, NULL);
+ zend_call_known_function(fn, this_ptr, this_ptr->ce, retval_ptr, param_count, params, NULL);
}
static zend_always_inline void zend_call_known_instance_method_with_0_params(
- zend_function *fn, zend_object *object, zval *retval_ptr)
+ zend_function *fn, zend_object *this_ptr, zval *retval_ptr)
{
- zend_call_known_instance_method(fn, object, retval_ptr, 0, NULL);
+ zend_call_known_instance_method(fn, this_ptr, retval_ptr, 0, NULL);
}
static zend_always_inline void zend_call_known_instance_method_with_1_params(
- zend_function *fn, zend_object *object, zval *retval_ptr, zval *param)
+ zend_function *fn, zend_object *this_ptr, zval *retval_ptr, zval *param)
{
- zend_call_known_instance_method(fn, object, retval_ptr, 1, param);
+ zend_call_known_instance_method(fn, this_ptr, retval_ptr, 1, param);
}
ZEND_API void zend_call_known_instance_method_with_2_params(
- zend_function *fn, zend_object *object, zval *retval_ptr, zval *param1, zval *param2);
+ zend_function *fn, zend_object *this_ptr, zval *retval_ptr, zval *param1, zval *param2);
/* Call method if it exists. Return FAILURE if method does not exist or call failed.
* If FAILURE is returned, retval will be UNDEF. As such, destroying retval unconditionally
* is legal. */
ZEND_API zend_result zend_call_method_if_exists(
- zend_object *object, zend_string *method_name, zval *retval,
+ zend_object *this_ptr, zend_string *method_name, zval *retval,
uint32_t param_count, zval *params);
ZEND_API zend_result zend_delete_global_variable(zend_string *name);
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index 7910c840a17..3d0b690944b 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -1133,7 +1133,7 @@ zend_result zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_
/* }}} */
ZEND_API void zend_call_known_function_ex(
- zend_function *fn, zend_object *object, zend_class_entry *called_scope, zval *retval_ptr,
+ zend_function *fn, zend_object *this_ptr, zend_class_entry *called_scope, zval *retval_ptr,
uint32_t param_count, zval *params, HashTable *named_params, uint32_t consumed_args)
{
zval retval;
@@ -1143,16 +1143,17 @@ ZEND_API void zend_call_known_function_ex(
ZEND_ASSERT(fn && "zend_function must be passed!");
fci.size = sizeof(fci);
- fci.object = object;
fci.retval = retval_ptr ? retval_ptr : &retval;
fci.param_count = param_count;
fci.params = params;
fci.named_params = named_params;
fci.consumed_args = consumed_args;
- ZVAL_UNDEF(&fci.function_name); /* Unused */
+ /* Unused */
+ ZVAL_UNDEF(&fci.function_name);
+ fci.object = NULL;
fcic.function_handler = fn;
- fcic.object = object;
+ fcic.object = this_ptr;
fcic.called_scope = called_scope;
zend_result result = zend_call_function(&fci, &fcic);
@@ -1170,16 +1171,16 @@ ZEND_API void zend_call_known_function_ex(
}
ZEND_API void zend_call_known_instance_method_with_2_params(
- zend_function *fn, zend_object *object, zval *retval_ptr, zval *param1, zval *param2)
+ zend_function *fn, zend_object *this_ptr, zval *retval_ptr, zval *param1, zval *param2)
{
zval params[2];
ZVAL_COPY_VALUE(¶ms[0], param1);
ZVAL_COPY_VALUE(¶ms[1], param2);
- zend_call_known_instance_method(fn, object, retval_ptr, 2, params);
+ zend_call_known_instance_method(fn, this_ptr, retval_ptr, 2, params);
}
ZEND_API zend_result zend_call_method_if_exists(
- zend_object *object, zend_string *method_name, zval *retval,
+ zend_object *this_ptr, zend_string *method_name, zval *retval,
uint32_t param_count, zval *params)
{
zval zval_method;
@@ -1187,7 +1188,7 @@ ZEND_API zend_result zend_call_method_if_exists(
ZVAL_STR(&zval_method, method_name);
- if (UNEXPECTED(!zend_is_callable_ex(&zval_method, object, IS_CALLABLE_SUPPRESS_DEPRECATIONS, NULL, &fcc, NULL))) {
+ if (UNEXPECTED(!zend_is_callable_ex(&zval_method, this_ptr, IS_CALLABLE_SUPPRESS_DEPRECATIONS, NULL, &fcc, NULL))) {
ZVAL_UNDEF(retval);
return FAILURE;
}