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.Traits.UseDeclaration: check spacing after use keyword for multi-line statements + fix typo #3856

Conversation

jrfnl
Copy link
Contributor

@jrfnl jrfnl commented Jul 19, 2023

Description

PSR12.Traits.UseDeclaration: fix typo in error code

The processUseStatement() method checking single-line trait use statements checks the spacing after the use keyword, but the error did not have the correct error code.

PSR12.Traits.UseDeclaration: check spacing after use keyword for multi-line statements

While the processUseStatement() method checking single-line trait use statements would check the spacing after the use keyword, the processUseGroup() method checking multi-line trait use statements did not execute that same check, while the rule applies to both single- as well as multi-line use statements.

By moving the check for the spacing after the use keyword to the process() method, it will now be executed for both situations.

Tested by adjusting a pre-existing test.

Suggested changelog entry

  • PSR12.Traits.UseDeclaration will now report on issues with spacing after the use keyword using the SpaceAfterUse errorcode.
  • PSR12.Traits.UseDeclaration will now report on issues with spacing after the use keyword for multi-line trait use statements.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
    • This change is only breaking for integrators, not for external standards or end-users.
  • Documentation improvement

The `processUseStatement()` method checking single-line trait `use` statements checks the spacing after the `use` keyword, but the error did not have the correct error code.
…lti-line statements

While the `processUseStatement()` method checking single-line trait `use` statements would check the spacing after the `use` keyword, the `processUseGroup()` method checking multi-line trait `use` statements did not execute that same check, while the rule applies to both single- as well as multi-line `use` statements.

By moving the check for the spacing after the `use` keyword to the `process()` method, it will now be executed for both situations.

Tested by adjusting a pre-existing test.
@jrfnl
Copy link
Contributor Author

jrfnl commented Dec 2, 2023

Closing as replaced by PHPCSStandards/PHP_CodeSniffer#75

@jrfnl jrfnl closed this Dec 2, 2023
@jrfnl jrfnl deleted the feature/psr12-trait-use-fix-missing-keyword-spacing-check-multiline branch December 2, 2023 02:29
@jrfnl
Copy link
Contributor Author

jrfnl commented Dec 8, 2023

FYI: this fix is included in today's PHP_CodeSniffer 3.8.0 release.

As per #3932, development on PHP_CodeSniffer will continue in the PHPCSStandards/PHP_CodeSniffer repository. If you want to stay informed, you may want to start "watching" that repo (or watching releases from that repo).

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.

1 participant