Skip to content

Adds proper escaping for php service config format #15766

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion service_container/expression_language.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ to another service: ``App\Mailer``. One way to do this is with an expression:
$services->set(MailerConfiguration::class);

$services->set(Mailer::class)
->args([expr("service('App\\Mail\\MailerConfiguration').getMailerMethod()")]);
->args([expr("service('App\\\\Mail\\\\MailerConfiguration').getMailerMethod()")]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The result is so ugly and confusing, that we might think of adding a comment explaining this. Example:

$services->set(Mailer::class)
    // because of the escaping applied by PHP, you must add 4 backslashes for each original backslash
    ->args([expr("service('App\\\\Mail\\\\MailerConfiguration').getMailerMethod()")]);

};

To learn more about the expression language syntax, see :doc:`/components/expression_language/syntax`.
Expand Down