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
Add HeredocIndentationFixer #3915
Conversation
9c50491
to
b644ac4
Compare
Is it strange that I'd prefer it to be like this? It would be the same as other opening/closing pairs.
|
It would change the string content, so it would be risky. This would be non-risky: <?php
$a = [
<<<'EOD'
abcdef
ghi
jkl
EOD
]; If it is desired, there could be a configuration option for choosing this style, or the style from my first comment. |
But I think the style from my first comment is better, especially in other cases, like function calls: Input: <?php
foo(<<<'EOD'
abcdef
ghi
jkl
EOD
); Style 1 (current indentation + 1): <?php
foo(<<<'EOD'
abcdef
ghi
jkl
EOD
); Style 2 (current indentation + 0): <?php
foo(<<<'EOD'
abcdef
ghi
jkl
EOD
); |
Oh yeah I agree, definitely current +1. What I commented goes against the standard unfortunately (but understandably too, how else would they determine what whitespace to strip). |
e50912b
to
ecd0db7
Compare
ecd0db7
to
3ece4f1
Compare
Anything to do here? |
3ece4f1
to
737ad11
Compare
On PHP7.4 the tests fail; https://travis-ci.org/FriendsOfPHP/PHP-CS-Fixer/jobs/460930989 (I can reproduce these local on PHP 7.3.0RC6 (cli) ) |
737ad11
to
5e4e52c
Compare
@SpacePossum it is fixed now. |
60f5c3a
to
61242ca
Compare
Thank you @gharlan. |
This PR was merged into the 2.14-dev branch. Discussion ---------- Add HeredocIndentationFixer #3697 / https://wiki.php.net/rfc/flexible_heredoc_nowdoc_syntaxes Requires PHP 7.3 Input: ```php <?php $a = [ <<<'EOD' abcdef ghi jkl EOD ]; ``` is fixed to: ```php <?php $a = [ <<<'EOD' abcdef ghi jkl EOD ]; ``` Commits ------- 61242ca Add HeredocIndentationFixer
thanks @gharlan 🎉 :) |
… level (gharlan) This PR was merged into the 2.17-dev branch. Discussion ---------- HeredocIndentationFixer - config option for indentation level We discussed the best indentation level for the HeredocIndentationFixer [here](#3697 (comment)) and [here](#3915). But now since I'm actually using it, I changed my mind. I would like to write code like this: ```php public function foo() { return $this->createQuery(<<<'DQL' SELECT foo FROM App\Entity\Foo foo WHERE ... DQL)->getResult(); } ``` and NOT: ```php public function foo() { return $this->createQuery(<<<'DQL' SELECT foo FROM App\Entity\Foo foo WHERE ... DQL)->getResult(); } ``` So I suggest to add a config option `indentation` with possible values `start_plus_one` (default; same as current behavior) and `same_as_start` (new behavior). (Ideas for better names?) The fixer will remain non-risky, so it does not change the actual string result. This input: ```php $dql = <<<'DQL' SELECT foo FROM App\Entity\Foo foo DQL; ``` will be changed with the new behavior (`same_as_start`) to: ```php $dql = <<<'DQL' SELECT foo FROM App\Entity\Foo foo DQL; ``` Adding one more indentation level inside string content is not part of this fixer (as it would be risky). Commits ------- b03554d HeredocIndentationFixer - config option for indentation level
#3697 / https://wiki.php.net/rfc/flexible_heredoc_nowdoc_syntaxes
Requires PHP 7.3
Input:
is fixed to: