From 78022239ddd27dcf898e92a523edd8c0cd340a15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Chardonnet?= Date: Sun, 4 Aug 2013 23:13:37 +0200 Subject: [PATCH] [DIC] Added note on untrimmed parameters (XML) In XML configuration, the value between` parameter` tags isn't trimmed, which can lead to unexpected behavior. See https://github.com/symfony/symfony/pull/8661 --- .../dependency_injection/parameters.rst | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/components/dependency_injection/parameters.rst b/components/dependency_injection/parameters.rst index 129d766cd61..94573c9d53c 100644 --- a/components/dependency_injection/parameters.rst +++ b/components/dependency_injection/parameters.rst @@ -97,6 +97,27 @@ rather than being tied up and hidden with the service definition: ->register('mailer', 'Mailer') ->addArgument('%mailer.transport%'); +.. caution:: + + The values between ``parameter`` tags in XML configuration files are not + trimmed. + + This means that the following configuration sample will have the value + ``\n sendmail\n``: + + .. code-block:: xml + + + sendmail + + + In some cases (for constants or class names), this could throw errors. In + order to prevent this, you must always inline your parameters as follow: + + .. code-block:: xml + + sendmail + If you were using this elsewhere as well, then you would only need to change the parameter value in one place if needed.