Skip to content

Commit 1b707dd

Browse files
Loïc Chardonnetweaverryan
Loïc Chardonnet
authored andcommitted
Added note on untrimmed parameters (XML)
In XML configuration, the value between` parameter` tags isn't trimmed, which can lead to unexpected behavior. See symfony/symfony#8661
1 parent 3980b0b commit 1b707dd

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

components/dependency_injection/parameters.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,27 @@ rather than being tied up and hidden with the service definition:
9797
->register('mailer', 'Mailer')
9898
->addArgument('%mailer.transport%');
9999
100+
.. caution::
101+
102+
The values between ``parameter`` tags in XML configuration files are not
103+
trimmed.
104+
105+
This means that the following configuration sample will have the value
106+
``\n sendmail\n``:
107+
108+
.. code-block:: xml
109+
110+
<parameter key="mailer.transport">
111+
sendmail
112+
</parameter>
113+
114+
In some cases (for constants or class names), this could throw errors. In
115+
order to prevent this, you must always inline your parameters as follow:
116+
117+
.. code-block:: xml
118+
119+
<parameter key="mailer.transport">sendmail</parameter>
120+
100121
If you were using this elsewhere as well, then you would only need to change
101122
the parameter value in one place if needed.
102123

0 commit comments

Comments
 (0)