From 42269df58d4f6b40f6fbde238125e2392abcdb2b Mon Sep 17 00:00:00 2001 From: Mathieu Lechat Date: Mon, 20 Nov 2017 12:23:02 +0100 Subject: [PATCH 1/3] Allow EnumNode name to be null --- src/Symfony/Component/Config/Definition/EnumNode.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Config/Definition/EnumNode.php b/src/Symfony/Component/Config/Definition/EnumNode.php index e8821cf51a6e..7fc8bf1699f8 100644 --- a/src/Symfony/Component/Config/Definition/EnumNode.php +++ b/src/Symfony/Component/Config/Definition/EnumNode.php @@ -22,7 +22,7 @@ class EnumNode extends ScalarNode { private $values; - public function __construct(string $name, NodeInterface $parent = null, array $values = array()) + public function __construct(?string $name, NodeInterface $parent = null, array $values = array()) { $values = array_unique($values); if (empty($values)) { From 0cb1988b951132f84769ff12d5f113e092564b3a Mon Sep 17 00:00:00 2001 From: Mathieu Lechat Date: Mon, 20 Nov 2017 12:32:18 +0100 Subject: [PATCH 2/3] add test case --- .../Component/Config/Tests/Definition/EnumNodeTest.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Symfony/Component/Config/Tests/Definition/EnumNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/EnumNodeTest.php index e3e7ef05946f..980d806a08eb 100644 --- a/src/Symfony/Component/Config/Tests/Definition/EnumNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/EnumNodeTest.php @@ -43,6 +43,11 @@ public function testConstructionWithOneDistinctValue() $this->assertSame('foo', $node->finalize('foo')); } + public function testConstructionWithNullName() + { + new EnumNode(null, null, array('foo')); + } + /** * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException * @expectedExceptionMessage The value "foobar" is not allowed for path "foo". Permissible values: "foo", "bar" From ea05224f9e5f3e8f240c1e7051d965d1b99cc4ed Mon Sep 17 00:00:00 2001 From: Mathieu Lechat Date: Mon, 20 Nov 2017 12:40:37 +0100 Subject: [PATCH 3/3] Finalize node --- src/Symfony/Component/Config/Tests/Definition/EnumNodeTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Config/Tests/Definition/EnumNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/EnumNodeTest.php index 980d806a08eb..48468db2604c 100644 --- a/src/Symfony/Component/Config/Tests/Definition/EnumNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/EnumNodeTest.php @@ -45,7 +45,8 @@ public function testConstructionWithOneDistinctValue() public function testConstructionWithNullName() { - new EnumNode(null, null, array('foo')); + $node = new EnumNode(null, null, array('foo')); + $this->assertSame('foo', $node->finalize('foo')); } /**