Skip to content

Use known zend_string pointer to check for equality instead of C strings #11370

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

Merged
merged 2 commits into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

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_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -2678,15 +2678,15 @@ ZEND_API void zend_check_magic_method_implementation(const zend_class_entry *ce,
zend_check_magic_method_public(ce, fptr, error_type);
zend_check_magic_method_arg_type(0, ce, fptr, error_type, MAY_BE_ARRAY);
zend_check_magic_method_return_type(ce, fptr, error_type, MAY_BE_OBJECT);
} else if (zend_string_equals_literal(lcname, "__invoke")) {
} else if (zend_string_equals(lcname, ZSTR_KNOWN(ZEND_STR_MAGIC_INVOKE))) {
zend_check_magic_method_non_static(ce, fptr, error_type);
zend_check_magic_method_public(ce, fptr, error_type);
} else if (zend_string_equals_literal(lcname, "__sleep")) {
} else if (zend_string_equals(lcname, ZSTR_KNOWN(ZEND_STR_SLEEP))) {
zend_check_magic_method_args(0, ce, fptr, error_type);
zend_check_magic_method_non_static(ce, fptr, error_type);
zend_check_magic_method_public(ce, fptr, error_type);
zend_check_magic_method_return_type(ce, fptr, error_type, MAY_BE_ARRAY);
} else if (zend_string_equals_literal(lcname, "__wakeup")) {
} else if (zend_string_equals(lcname, ZSTR_KNOWN(ZEND_STR_WAKEUP))) {
zend_check_magic_method_args(0, ce, fptr, error_type);
zend_check_magic_method_non_static(ce, fptr, error_type);
zend_check_magic_method_public(ce, fptr, error_type);
Expand Down
4 changes: 2 additions & 2 deletions Zend/zend_closures.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ static zend_result zend_create_closure_from_callable(zval *return_value, zval *c
if (mptr->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) {
/* For Closure::fromCallable([$closure, "__invoke"]) return $closure. */
if (fcc.object && fcc.object->ce == zend_ce_closure
&& zend_string_equals_literal(mptr->common.function_name, "__invoke")) {
&& zend_string_equals(mptr->common.function_name, ZSTR_KNOWN(ZEND_STR_MAGIC_INVOKE))) {
RETVAL_OBJ_COPY(fcc.object);
zend_free_trampoline(mptr);
return SUCCESS;
Expand Down Expand Up @@ -834,7 +834,7 @@ void zend_closure_from_frame(zval *return_value, zend_execute_data *call) { /* {
if (mptr->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) {
if ((ZEND_CALL_INFO(call) & ZEND_CALL_HAS_THIS) &&
(Z_OBJCE(call->This) == zend_ce_closure)
&& zend_string_equals_literal(mptr->common.function_name, "__invoke")) {
&& zend_string_equals(mptr->common.function_name, ZSTR_KNOWN(ZEND_STR_MAGIC_INVOKE))) {
zend_free_trampoline(mptr);
RETURN_OBJ_COPY(Z_OBJ(call->This));
}
Expand Down