summaryrefslogtreecommitdiff
path: root/Zend/zend_API.c
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-04-14 17:02:47 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-04-14 17:02:47 +0200
commit4a935bc2c9a58319b416655d473367b54fe113de (patch)
tree60c3b7707ac8d2c8679170ca358b11ed7195c3d2 /Zend/zend_API.c
parentbac5137e4ec7e64f1357d7de53764e79751b5c1a (diff)
downloadphp-git-4a935bc2c9a58319b416655d473367b54fe113de.tar.gz
Always use __invoke callable name for objects
The callable name is provided also if it's not callable, in which case it's basically "what it would be if it were callable", which is ClassName::__invoke. The current behavior of casting the object to string makes very little sense as this will just throw an exception for most objects.
Diffstat (limited to 'Zend/zend_API.c')
-rw-r--r--Zend/zend_API.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 6dab0d3f29..cbd89f7c0c 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -3136,21 +3136,12 @@ try_again:
}
case IS_OBJECT:
{
- zend_class_entry *calling_scope;
- zend_function *fptr;
- zend_object *object;
- zend_object *zobj = Z_OBJ_P(callable);
-
- if (zobj->handlers->get_closure
- && zobj->handlers->get_closure(zobj, &calling_scope, &fptr, &object, 1) == SUCCESS) {
- zend_class_entry *ce = zobj->ce;
- zend_string *callable_name = zend_string_alloc(
- ZSTR_LEN(ce->name) + sizeof("::__invoke") - 1, 0);
- memcpy(ZSTR_VAL(callable_name), ZSTR_VAL(ce->name), ZSTR_LEN(ce->name));
- memcpy(ZSTR_VAL(callable_name) + ZSTR_LEN(ce->name), "::__invoke", sizeof("::__invoke"));
- return callable_name;
- }
- return zval_get_string_func(callable);
+ zend_class_entry *ce = Z_OBJCE_P(callable);
+ zend_string *callable_name = zend_string_alloc(
+ ZSTR_LEN(ce->name) + sizeof("::__invoke") - 1, 0);
+ memcpy(ZSTR_VAL(callable_name), ZSTR_VAL(ce->name), ZSTR_LEN(ce->name));
+ memcpy(ZSTR_VAL(callable_name) + ZSTR_LEN(ce->name), "::__invoke", sizeof("::__invoke"));
+ return callable_name;
}
case IS_REFERENCE:
callable = Z_REFVAL_P(callable);