I'm looking for a way to access the default value assignment for a property without instantiating the class.
E.g.
class Foo {
private $bar = 'bar';
}
$reflClass = new ReflectionClass('Foo');
$reflProp = $reflClass->getProperty('bar');
Now what? If I use $reflProp->getValue()
(without an object argument) it will fail.
You can use getDefaultProperties()
:
var_dump($reflClass->getDefaultProperties());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With