8000 Property access for properties starting with non-alpha character · Issue #8930 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

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

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

Closed
pavelsmolka opened this issue Sep 4, 2013 · 1 comment
Closed

Comments

@pavelsmolka
Copy link

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
@pavelsmolka
Copy link
Author

I guess this should be achieved by changing this regex:
https://github.com/symfony/PropertyAccess/blob/master/PropertyPath.php#L121

And this (different) regex causes that the first example from my issue report works:
https://github.com/symfony/PropertyAccess/blob/master/PropertyPath.php#L96

The question is: What happens if these regexs change? I am new to Symfony and I do not know what has to be matched by these regexs and what must not be.

thunderer added a commit to thunderer/symfony that referenced this issue Dec 14, 2013
thunderer added a commit to thunderer/symfony that referenced this issue Dec 14, 2013
fabpot added a commit that referenced this issue Dec 23, 2013
…ct properties (florianv)

This PR was merged into the 2.5-dev branch.

Discussion
----------

[PropertyAccess] Allowed non alphanumeric chars in object properties

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #8930
| License       | MIT
| Doc PR        |

Commits
-------

20d4eb6 [PropertyAccess] Allowed non alphanumeric chars in object properties
@fabpot fabpot closed this as completed Dec 23, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants
0