1--TEST--
2Test ReflectionProperty::isDynamic() usage.
3--FILE--
4<?php
5
6function reflectProperty($classOrObj, $property, $className = null) {
7    $className ??= $classOrObj;
8    $propInfo = new ReflectionProperty($classOrObj, $property);
9    echo "**********************************\n";
10    echo "Reflecting on property $className::$property\n\n";
11    echo "isDynamic():\n";
12    var_dump($propInfo->isDynamic());
13    echo "\n**********************************\n";
14}
15
16#[AllowDynamicProperties]
17class TestClass {
18    public $pub;
19    static public $stat = "static property";
20    protected $prot = 4;
21    private $priv = "keepOut";
22}
23
24reflectProperty("TestClass", "pub");
25reflectProperty("TestClass", "stat");
26reflectProperty("TestClass", "prot");
27reflectProperty("TestClass", "priv");
28
29$obj = new TestClass();
30$obj->dyn = 'dynamic';
31reflectProperty($obj, "dyn", "TestClass");
32
33?>
34--EXPECT--
35**********************************
36Reflecting on property TestClass::pub
37
38isDynamic():
39bool(false)
40
41**********************************
42**********************************
43Reflecting on property TestClass::stat
44
45isDynamic():
46bool(false)
47
48**********************************
49**********************************
50Reflecting on property TestClass::prot
51
52isDynamic():
53bool(false)
54
55**********************************
56**********************************
57Reflecting on property TestClass::priv
58
59isDynamic():
60bool(false)
61
62**********************************
63**********************************
64Reflecting on property TestClass::dyn
65
66isDynamic():
67bool(true)
68
69**********************************
70