ReflectionProperty::has/getDefaultValue
| From: | Benjamin Eberlei | Date: | Wed, 15 Jan 2020 14:52:16 +0000 |
| Subject: | ReflectionProperty::has/getDefaultValue | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-108147@lists.php.net to get a copy of this message | ||
Hi everyone,
until now there was no way on ReflectionProperty to easily find out if a
value has a default value and what that default value is. Essentially the
way was indirectly through ReflectionClass::getDefaultProperties().
In combination with typed properties and Reflection use cases (for code
generation for example) it is interesting to know when a property has no
default value, because accessing it through
ReflectionProperty::getValue($object) would otherwise throw a "property
unitialized" error.
I have added a PR adding these two functions and looking for more feedback
from interested parties:
https://github.com/php/php-src/pull/5071
This addition is small so that I believe an RFC is not necessary, given
that it is more "missing functionality" that should have been there before
greetings
Benjamin