Skip to content

Property access for properties starting with non-alpha character #8930

@pavelsmolka

Description

@pavelsmolka

This is a feature request. I would like the PropertyAccessor to be able to access nested properties beginning with non-alpha characters (especially '@' and '$'). These are used very often in the object trees, which have been created by parsing JSON or other markup/data format.

Example:

$object = json_decode('{ "@works" : 1, "nested" : { "@broken" : 2 } }');
$accessor = PropertyAccess::createPropertyAccessor();

$object->{'@works'}; // returns 1
$accessor->getValue($object, '@works'); // returns 1

$object->{'nested'}->{'@broken'}; // returns 2
$accessor->getValue($object, 'nested.@broken'); // throws an exception

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