xref: /PHP-8.3/Zend/tests/bug79862.phpt (revision 902d6439)
1--TEST--
2Bug #79862: Public non-static property in child should take priority over private static
3--FILE--
4<?php
5
6#[AllowDynamicProperties]
7class a {
8    private static $prop1;
9    private static $prop2;
10    private $prop3;
11    private $prop4;
12    private static $prop5;
13    private static $prop6;
14    public function __construct() {
15        $this->prop1 = 1;
16        $this->prop2 = 2;
17        $this->prop3 = 3;
18        $this->prop4 = 4;
19        $this->prop5 = 5;
20        $this->prop6 = 6;
21        var_dump(self::$prop1);
22        var_dump(self::$prop2);
23        var_dump(self::$prop5);
24        var_dump(self::$prop6);
25        var_dump($this);
26    }
27}
28class c extends a {
29    public $prop1;
30    protected $prop2;
31    public static $prop3;
32    protected static $prop4;
33    public static $prop5;
34    protected static $prop6;
35}
36
37$c = new c;
38
39?>
40--EXPECTF--
41Notice: Accessing static property c::$prop5 as non static in %s on line %d
42
43Notice: Accessing static property c::$prop6 as non static in %s on line %d
44NULL
45NULL
46NULL
47NULL
48object(c)#1 (6) {
49  ["prop3":"a":private]=>
50  int(3)
51  ["prop4":"a":private]=>
52  int(4)
53  ["prop1"]=>
54  int(1)
55  ["prop2":protected]=>
56  int(2)
57  ["prop5"]=>
58  int(5)
59  ["prop6"]=>
60  int(6)
61}
62