diff --git a/src/Symfony/Component/PropertyAccess/CHANGELOG.md b/src/Symfony/Component/PropertyAccess/CHANGELOG.md index 071ef3b5201b0..fb5ebfa55034a 100644 --- a/src/Symfony/Component/PropertyAccess/CHANGELOG.md +++ b/src/Symfony/Component/PropertyAccess/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +2.5.0 +------ + + * allowed non alpha numeric characters in second level and deeper object properties names + 2.3.0 ------ diff --git a/src/Symfony/Component/PropertyAccess/PropertyPath.php b/src/Symfony/Component/PropertyAccess/PropertyPath.php index 840fc71572339..833dd0543bc75 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyPath.php +++ b/src/Symfony/Component/PropertyAccess/PropertyPath.php @@ -118,7 +118,7 @@ public function __construct($propertyPath) $position += strlen($matches[1]); $remaining = $matches[4]; - $pattern = '/^(\.(\w+)|\[([^\]]+)\])(.*)/'; + $pattern = '/^(\.([^\.|\[]+)|\[([^\]]+)\])(.*)/'; } if ('' !== $remaining) { diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php index a64930a93a7ba..72fbfe428f4fc 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php @@ -137,6 +137,13 @@ public function testGetValueReadsPropertyWithSpecialCharsExceptDot() $this->assertEquals('Bernhard', $this->getPropertyAccessor()->getValue($array, '%!@$ยง')); } + public function testGetValueReadsPropertyWithSpecialCharsExceptDotNested() + { + $object = (object) array('nested' => (object) array('@child' => 'foo')); + + $this->assertEquals('foo', $this->getPropertyAccessor()->getValue($object, 'nested.@child')); + } + public function testGetValueReadsPropertyWithCustomPropertyPath() { $object = new Author(); @@ -328,6 +335,17 @@ public function testSetValueCamelizesSetterNames() $this->assertEquals('Schussek', $object->getLastName()); } + public function testSetValueWithSpecialCharsNested() + { + $object = new \stdClass(); + $person = new \stdClass(); + $person->{'@email'} = null; + $object->person = $person; + + $this->getPropertyAccessor()->setValue($object, 'person.@email', 'bar'); + $this->assertEquals('bar', $object->person->{'@email'}); + } + /** * @expectedException \Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException */ diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyPathTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyPathTest.php index 4e77a913ff851..c6f1fd6e14e38 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/PropertyPathTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyPathTest.php @@ -38,12 +38,26 @@ public function testDotCannotBePresentAtTheBeginning() new PropertyPath('.property'); } + public function providePathsContainingUnexpectedCharacters() + { + return array( + array('property.'), + array('property.['), + array('property..'), + array('property['), + array('property[['), + array('property[.'), + array('property[]'), + ); + } + /** + * @dataProvider providePathsContainingUnexpectedCharacters * @expectedException \Symfony\Component\PropertyAccess\Exception\InvalidPropertyPathException */ - public function testUnexpectedCharacters() + public function testUnexpectedCharacters($path) { - new PropertyPath('property.$foo'); + new PropertyPath($path); } /** 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