Skip to content

Commit 9ce6980

Browse files
authored
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
1 parent a720268 commit 9ce6980

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Zend/zend_API.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2678,15 +2678,15 @@ ZEND_API void zend_check_magic_method_implementation(const zend_class_entry *ce,
26782678
zend_check_magic_method_public(ce, fptr, error_type);
26792679
zend_check_magic_method_arg_type(0, ce, fptr, error_type, MAY_BE_ARRAY);
26802680
zend_check_magic_method_return_type(ce, fptr, error_type, MAY_BE_OBJECT);
2681-
} else if (zend_string_equals_literal(lcname, "__invoke")) {
2681+
} else if (zend_string_equals(lcname, ZSTR_KNOWN(ZEND_STR_MAGIC_INVOKE))) {
26822682
zend_check_magic_method_non_static(ce, fptr, error_type);
26832683
zend_check_magic_method_public(ce, fptr, error_type);
2684-
} else if (zend_string_equals_literal(lcname, "__sleep")) {
2684+
} else if (zend_string_equals(lcname, ZSTR_KNOWN(ZEND_STR_SLEEP))) {
26852685
zend_check_magic_method_args(0, ce, fptr, error_type);
26862686
zend_check_magic_method_non_static(ce, fptr, error_type);
26872687
zend_check_magic_method_public(ce, fptr, error_type);
26882688
zend_check_magic_method_return_type(ce, fptr, error_type, MAY_BE_ARRAY);
2689-
} else if (zend_string_equals_literal(lcname, "__wakeup")) {
2689+
} else if (zend_string_equals(lcname, ZSTR_KNOWN(ZEND_STR_WAKEUP))) {
26902690
zend_check_magic_method_args(0, ce, fptr, error_type);
26912691
zend_check_magic_method_non_static(ce, fptr, error_type);
26922692
zend_check_magic_method_public(ce, fptr, error_type);

Zend/zend_closures.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ static zend_result zend_create_closure_from_callable(zval *return_value, zval *c
324324
if (mptr->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) {
325325
/* For Closure::fromCallable([$closure, "__invoke"]) return $closure. */
326326
if (fcc.object && fcc.object->ce == zend_ce_closure
327-
&& zend_string_equals_literal(mptr->common.function_name, "__invoke")) {
327+
&& zend_string_equals(mptr->common.function_name, ZSTR_KNOWN(ZEND_STR_MAGIC_INVOKE))) {
328328
RETVAL_OBJ_COPY(fcc.object);
329329
zend_free_trampoline(mptr);
330330
return SUCCESS;
@@ -834,7 +834,7 @@ void zend_closure_from_frame(zval *return_value, zend_execute_data *call) { /* {
834834
if (mptr->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) {
835835
if ((ZEND_CALL_INFO(call) & ZEND_CALL_HAS_THIS) &&
836836
(Z_OBJCE(call->This) == zend_ce_closure)
837-
&& zend_string_equals_literal(mptr->common.function_name, "__invoke")) {
837+
&& zend_string_equals(mptr->common.function_name, ZSTR_KNOWN(ZEND_STR_MAGIC_INVOKE))) {
838838
zend_free_trampoline(mptr);
839839
RETURN_OBJ_COPY(Z_OBJ(call->This));
840840
}

0 commit comments

Comments
 (0)