summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Zend/tests/bug50810.phpt2
-rw-r--r--Zend/tests/method_exists_002.phpt2
-rw-r--r--Zend/zend_builtin_functions.c20
-rw-r--r--ext/standard/tests/class_object/method_exists_basic_001.phpt8
4 files changed, 17 insertions, 15 deletions
diff --git a/Zend/tests/bug50810.phpt b/Zend/tests/bug50810.phpt
index b2a2931651..e36ab0c30b 100644
--- a/Zend/tests/bug50810.phpt
+++ b/Zend/tests/bug50810.phpt
@@ -40,7 +40,7 @@ var_dump($example->propertyBarExists());
?>
--EXPECT--
-bool(true)
+bool(false)
bool(true)
bool(true)
bool(true)
diff --git a/Zend/tests/method_exists_002.phpt b/Zend/tests/method_exists_002.phpt
index 385506b0b7..89d3f2824d 100644
--- a/Zend/tests/method_exists_002.phpt
+++ b/Zend/tests/method_exists_002.phpt
@@ -62,7 +62,7 @@ bool(true)
bool(true)
----
bool(true)
-bool(true)
+bool(false)
bool(true)
----
bool(true)
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index cc372c4ee8..40692925e7 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -1125,7 +1125,8 @@ ZEND_FUNCTION(method_exists)
zval *klass;
zend_string *method_name;
zend_string *lcname;
- zend_class_entry * ce;
+ zend_class_entry *ce;
+ zend_function *func;
ZEND_PARSE_PARAMETERS_START(2, 2)
Z_PARAM_ZVAL(klass)
@@ -1143,28 +1144,29 @@ ZEND_FUNCTION(method_exists)
}
lcname = zend_string_tolower(method_name);
- if (zend_hash_exists(&ce->function_table, lcname)) {
- zend_string_release_ex(lcname, 0);
- RETURN_TRUE;
- } else if (Z_TYPE_P(klass) == IS_OBJECT) {
+ func = zend_hash_find_ptr(&ce->function_table, lcname);
+ zend_string_release_ex(lcname, 0);
+
+ if (func) {
+ RETURN_BOOL(!(func->common.fn_flags & ZEND_ACC_PRIVATE) || func->common.scope == ce);
+ }
+
+ if (Z_TYPE_P(klass) == IS_OBJECT) {
zend_object *obj = Z_OBJ_P(klass);
- zend_function *func = Z_OBJ_HT_P(klass)->get_method(&obj, method_name, NULL);
+ func = Z_OBJ_HT_P(klass)->get_method(&obj, method_name, NULL);
if (func != NULL) {
if (func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) {
/* Returns true to the fake Closure's __invoke */
RETVAL_BOOL(func->common.scope == zend_ce_closure
&& zend_string_equals_literal(method_name, ZEND_INVOKE_FUNC_NAME));
- zend_string_release_ex(lcname, 0);
zend_string_release_ex(func->common.function_name, 0);
zend_free_trampoline(func);
return;
}
- zend_string_release_ex(lcname, 0);
RETURN_TRUE;
}
}
- zend_string_release_ex(lcname, 0);
RETURN_FALSE;
}
/* }}} */
diff --git a/ext/standard/tests/class_object/method_exists_basic_001.phpt b/ext/standard/tests/class_object/method_exists_basic_001.phpt
index 2368d1217e..8046051523 100644
--- a/ext/standard/tests/class_object/method_exists_basic_001.phpt
+++ b/ext/standard/tests/class_object/method_exists_basic_001.phpt
@@ -53,10 +53,10 @@ echo "Done";
---(Using string class name)---
Does C::inherit_pub exist? bool(true)
Does C::inherit_prot exist? bool(true)
-Does C::inherit_priv exist? bool(true)
+Does C::inherit_priv exist? bool(false)
Does C::inherit_static_pub exist? bool(true)
Does C::inherit_static_prot exist? bool(true)
-Does C::inherit_static_priv exist? bool(true)
+Does C::inherit_static_priv exist? bool(false)
Does C::pub exist? bool(true)
Does C::prot exist? bool(true)
Does C::priv exist? bool(true)
@@ -68,10 +68,10 @@ Does C::non_existent exist? bool(false)
---(Using object)---
Does C::inherit_pub exist? bool(true)
Does C::inherit_prot exist? bool(true)
-Does C::inherit_priv exist? bool(true)
+Does C::inherit_priv exist? bool(false)
Does C::inherit_static_pub exist? bool(true)
Does C::inherit_static_prot exist? bool(true)
-Does C::inherit_static_priv exist? bool(true)
+Does C::inherit_static_priv exist? bool(false)
Does C::pub exist? bool(true)
Does C::prot exist? bool(true)
Does C::priv exist? bool(true)