Closed
Description
Description
I think it would be nice to have the possibility of disabling the exception that is thrown and just using a default/null value as return from ->getValue()
?
Currently we can only disable the exception for invalid array indexes:
https://symfony.com/doc/current/components/property_access.html#reading-from-arrays
Example
$propertyAccessor = PropertyAccess::createPropertyAccessorBuilder()
//->enableExceptionOnInvalidPropertyPath()
->disableExceptionOnInvalidPropertyPath()
->getPropertyAccessor();
$object = new Object(); // no methods
$value = $propertyAccessor->getValue($object, 'test');
// $value = null