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
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
+1. I have previously run into a use-case for this.
-Mike