Skip to content

Allow PHPCS Sniffs to Disable Themselves #229

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

Conversation

Kenneth-Sills
Copy link
Contributor

From the related issue:

Some PHPCS sniffer rules return a value with their ->process method, pointing to an index in the file's token stack where the rule should turn back on. This allows them to recognize blocks of code where they do not apply.

An example of this can be seen with PSR12.Operators.OperatorSpacingSniff. It must use this ignore functionality to avoid adding spacing to the left/right of the = in declare(strict_types=1).

We don't currently respect any return code they provide, meaning using the PSR12 rules for ECS, PHPCS, and PHP CS Fixer together will become unresolvable.

Closes #215

@TomasVotruba
Copy link
Contributor

Despite this being a feature in linked sniff, I feel this should be fixed in the sniff logic itself. It seems pretty nasty hack.
Moreover when php-cs-fixer has mutually independent rules by design. I suggest either improving design of code sniffer/rule, or using php-cs-fixer rule (if we use the sniff in one of sets here, please send PR to use fixer).

Closing then, thanks for understanding 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ECS Does Not Allow PHPCS Sniffs to Disable Themselves
2 participants