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

Generic/OpeningFunctionBraceKernighanRitchie: fix error position #82

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Nov 11, 2023

Description

Recreation of upstream PR squizlabs/PHP_CodeSniffer#3871:

The SpaceBeforeBrace error code is about the space before the scope opener, but was being thrown on the parenthesis closer preceding it, which could be confusing when there is a type declaration between the two.

Fixed now.

I haven't added a test as no meaningful test can be added as the error "column" is not part of the test logic.

To see the issue run the following command over the below code snippet:

phpcs test.php --standard=Generic --sniffs=Generic.Functions.OpeningFunctionBraceKernighanRitchie --report=code
function foo( $param_a, $param_b ): Type       {}
//                       The space here   ^   was originally flagged on the close parens, not the open brace.

Suggested changelog entry

N/A

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 `SpaceBeforeBrace` error code is about the space before the scope opener, but was being thrown on the parenthesis closer preceding it, which could be confusing when there is a type declaration between the two.

Fixed now.

I haven't added a test as no meaningful test can be added as the error "column" is not part of the test logic.
@jrfnl jrfnl force-pushed the feature/generic-openingfunctionbracekernighanritchie-fix-error-position branch from 67f6ecd to 26da214 Compare December 4, 2023 15:19
@jrfnl jrfnl merged commit bc001b0 into master Dec 4, 2023
65 checks passed
@jrfnl jrfnl deleted the feature/generic-openingfunctionbracekernighanritchie-fix-error-position branch December 4, 2023 15:34
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