-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
chore: PHP CS Fixer - update heredoc handling #61372
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
rebase needed |
28902d9
to
ada37a9
Compare
I made some handcrafted tweaks. |
I think we should find a better way than having the need for trailing spaces in some tests as dealing with them is also a mess when you open these test files in your local IDE for doing other changes in that file and your IDE then strips all trailing whitespaces. |
👍🏻
do you have an example of Fixer doing that? I can't see it in this PR, and we tried hard to not remove trailing whitespace inside of string, as it would change the meaning of the code. separately, good to merge, I think ? |
See Fabbot's report in the CI failures: php-cs-fixer suggests many changes inside heredoc that we don't want. |
ok, thanks for hint what you meant. to change the behaviour, we simply need to disable that rule for the project, but tbh - i would rather keep it enabled, as for 99% cases, removal of trailing whitespaces is expected, and as @xabbuh mentioned, having them is also fooling other tools like IDE |
Ah that's good to know. This should be disabled to me. Strings are strings - aka not up for CS fixes. |
that's where we have i recommend to not block this PR due to |
from practice, most of cases i had strings i actually wanted to remove such spaces, but happy to go both ways and update the ruleset if concluded (or please, feel free to send such PR as well). as alternative solution, we can change way we write such strings, eg: --- a/src/Symfony/Component/Console/Tests/Helper/TableTest.php
+++ b/src/Symfony/Component/Console/Tests/Helper/TableTest.php
@@ -1832,20 +1832,20 @@ class TableTest extends TestCase
];
yield 'Borderless style' => [
- <<<EOTXT
- ==============================
- ISBN: 99921-58-10-7
- Title: Divine Comedy
- Author: Dante Alighieri
- Price: 9.95
- ==============================
- ISBN: 9971-5-0210-0
- Title: A Tale of Two Cities
- Author: Charles Dickens
- Price: 139.25
- ==============================
-
- EOTXT,
+ implode("\n", [
+ ' ============================== ',
+ ' ISBN: 99921-58-10-7 ',
+ ' Title: Divine Comedy ',
+ ' Author: Dante Alighieri ',
+ ' Price: 9.95 ',
+ ' ============================== ',
+ ' ISBN: 9971-5-0210-0 ',
+ ' Title: A Tale of Two Cities ',
+ ' Author: Charles Dickens ',
+ ' Price: 139.25 ',
+ ' ============================== ',
+ '',
+ ]), benefit? no other tools (like IDE) will complain on trailing whitespaces. |
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.
I disabled no_trailing_whitespace_in_string
.
That'll remove a bunch of false-positives.
Thanks for pointing this exists :)
ada37a9
to
f995622
Compare
Thank you @keradus. |
@nicolas-grekas , would you like to re-visit |
@nicolas-grekas , also as you are on fire, please check PHP-CS-Fixer/PHP-CS-Fixer#8930 |
Inspired while #61371 , but can be merged separately.
@PHPxMigration
and@Symfony
ruleset have different config for those rules. I assume the difference is coming from supporting pre-7.2 PHP version earlier in the codebase, where heredoc closure and trailing comma had to be on separated lines - but it's no longer the case.Can we benefit from newer PHP syntax and incorporate those changes? (yes,
trailing_comma_in_multiline
, part of@Symfony
, is already having this enabled!)if so, i will also merge them into
@Symfony
ruleset itself afterwards.with love by PHP Coding Standards Fixer