File tree 2 files changed +65
-1
lines changed 2 files changed +65
-1
lines changed 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 @@ -310,7 +310,11 @@ static zend_always_inline uintptr_t zend_get_property_offset(zend_class_entry *c
310
310
if (flags & ZEND_ACC_CHANGED ) {
311
311
zend_property_info * p = zend_get_parent_private_property (scope , ce , member );
312
312
313
- if (p ) {
313
+ /* If there is a public/protected instance property on ce, don't try to use a
314
+ * private static property on scope. If both are static, prefer the static
315
+ * property on scope. This will throw a static property notice, rather than
316
+ * a visibility error. */
317
+ if (p && (!(p -> flags & ZEND_ACC_STATIC ) || (flags & ZEND_ACC_STATIC ))) {
314
318
property_info = p ;
315
319
flags = property_info -> flags ;
316
320
goto found ;
You can’t perform that action at this time.
0 commit comments