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