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