Re: ReflectionProperty::has/getDefaultValue

From: Date: Wed, 15 Jan 2020 19:00:10 +0000
Subject: Re: ReflectionProperty::has/getDefaultValue
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-108148@lists.php.net to get a copy of this message
> On Jan 15, 2020, at 9:52 AM, Benjamin Eberlei <kontakt@beberlei.de> wrote: > > 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

« previous php.internals (#108148) next »