Skip to content

[PropertyAccess][VarExporter] PropertyAccessor::isReadable() triggers an error when called on a lazy object’s missing property #51919

Closed
@MatTheCat

Description

@MatTheCat

Symfony version(s) affected

≥ 6.2

Description

Calling PropertyAccessor::isReadable() on a lazy object’s missing property will trigger an error, even if the object is fully loaded.

This is because PropertyAccessor::getReadInfo() will return the property as public as its class has a __get method, and trying to access it will call trigger_error:

trigger_error(sprintf('Undefined property: %s::$%s in %s on line %s', $this::class, $name, $frame['file'], $frame['line']), \E_USER_NOTICE);

How to reproduce

Call PropertyAccessor::isReadable() on a lazy object’s (like a Doctrine proxy) missing property. Instead of false, you’ll get an ErrorException.

Possible Solution

No response

Additional Context

No response

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