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

Generic.WhiteSpace.ScopeIndent false positives when indenting open tags at a non tab-stop #2586

Closed
cordis-dev opened this issue Aug 17, 2019 · 2 comments

Comments

@cordis-dev
Copy link

PHPCS version:

PHP_CodeSniffer version 3.4.2 (stable) by Squiz (http://www.squiz.net)

Command:

phpcbf --standard=PSR2 test.php -p

File:

     <?php if (true) : ?>
         <span></span>
        <?php endif ?>

Results:

PHPCBF RESULT SUMMARY
----------------------------------------------------------------------
FILE                                                  FIXED  REMAINING
----------------------------------------------------------------------
test.php                                                 FAILED TO FIX
----------------------------------------------------------------------
A TOTAL OF 0 ERRORS WERE FIXED IN 1 FILE
----------------------------------------------------------------------
PHPCBF FAILED TO FIX 1 FILE
----------------------------------------------------------------------

Time: 70ms; Memory: 6MB
@gsherwood
Copy link
Member

The Squiz.WhiteSpace.ScopeClosingBrace and Generic.WhiteSpace.ScopeIndent are conflicting here, due to the 5-space indent of the first line.

A quick workaround is to use a 4-space indent, which is what the sniffs are expecting when you don't specify --tab-width.

I'm not sure which sniff should be changed to resolve the conflict. It depends on if the opening PHP tag should be positioned at an exact tab stop or not.

@gsherwood gsherwood added this to Backlog in PHPCS v3 Development via automation Aug 18, 2019
@gsherwood gsherwood added this to the 3.5.1 milestone Sep 24, 2019
@gsherwood gsherwood moved this from Idea Bank to Backlog in PHPCS v3 Development Sep 26, 2019
@gsherwood gsherwood modified the milestones: 3.5.1, 3.5.2 Oct 1, 2019
@gsherwood gsherwood changed the title Fixer issue for Generic.WhiteSpace.ScopeIndent sniff with PSR2 standard Generic.WhiteSpace.ScopeIndent false positives when indenting open tags at a non tab-stop Nov 12, 2019
gsherwood added a commit that referenced this issue Nov 12, 2019
@gsherwood
Copy link
Member

Thanks for reporting this. I've committed a fix, which will be in 3.5.3. With this change, the open tags will try and align as normal, meaning that the code will be fixed like this:

     <?php if (true) : ?>
         <span></span>
     <?php endif ?>

PHPCS v3 Development automation moved this from Backlog to Ready for Release Nov 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
PHPCS v3 Development
Ready for Release
Development

No branches or pull requests

2 participants