File tree Expand file tree Collapse file tree 3 files changed +9
-5
lines changed
ext/standard/tests/class_object Expand file tree Collapse file tree 3 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ var_dump($example->propertyBarExists());
40
40
41
41
?>
42
42
--EXPECT--
43
- bool(false )
43
+ bool(true )
44
44
bool(true)
45
45
bool(true)
46
46
bool(true)
Original file line number Diff line number Diff line change @@ -1148,7 +1148,11 @@ ZEND_FUNCTION(method_exists)
1148
1148
zend_string_release_ex (lcname , 0 );
1149
1149
1150
1150
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 );
1152
1156
}
1153
1157
1154
1158
if (Z_TYPE_P (klass ) == IS_OBJECT ) {
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ foreach ($methods as $method) {
50
50
echo "Done " ;
51
51
?>
52
52
--EXPECT--
53
- ---(Using string class name)---
53
+ ---(Using string class name)---
54
54
Does C::inherit_pub exist? bool(true)
55
55
Does C::inherit_prot exist? bool(true)
56
56
Does C::inherit_priv exist? bool(false)
@@ -68,10 +68,10 @@ Does C::non_existent exist? bool(false)
68
68
---(Using object)---
69
69
Does C::inherit_pub exist? bool(true)
70
70
Does C::inherit_prot exist? bool(true)
71
- Does C::inherit_priv exist? bool(false )
71
+ Does C::inherit_priv exist? bool(true )
72
72
Does C::inherit_static_pub exist? bool(true)
73
73
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 )
75
75
Does C::pub exist? bool(true)
76
76
Does C::prot exist? bool(true)
77
77
Does C::priv exist? bool(true)
You can’t perform that action at this time.
0 commit comments