Skip to content

Commit cc4af35

Browse files
committed
Merge branch 'PHP-7.4'
2 parents 714561d + 6255308 commit cc4af35

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

Zend/tests/bug50810.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ var_dump($example->propertyBarExists());
4040

4141
?>
4242
--EXPECT--
43-
bool(true)
43+
bool(false)
4444
bool(true)
4545
bool(true)
4646
bool(true)

Zend/tests/method_exists_002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ bool(true)
6262
bool(true)
6363
----
6464
bool(true)
65-
bool(true)
65+
bool(false)
6666
bool(true)
6767
----
6868
bool(true)

Zend/zend_builtin_functions.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,8 @@ ZEND_FUNCTION(method_exists)
11251125
zval *klass;
11261126
zend_string *method_name;
11271127
zend_string *lcname;
1128-
zend_class_entry * ce;
1128+
zend_class_entry *ce;
1129+
zend_function *func;
11291130

11301131
ZEND_PARSE_PARAMETERS_START(2, 2)
11311132
Z_PARAM_ZVAL(klass)
@@ -1143,28 +1144,29 @@ ZEND_FUNCTION(method_exists)
11431144
}
11441145

11451146
lcname = zend_string_tolower(method_name);
1146-
if (zend_hash_exists(&ce->function_table, lcname)) {
1147-
zend_string_release_ex(lcname, 0);
1148-
RETURN_TRUE;
1149-
} else if (Z_TYPE_P(klass) == IS_OBJECT) {
1147+
func = zend_hash_find_ptr(&ce->function_table, lcname);
1148+
zend_string_release_ex(lcname, 0);
1149+
1150+
if (func) {
1151+
RETURN_BOOL(!(func->common.fn_flags & ZEND_ACC_PRIVATE) || func->common.scope == ce);
1152+
}
1153+
1154+
if (Z_TYPE_P(klass) == IS_OBJECT) {
11501155
zend_object *obj = Z_OBJ_P(klass);
1151-
zend_function *func = Z_OBJ_HT_P(klass)->get_method(&obj, method_name, NULL);
1156+
func = Z_OBJ_HT_P(klass)->get_method(&obj, method_name, NULL);
11521157
if (func != NULL) {
11531158
if (func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) {
11541159
/* Returns true to the fake Closure's __invoke */
11551160
RETVAL_BOOL(func->common.scope == zend_ce_closure
11561161
&& zend_string_equals_literal(method_name, ZEND_INVOKE_FUNC_NAME));
11571162

1158-
zend_string_release_ex(lcname, 0);
11591163
zend_string_release_ex(func->common.function_name, 0);
11601164
zend_free_trampoline(func);
11611165
return;
11621166
}
1163-
zend_string_release_ex(lcname, 0);
11641167
RETURN_TRUE;
11651168
}
11661169
}
1167-
zend_string_release_ex(lcname, 0);
11681170
RETURN_FALSE;
11691171
}
11701172
/* }}} */

ext/standard/tests/class_object/method_exists_basic_001.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ echo "Done";
5353
---(Using string class name)---
5454
Does C::inherit_pub exist? bool(true)
5555
Does C::inherit_prot exist? bool(true)
56-
Does C::inherit_priv exist? bool(true)
56+
Does C::inherit_priv exist? bool(false)
5757
Does C::inherit_static_pub exist? bool(true)
5858
Does C::inherit_static_prot exist? bool(true)
59-
Does C::inherit_static_priv exist? bool(true)
59+
Does C::inherit_static_priv exist? bool(false)
6060
Does C::pub exist? bool(true)
6161
Does C::prot exist? bool(true)
6262
Does C::priv exist? bool(true)
@@ -68,10 +68,10 @@ Does C::non_existent exist? bool(false)
6868
---(Using object)---
6969
Does C::inherit_pub exist? bool(true)
7070
Does C::inherit_prot exist? bool(true)
71-
Does C::inherit_priv exist? bool(true)
71+
Does C::inherit_priv exist? bool(false)
7272
Does C::inherit_static_pub exist? bool(true)
7373
Does C::inherit_static_prot exist? bool(true)
74-
Does C::inherit_static_priv exist? bool(true)
74+
Does C::inherit_static_priv exist? bool(false)
7575
Does C::pub exist? bool(true)
7676
Does C::prot exist? bool(true)
7777
Does C::priv exist? bool(true)

0 commit comments

Comments
 (0)