From 58c3f52263c032f3197a31e5bf4a2ef4b0085246 Mon Sep 17 00:00:00 2001 From: Lars Strojny Date: Wed, 19 Oct 2016 20:16:43 +0200 Subject: [PATCH 1/2] Trim constant values in XmlFileLoader MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When an XML config file gets long, it's nice to put the constant name into the next line like this: ```xml Some\Namespace\That\Is\Sufficiently\Long\To\Require\A\LineBreak::someLongishConstantName ``` If that’s the case, `constant()` will try and find a constant including the spaces. While it is theoretically possible to have a constant in PHP that starts or ends with a space, it’s impossible for class constants and only doable using `define(" FOO ", …);`. So that’s probably an edge case we can ignore. --- .../Component/DependencyInjection/Loader/XmlFileLoader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php index 91bb2d071dd52..fa4575065bec7 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php @@ -391,7 +391,7 @@ private function getArgumentsAsPhp(\DOMElement $node, $name, $lowercase = true) $arguments[$key] = $arg->nodeValue; break; case 'constant': - $arguments[$key] = constant($arg->nodeValue); + $arguments[$key] = constant(trim(arg->nodeValue)); break; default: $arguments[$key] = XmlUtils::phpize($arg->nodeValue); From 5a4b048b2d989297e1d40b8308560b093a14e50e Mon Sep 17 00:00:00 2001 From: Lars Strojny Date: Wed, 19 Oct 2016 20:31:33 +0200 Subject: [PATCH 2/2] Update XmlFileLoader.php --- .../Component/DependencyInjection/Loader/XmlFileLoader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php index fa4575065bec7..32b62820190b1 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php @@ -391,7 +391,7 @@ private function getArgumentsAsPhp(\DOMElement $node, $name, $lowercase = true) $arguments[$key] = $arg->nodeValue; break; case 'constant': - $arguments[$key] = constant(trim(arg->nodeValue)); + $arguments[$key] = constant(trim($arg->nodeValue)); break; default: $arguments[$key] = XmlUtils::phpize($arg->nodeValue);