1--TEST--
2reflection: ReflectionProperty::getDefaultValue
3--FILE--
4<?php
5
6define('FOO', 42);
7
8#[AllowDynamicProperties]
9class TestClass
10{
11    public $foo;
12    public $bar = 'baz';
13
14    public static $static1;
15    public static $static2 = 1234;
16
17    public int $val1;
18    public int $val2 = 1234;
19
20    public ?int $nullable;
21    public ?int $nullable2 = null;
22
23    public $constantAst = 2 * 2;
24    public $constantRuntimeAst = FOO;
25}
26
27$property = new ReflectionProperty(TestClass::class, 'foo');
28var_dump($property->getDefaultValue());
29
30$property = new ReflectionProperty(TestClass::class, 'bar');
31var_dump($property->getDefaultValue());
32
33$property = new ReflectionProperty(TestClass::class, 'static1');
34var_dump($property->getDefaultValue());
35
36$property = new ReflectionProperty(TestClass::class, 'static2');
37var_dump($property->getDefaultValue());
38
39$property = new ReflectionProperty(TestClass::class, 'val1');
40var_dump($property->getDefaultValue());
41
42$property = new ReflectionProperty(TestClass::class, 'val2');
43var_dump($property->getDefaultValue());
44
45$property = new ReflectionProperty(TestClass::class, 'nullable');
46var_dump($property->getDefaultValue());
47
48$property = new ReflectionProperty(TestClass::class, 'nullable2');
49var_dump($property->getDefaultValue());
50
51$property = new ReflectionProperty(TestClass::class, 'constantAst');
52var_dump($property->getDefaultValue());
53
54$property = new ReflectionProperty(TestClass::class, 'constantRuntimeAst');
55var_dump($property->getDefaultValue());
56
57$test = new TestClass;
58$test->dynamic = null;
59$property = new ReflectionProperty($test, 'dynamic');
60var_dump($property->getDefaultValue());
61
62?>
63--EXPECT--
64NULL
65string(3) "baz"
66NULL
67int(1234)
68NULL
69int(1234)
70NULL
71NULL
72int(4)
73int(42)
74NULL
75