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

PSR12/FileHeader: make "SpacingAfter" and "SpacingInside" errorcodes modular #2729

Conversation

jrfnl
Copy link
Contributor

@jrfnl jrfnl commented Dec 1, 2019

This changes the error codes for the SpacingAfterBlock and SpacingInsideBlock errors to modular error codes which include a reference to the type of header block, i.e. SpacingAfterDeclareBlock, SpacingInsideUseFunctionBlock etc.

This allows for more selective application of the rules.

Take for instance the quite common case of the header blocks all being separated by blank lines, except for the open tag and file docblock.

<?php
/**
 * File docblock.
 */

namespace A\B\C;

use B\C;

The modular errorcodes I'm proposing in this PR will allow for the sniff to be used to safeguard the blank lines between each section without enforcing a blank line between the PHP open tag and the file docblock using:

<rule ref="PSR12.Files.FileHeader">
   <exclude name="PSR12.Files.FileHeader.SpacingAfterTagBlock"/>
</rule>

Fixes #3453

…modular

This changes the error codes for the `SpacingAfterBlock` and `SpacingInsideBlock` errors to modular error codes which include a reference to the type of header block, i.e. `SpacingAfterDeclareBlock`, `SpacingInsideUseFunctionBlock` etc.

This allows for more selective application of the rules.

Take for instance the quite common case of the header blocks all being separated by blank lines, except for the open tag and file docblock.
```php
<?php
/**
 * File docblock.
 */

namespace A\B\C;

use B\C;
```

The modular errorcodes I'm proposing in this PR will allow for the sniff to be used to safeguard the blank lines between each section without enforcing a blank line between the PHP open tag and the file docblock.
@jrfnl
Copy link
Contributor Author

jrfnl commented Dec 2, 2023

Closing as replaced by PHPCSStandards/PHP_CodeSniffer#35

@jrfnl jrfnl closed this Dec 2, 2023
@jrfnl jrfnl deleted the feature/psr12-fileheader-more-modular-errorcode-spacing-after branch December 26, 2023 01:07
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.

[Question] Possible to ignore only one speciifc PSR12 rule?
1 participant