Skip to content

Commit fec0ff8

Browse files
committed
Merge branch 'PHP-7.4'
2 parents dc3c8c7 + ca652aa commit fec0ff8

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
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(false)
43+
bool(true)
4444
bool(true)
4545
bool(true)
4646
bool(true)

Zend/zend_builtin_functions.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1148,7 +1148,11 @@ ZEND_FUNCTION(method_exists)
11481148
zend_string_release_ex(lcname, 0);
11491149

11501150
if (func) {
1151-
RETURN_BOOL(!(func->common.fn_flags & ZEND_ACC_PRIVATE) || func->common.scope == ce);
1151+
/* Exclude shadow properties when checking a method on a specific class. Include
1152+
* them when checking an object, as method_exists() generally ignores visibility.
1153+
* TODO: Should we use EG(scope) for the object case instead? */
1154+
RETURN_BOOL(Z_TYPE_P(klass) == IS_OBJECT
1155+
|| !(func->common.fn_flags & ZEND_ACC_PRIVATE) || func->common.scope == ce);
11521156
}
11531157

11541158
if (Z_TYPE_P(klass) == IS_OBJECT) {

ext/standard/tests/class_object/method_exists_basic_001.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ foreach ($methods as $method) {
5050
echo "Done";
5151
?>
5252
--EXPECT--
53-
---(Using string class name)---
53+
---(Using string class name)---
5454
Does C::inherit_pub exist? bool(true)
5555
Does C::inherit_prot exist? bool(true)
5656
Does C::inherit_priv exist? bool(false)
@@ -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(false)
71+
Does C::inherit_priv exist? bool(true)
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(false)
74+
Does C::inherit_static_priv exist? bool(true)
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)