-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DI] Fix possible incorrect php-code when dumped strings contains newlines #24532
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
Conversation
I think you can still create a simple test case that uses a "\n" and ensure the dumped result is OK (without trying to actually fit that with the case where it is required). |
@nicolas-grekas done |
$cleanParts = explode("\n", $value); | ||
$cleanParts = array_map(function ($part) { return var_export($part, true); }, $cleanParts); | ||
|
||
return implode(' . "\n" . ', $cleanParts); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spaces around dots should be remove I think, per our CS policy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nicolas-grekas sure, already done.
Some optimizations could be done, for example now string like |
PHP 7 will concat at compile time, so no need IMHO. |
So |
|
Thank you @Strate. |
…ontains newlines (Strate) This PR was squashed before being merged into the 2.7 branch (closes #24532). Discussion ---------- [DI] Fix possible incorrect php-code when dumped strings contains newlines | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no | Deprecations? | no <!-- don't forget to update UPGRADE-*.md files --> | Tests pass? | yes | Fixed tickets | ? | License | MIT | Doc PR | no See discussion #24517 <!-- - Bug fixes must be submitted against the lowest branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against the 3.4, legacy code removals go to the master branch. - Please fill in this template according to the PR you're about to submit. - Replace this comment by a description of what your PR is solving. --> Commits ------- 345f2fc [DI] Fix possible incorrect php-code when dumped strings contains newlines
See discussion #24517