Skip to content

reflection: try to avoid manual string comparison #17726

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Zend/zend_builtin_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ ZEND_FUNCTION(method_exists)
if (func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) {
/* Returns true for the fake Closure's __invoke */
RETVAL_BOOL(func->common.scope == zend_ce_closure
&& zend_string_equals_literal_ci(method_name, ZEND_INVOKE_FUNC_NAME));
&& zend_string_equals_ci(method_name, ZSTR_KNOWN(ZEND_STR_MAGIC_INVOKE)));

zend_string_release_ex(func->common.function_name, 0);
zend_free_trampoline(func);
Expand All @@ -985,7 +985,7 @@ ZEND_FUNCTION(method_exists)
} else {
/* Returns true for fake Closure::__invoke */
if (ce == zend_ce_closure
&& zend_string_equals_literal_ci(method_name, ZEND_INVOKE_FUNC_NAME)) {
&& zend_string_equals_ci(method_name, ZSTR_KNOWN(ZEND_STR_MAGIC_INVOKE))) {
RETURN_TRUE;
}
}
Expand Down Expand Up @@ -1537,7 +1537,7 @@ ZEND_FUNCTION(get_resources)
zend_hash_index_add_new(Z_ARRVAL_P(return_value), index, val);
}
} ZEND_HASH_FOREACH_END();
} else if (zend_string_equals_literal(type, "Unknown")) {
} else if (zend_string_equals(type, ZSTR_KNOWN(ZEND_STR_UNKNOWN_CAPITALIZED))) {
array_init(return_value);
ZEND_HASH_FOREACH_KEY_VAL(&EG(regular_list), index, key, val) {
if (!key && Z_RES_TYPE_P(val) <= 0) {
Expand Down
2 changes: 1 addition & 1 deletion ext/reflection/php_reflection.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ static zend_always_inline uint32_t prop_get_flags(const property_reference *ref)

static inline bool is_closure_invoke(const zend_class_entry *ce, const zend_string *lcname) {
return ce == zend_ce_closure
&& zend_string_equals_literal(lcname, ZEND_INVOKE_FUNC_NAME);
&& zend_string_equals(lcname, ZSTR_KNOWN(ZEND_STR_MAGIC_INVOKE));
}

static zend_function *_copy_function(zend_function *fptr) /* {{{ */
Expand Down
Loading