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

Fixer conflict between Generic.WhiteSpace.ScopeIndent and Squiz.WhiteSpace.ScopeClosingBrace when class indented 1 space #2464

Closed
mirzazeyrek opened this issue Mar 27, 2019 · 3 comments
Milestone

Comments

@mirzazeyrek
Copy link

mirzazeyrek commented Mar 27, 2019

PHPCS version:

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

Command:

phpcbf --standard=PSR2 calculator.php -p

File:

 <?php


 class Test {

 }

image

@jrfnl
Copy link
Contributor

jrfnl commented Mar 27, 2019

@mirzazeyrek Thanks for reporting this, though I think the topic needs to be changed.

There is no rule in PSR-2 about space before the PHP open tag not being allowed, so PHPCS is not trying to fix that at all, nor will it report on it.

The fixer conflict you are seeing is a conflict between the Generic.WhiteSpace.ScopeIndent and the Squiz.WhiteSpace.ScopeClosingBrace sniffs.

I've ran into that one a number of times before, but haven't been able to find the time to debug it properly .

@gsherwood gsherwood changed the title PHPCBF Failed to fix when there is space before php openning tag Fixer conflict between Generic.WhiteSpace.ScopeIndent and Squiz.WhiteSpace.ScopeClosingBrace when class indented 1 space Apr 1, 2019
@gsherwood
Copy link
Member

A possible solution for this is to just let scope closers (like the class closing brace) be indented to a column that isn't divisible by the current tab width.

This change stops the conflict from occurring and it doesn't make any of the scope indent unit tests fail, but need to add some more tests just to be sure.

@gsherwood gsherwood added this to the 3.4.2 milestone Apr 1, 2019
gsherwood added a commit that referenced this issue Apr 2, 2019
…nt and Squiz.WhiteSpace.ScopeClosingBrace when class indented 1 space
@gsherwood
Copy link
Member

I checked the history of this code and it's been around forever, but an exception was made for closures about 5 years ago. None of the tests are failing, so I've made the change, which allows the closing brace to sit wherever the opener does and not have to be a perfect index. This lets other parts of a standard enforce closing brace rules.

LeSuisse added a commit to Enalean/tuleap that referenced this issue Aug 2, 2019
This update comes with a few indent changes (see [0]).

The update is needed to pull the most recent UnusedUses
sniff from slevomat/coding-standards into our codebase.

Part of request #13708: Cleanup unused use statements and
enforce it in the Tuleap PHP coding standards

[0] squizlabs/PHP_CodeSniffer#2464

Change-Id: I9136142542d0aa83bccc41d62f03b4317e0367cd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants