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

Squiz.WhiteSpace.FunctionSpacing can remove spaces between comment and first/last method during auto-fixing #2657

Merged

Conversation

jrfnl
Copy link
Contributor

@jrfnl jrfnl commented Oct 17, 2019

Similar to #2656

If there would be comments (or commented out code) before the first method or after the last method in an OO structure, the fixer as it was, would - depending on the various $spacing settings, potentially remove the space between the method and the comment which would easily conflict with other comment rules.

By allowing for comments before the first method/after the last method, this is prevented.

The fix now implemented means that if there is anything between the class opener/trait import use and the first method, other than a function docblock/comment, the method will be treated as any method and won't get the special "first method" treatment.
Similarly, when there is anything between the last method and the class closer, other than a trailing comment, the method will be treated as any method and won't get the special "last" method treatment.

Includes unit test.

…ter last

If there would be comments (or commented out code) before the first method or after the last method in an OO structure, the fixer as it was, would - depending on the various `$spacing` settings, potentially remove the space between the method and the comment which would easily conflict with other comment rules.

By allowing for comments before the first method/after the last method, this is prevented.

The fix now implemented means that if there is anything between the class opener/trait import `use` and the first method, other than a function docblock/comment, the method will be treated as any method and won't get the special "first method" treatment.
Similarly, when there is anything between the last method and the class closer, other than a trailing comment, the method will be treated as any method and won't get the special "last" method treatment.

Includes unit test.
@gsherwood gsherwood added this to Idea Bank in PHPCS v3 Development via automation Oct 30, 2019
@gsherwood gsherwood added this to the 3.5.3 milestone Oct 30, 2019
@gsherwood gsherwood modified the milestones: 3.5.3, 3.5.4 Nov 29, 2019
@gsherwood gsherwood changed the title Squiz/FunctionSpacing: improve handling with comments before first/after last Squiz.WhiteSpace.FunctionSpacing can remove spaces between comment and first/last method during auto-fixing Jan 14, 2020
gsherwood added a commit that referenced this pull request Jan 14, 2020
@gsherwood gsherwood merged commit f362965 into squizlabs:master Jan 14, 2020
PHPCS v3 Development automation moved this from Idea Bank to Ready for Release Jan 14, 2020
@gsherwood
Copy link
Member

Thanks

@jrfnl jrfnl deleted the feature/squiz-functionspacing-enhancement branch January 14, 2020 23:01
@jrfnl
Copy link
Contributor Author

jrfnl commented Jan 14, 2020

You're welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
PHPCS v3 Development
Ready for Release
Development

Successfully merging this pull request may close these issues.

None yet

2 participants