1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

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

* Compare __invoke magic method name with known zend_string pointer

* Compare __sleep/__wakeup magic method name with known zend_string pointer
This commit is contained in:
George Peter Banyard
2023-06-05 13:59:04 +01:00
committed by GitHub
parent a720268214
commit 9ce6980b4d
2 changed files with 5 additions and 5 deletions

View File

@@ -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);

View File

@@ -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;
@@ -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));
}