File tree Expand file tree Collapse file tree 4 files changed +11
-5
lines changed
ext/standard/tests/class_object Expand file tree Collapse file tree 4 files changed +11
-5
lines changed Original file line number Diff line number Diff line change 6
6
. Fixed bug #78614 (Does not compile with DTRACE anymore).
7
7
(tz at FreeBSD dot org)
8
8
. Fixed bug #78620 (Out of memory error). (cmb, Nikita)
9
+ . Fixed bug #78632 (method_exists() in php74 works differently from php73 in
10
+ checking priv. methods). (Nikita)
9
11
10
12
- Pcntl:
11
13
. Fixed bug #77335 (PHP is preventing SIGALRM from specifying SA_RESTART).
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 @@ -1373,7 +1373,11 @@ ZEND_FUNCTION(method_exists)
1373
1373
zend_string_release_ex (lcname , 0 );
1374
1374
1375
1375
if (func ) {
1376
- RETURN_BOOL (!(func -> common .fn_flags & ZEND_ACC_PRIVATE ) || func -> common .scope == ce );
1376
+ /* Exclude shadow properties when checking a method on a specific class. Include
1377
+ * them when checking an object, as method_exists() generally ignores visibility.
1378
+ * TODO: Should we use EG(scope) for the object case instead? */
1379
+ RETURN_BOOL (Z_TYPE_P (klass ) == IS_OBJECT
1380
+ || !(func -> common .fn_flags & ZEND_ACC_PRIVATE ) || func -> common .scope == ce );
1377
1381
}
1378
1382
1379
1383
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