Skip to content

PropertyAccessor->getValue disable exception #30536

@wuestkamp

Description

@wuestkamp

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy