xref: /PHP-8.0/Zend/tests/bug78921.phpt (revision 621598ea)
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$reflectionProperty->setAccessible(true);
31$value = $reflectionProperty->getValue();
32echo "Value is $value\n";
33
34?>
35--EXPECT--
36Value is my property
37