It is useful to note that if this is used on a promoted property, which has a default value, it does not work as expected. The default value is related to the constructor parameter, not to the property itself. So for example, if you reflect this property:
<?php
class SomeClass
{
public function __construct(
public ?string $property = null,
) {
}
}
?>
The ReflectionProperty::hasDefaultValue will return false.