Skip to content

Squiz/FunctionSpacing: fix regression - only look at first docblock #946

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

Merged

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Apr 8, 2025

Description

To determine whether there are the correct number of lines before the function declaration, the sniff skips over attributes and docblocks to find the first bit of code which doesn't belong with the function declaration.

While the change in PR #826 improved this for attributes before the docblock, it didn't take multiple docblocks into account and would skip over more than just the first docblock.

Fixed now.

Includes tests.

Suggested changelog entry

Fixed: Squiz.WhiteSpace.FunctionSpacing would get confused when there are two docblocks above a function declaration.

Related issues/external references

Fixes #826

Fixes #945
Closes #938

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

To determine whether there are the correct number of lines before the function declaration, the sniff skips over attributes and docblocks to find the first bit of code which doesn't belong with the function declaration.

While the change in PR 826 improved this for attributes _before_ the docblock, it didn't take multiple docblocks into account and would skip over more than just the first docblock.

Fixed now.

Includes tests.
Copy link
Contributor

@rodrigoprimo rodrigoprimo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I just left a comment with a small suggestion.

@jrfnl jrfnl merged commit 06833c6 into master Apr 13, 2025
61 checks passed
@jrfnl jrfnl deleted the feature/945-squiz-functionspacing-bug-fix-double-docblock branch April 13, 2025 00:55
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.

New warning about function spacing since version 3.12.0
2 participants