From 7ff2a9b21045ce8c07bd732af2d65806f130d5e2 Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Fri, 18 May 2012 10:53:52 +0200 Subject: [PATCH] Revert "[Form] removed a constraint in PropertyPath as the path can definitely be an empty string for errors attached on the main form (when using a constraint defined with the 'validation_constraint' option)" This reverts commit 5182a0c2c417f0e10ecec7d5c6c4f8edba362a5e. PropertyPath instances should be empty. If you have an empty property path string, there is no need to create a PropertyPath instance for it. Conflicts: tests/Symfony/Tests/Component/Form/PropertyPathTest.php --- .../Component/Form/Tests/Util/PropertyPathTest.php | 8 ++++++++ src/Symfony/Component/Form/Util/PropertyPath.php | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Form/Tests/Util/PropertyPathTest.php b/src/Symfony/Component/Form/Tests/Util/PropertyPathTest.php index 299b93c274..4a7190ddb1 100644 --- a/src/Symfony/Component/Form/Tests/Util/PropertyPathTest.php +++ b/src/Symfony/Component/Form/Tests/Util/PropertyPathTest.php @@ -440,6 +440,14 @@ class PropertyPathTest extends \PHPUnit_Framework_TestCase new PropertyPath('property.$form'); } + /** + * @expectedException Symfony\Component\Form\Exception\InvalidPropertyPathException + */ + public function testInvalidPropertyPath_empty() + { + new PropertyPath(''); + } + /** * @expectedException Symfony\Component\Form\Exception\InvalidPropertyPathException */ diff --git a/src/Symfony/Component/Form/Util/PropertyPath.php b/src/Symfony/Component/Form/Util/PropertyPath.php index 8371b6f873..11769ff287 100644 --- a/src/Symfony/Component/Form/Util/PropertyPath.php +++ b/src/Symfony/Component/Form/Util/PropertyPath.php @@ -77,7 +77,7 @@ class PropertyPath implements \IteratorAggregate */ public function __construct($propertyPath) { - if (null === $propertyPath) { + if ('' === $propertyPath || null === $propertyPath) { throw new InvalidPropertyPathException('The property path must not be empty'); }