File tree 3 files changed +67
-1
lines changed 3 files changed +67
-1
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,8 @@ PHP NEWS
25
25
array write fetch). (Nikita)
26
26
. Fixed bug #79793 (Use after free if string used in undefined index warning
27
27
is changed). (Nikita)
28
+ . Fixed bug #79862 (Public non-static property in child should take priority
29
+ over private static). (Nikita)
28
30
29
31
- Fileinfo:
30
32
. Fixed bug #79756 (finfo_file crash (FILEINFO_MIME)). (cmb)
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Bug #79862: Public non-static property in child should take priority over private static
3
+ --FILE--
4
+ <?php
5
+
6
+ class a {
7
+ private static $ prop1 ;
8
+ private static $ prop2 ;
9
+ private $ prop3 ;
10
+ private $ prop4 ;
11
+ private static $ prop5 ;
12
+ private static $ prop6 ;
13
+ public function __construct () {
14
+ $ this ->prop1 = 1 ;
15
+ $ this ->prop2 = 2 ;
16
+ $ this ->prop3 = 3 ;
17
+ $ this ->prop4 = 4 ;
18
+ $ this ->prop5 = 5 ;
19
+ $ this ->prop6 = 6 ;
20
+ var_dump (self ::$ prop1 );
21
+ var_dump (self ::$ prop2 );
22
+ var_dump (self ::$ prop5 );
23
+ var_dump (self ::$ prop6 );
24
+ var_dump ($ this );
25
+ }
26
+ }
27
+ class c extends a {
28
+ public $ prop1 ;
29
+ protected $ prop2 ;
30
+ public static $ prop3 ;
31
+ protected static $ prop4 ;
32
+ public static $ prop5 ;
33
+ protected static $ prop6 ;
34
+ }
35
+
36
+ $ c = new c ;
37
+
38
+ ?>
39
+ --EXPECTF--
40
+ Notice: Accessing static property c::$prop5 as non static in %s on line %d
41
+
42
+ Notice: Accessing static property c::$prop6 as non static in %s on line %d
43
+ NULL
44
+ NULL
45
+ NULL
46
+ NULL
47
+ object(c)#1 (6) {
48
+ ["prop1"]=>
49
+ int(1)
50
+ ["prop2":protected]=>
51
+ int(2)
52
+ ["prop3":"a":private]=>
53
+ int(3)
54
+ ["prop4":"a":private]=>
55
+ int(4)
56
+ ["prop5"]=>
57
+ int(5)
58
+ ["prop6"]=>
59
+ int(6)
60
+ }
Original file line number Diff line number Diff line change @@ -421,7 +421,11 @@ static zend_always_inline uintptr_t zend_get_property_offset(zend_class_entry *c
421
421
if (flags & ZEND_ACC_CHANGED ) {
422
422
zend_property_info * p = zend_get_parent_private_property (scope , ce , member );
423
423
424
- if (p ) {
424
+ /* If there is a public/protected instance property on ce, don't try to use a
425
+ * private static property on scope. If both are static, prefer the static
426
+ * property on scope. This will throw a static property notice, rather than
427
+ * a visibility error. */
428
+ if (p && (!(p -> flags & ZEND_ACC_STATIC ) || (flags & ZEND_ACC_STATIC ))) {
425
429
property_info = p ;
426
430
flags = property_info -> flags ;
427
431
goto found ;
You can’t perform that action at this time.
0 commit comments