Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

PropertyAccessor->getValue disable exception #30536

Copy link
Copy link
Closed
@wuestkamp

Description

@wuestkamp
Issue body actions

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.