xref: /PHP-8.4/Zend/tests/bug78921.phpt (revision 6e16e1da)
1--TEST--
2Bug #78921: When Reflection triggers class load, property visibility is incorrect
3--FILE--
4<?php
5
6spl_autoload_register(function($className) {
7    if ($className == 'PrivateStatic') {
8        class PrivateStatic
9        {
10            const SOME_CONST = 13;
11            private static $privateStaticVarArray = ['a', 'b', 'c'];
12            private static $otherStatic;
13            public static function init()
14            {
15                self::$otherStatic = self::$privateStaticVarArray;
16            }
17        }
18        PrivateStatic::init();
19    }
20});
21
22class OtherClass
23{
24    const MY_CONST = PrivateStatic::SOME_CONST;
25    public static $prop = 'my property';
26}
27
28$reflectionClass = new ReflectionClass('OtherClass');
29$reflectionProperty = $reflectionClass->getProperty('prop');
30$value = $reflectionProperty->getValue();
31echo "Value is $value\n";
32
33?>
34--EXPECT--
35Value is my property
36