Skip to content
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

HeredocIndentationFixer - config option for indentation level #4880

Merged
merged 1 commit into from
Apr 5, 2020

Conversation

gharlan
Copy link
Contributor

@gharlan gharlan commented Mar 9, 2020

We discussed the best indentation level for the HeredocIndentationFixer here and here.

But now since I'm actually using it, I changed my mind.
I would like to write code like this:

    public function foo() 
    {
        return $this->createQuery(<<<'DQL'
            SELECT foo
            FROM App\Entity\Foo foo
            WHERE ...
        DQL)->getResult();
    }

and NOT:

    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:

    $dql = <<<'DQL'
SELECT foo
FROM App\Entity\Foo foo
DQL;

will be changed with the new behavior (same_as_start) to:

    $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).

@gharlan gharlan marked this pull request as ready for review March 20, 2020 23:06
@julienfalque julienfalque added this to the 2.17.0 milestone Mar 21, 2020
@julienfalque julienfalque added the RTM Ready To Merge label Mar 31, 2020
@SpacePossum
Copy link
Contributor

Thank you @gharlan.

@SpacePossum SpacePossum merged commit 98e354f into PHP-CS-Fixer:master Apr 5, 2020
@SpacePossum SpacePossum removed the RTM Ready To Merge label Apr 5, 2020
@gharlan gharlan deleted the heredoc-indentation branch April 5, 2020 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants