Skip to content

Commit 0dc8a54

Browse files
committed
Zend: move true function search out of main callability check
And rename C function to zend_is_method_callable
1 parent 76e0734 commit 0dc8a54

1 file changed

Lines changed: 17 additions & 13 deletions

File tree

Zend/zend_API.c

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3818,7 +3818,7 @@ ZEND_API void zend_release_fcall_info_cache(zend_fcall_info_cache *fcc) {
38183818
}
38193819
}
38203820

3821-
static zend_always_inline bool zend_is_string_callable(zend_string *callable, const zend_execute_data *frame, zend_fcall_info_cache *fcc, bool strict_class, char **error, bool suppress_deprecation) /* {{{ */
3821+
static zend_always_inline bool zend_is_method_callable(zend_string *callable, const zend_execute_data *frame, zend_fcall_info_cache *fcc, bool strict_class, char **error, bool suppress_deprecation) /* {{{ */
38223822
{
38233823
zend_class_entry *ce_org = fcc->calling_scope;
38243824
bool retval = false;
@@ -3831,14 +3831,6 @@ static zend_always_inline bool zend_is_string_callable(zend_string *callable, co
38313831

38323832
fcc->calling_scope = NULL;
38333833

3834-
if (!ce_org) {
3835-
zend_function *func = zend_fetch_function(callable);
3836-
if (EXPECTED(func != NULL)) {
3837-
fcc->function_handler = func;
3838-
return 1;
3839-
}
3840-
}
3841-
38423834
/* Split name into class/namespace and method/function names */
38433835
if ((colon = zend_memrchr(ZSTR_VAL(callable), ':', ZSTR_LEN(callable))) != NULL &&
38443836
colon > ZSTR_VAL(callable) &&
@@ -4176,17 +4168,29 @@ ZEND_API bool zend_is_callable_at_frame(
41764168
again:
41774169
switch (Z_TYPE_P(callable)) {
41784170
case IS_STRING:
4179-
if (object) {
4171+
/* First check for a normal function */
4172+
if (!object) {
4173+
if (check_flags & IS_CALLABLE_CHECK_SYNTAX_ONLY) {
4174+
return true;
4175+
}
4176+
4177+
zend_function *func = zend_fetch_function(Z_STR_P(callable));
4178+
if (EXPECTED(func != NULL)) {
4179+
fcc->function_handler = func;
4180+
return true;
4181+
}
4182+
/* Might be a static method */
4183+
} else {
41804184
fcc->object = object;
41814185
fcc->calling_scope = object->ce;
41824186
}
41834187

41844188
if (check_flags & IS_CALLABLE_CHECK_SYNTAX_ONLY) {
41854189
fcc->called_scope = fcc->calling_scope;
4186-
return 1;
4190+
return true;
41874191
}
41884192

4189-
ret = zend_is_string_callable(Z_STR_P(callable), frame, fcc, strict_class, error, check_flags & IS_CALLABLE_SUPPRESS_DEPRECATIONS);
4193+
ret = zend_is_method_callable(Z_STR_P(callable), frame, fcc, strict_class, error, check_flags & IS_CALLABLE_SUPPRESS_DEPRECATIONS);
41904194
break;
41914195

41924196
case IS_ARRAY:
@@ -4234,7 +4238,7 @@ ZEND_API bool zend_is_callable_at_frame(
42344238
}
42354239
}
42364240

4237-
ret = zend_is_string_callable(Z_STR_P(method), frame, fcc, strict_class, error, check_flags & IS_CALLABLE_SUPPRESS_DEPRECATIONS);
4241+
ret = zend_is_method_callable(Z_STR_P(method), frame, fcc, strict_class, error, check_flags & IS_CALLABLE_SUPPRESS_DEPRECATIONS);
42384242
break;
42394243
}
42404244

0 commit comments

Comments
 (0)