-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Add exists() method in PropertyAccesor class #60271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hello, is symfony/src/Symfony/Component/PropertyAccess/PropertyAccessorInterface.php Lines 86 to 94 in c10a83f
It basically does the same thing as |
unfortunally I need to use this code to check if array key exits : 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;
}
} |
Description
Hi,
Is it possible to add exists() method in Symfony\Component\PropertyAccess\PropertyAccessor class please ?
Thanks
Example
I use it like this :
The text was updated successfully, but these errors were encountered: