Open
Description
Description
Hi,
Is it possible to add exists() method in Symfony\Component\PropertyAccess\PropertyAccessor class please ?
Thanks
Example
I use it like this :
private PropertyAccessor $pa;
public function __construct()
{
$this->pa = PropertyAccess::createPropertyAccessorBuilder()
->enableExceptionOnInvalidIndex()
->getPropertyAccessor();
}
public function propertyExists(array $objectOrArray, string $propertyPath): bool
{
try {
$this->pa->getValue($objectOrArray, $propertyPath);
return true;
} catch(NoSuchIndexException $e) {
return false;
}
}