Skip to content

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Nov 11, 2023

Description

Recreation of upstream PR squizlabs/PHP_CodeSniffer#3856:

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

jrfnl added 2 commits December 5, 2023 19:13
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 jrfnl force-pushed the feature/psr12-trait-use-fix-missing-keyword-spacing-check-multiline branch from 0efbab8 to 5e282de Compare December 5, 2023 18:14
@jrfnl jrfnl merged commit 76ebdef into master Dec 5, 2023
@jrfnl jrfnl deleted the feature/psr12-trait-use-fix-missing-keyword-spacing-check-multiline branch December 5, 2023 19:19
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