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 - Introduction #3915

Open
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
4 participants
@gharlan
Contributor

gharlan commented Jul 14, 2018

#3697 / https://wiki.php.net/rfc/flexible_heredoc_nowdoc_syntaxes

Requires PHP 7.3

Input:

<?php
    $a = [
        <<<'EOD'
abcdef
    ghi
jkl
EOD
    ];

is fixed to:

<?php
    $a = [
        <<<'EOD'
            abcdef
                ghi
            jkl
            EOD
    ];

@gharlan gharlan force-pushed the gharlan:heredoc-indentation branch 6 times, most recently from 9c50491 to b644ac4 Jul 14, 2018

@gharlan gharlan changed the title from (WIP) Add HeredocIndentationFixer to Add HeredocIndentationFixer Jul 14, 2018

@dmvdbrugge

This comment has been minimized.

Contributor

dmvdbrugge commented Jul 16, 2018

Is it strange that I'd prefer it to be like this? It would be the same as other opening/closing pairs.

<?php
    $a = [
        <<<'EOD'
            abcdef
                ghi
            jkl
        EOD
    ];

Or does the standard not allow that? It indeed doesn't, I should learn to read the provided links before commenting...

@gharlan

This comment has been minimized.

Contributor

gharlan commented Jul 16, 2018

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.

@gharlan

This comment has been minimized.

Contributor

gharlan commented Jul 16, 2018

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
    );
@dmvdbrugge

This comment has been minimized.

Contributor

dmvdbrugge commented Jul 16, 2018

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

@julienfalque julienfalque referenced this pull request Aug 8, 2018

Open

[Meta] PHP 7.3 support #3697

0 of 6 tasks complete

@gharlan gharlan force-pushed the gharlan:heredoc-indentation branch 2 times, most recently from e50912b to ecd0db7 Sep 7, 2018

@gharlan gharlan force-pushed the gharlan:heredoc-indentation branch from ecd0db7 to 3ece4f1 Nov 27, 2018

@gharlan

This comment has been minimized.

Contributor

gharlan commented Nov 27, 2018

Anything to do here?

@gharlan gharlan force-pushed the gharlan:heredoc-indentation branch from 3ece4f1 to 737ad11 Nov 28, 2018

@SpacePossum

This comment has been minimized.

Member

SpacePossum commented Dec 4, 2018

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

@SpacePossum SpacePossum changed the title from Add HeredocIndentationFixer to HeredocIndentationFixer - Introduction Dec 4, 2018

@gharlan gharlan force-pushed the gharlan:heredoc-indentation branch from 737ad11 to 5e4e52c Dec 4, 2018

@gharlan

This comment has been minimized.

Contributor

gharlan commented Dec 4, 2018

@SpacePossum it is fixed now.
(the current errors seem not to be not related to this pr)

@SpacePossum SpacePossum added the feature label Dec 11, 2018

@SpacePossum SpacePossum added this to the 2.14.0 milestone Dec 11, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment