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

Function closing brace #110

Merged
merged 1 commit into from
Aug 26, 2022
Merged

Function closing brace #110

merged 1 commit into from
Aug 26, 2022

Conversation

dingo-d
Copy link
Member

@dingo-d dingo-d commented Aug 20, 2022

This PR depends on #109. Once that is merged, this PR should be rebased to the master branch.

The PR adds rules about the function closing brace and is the continuation of the additions of 'modern' PHP code in the WordPress PHP Coding Standards handbook based on the make post by Juliette Reinders Folmer.

Copy link
Member

@jrfnl jrfnl left a comment

Choose a reason for hiding this comment

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

I wonder if this should have an explicit separate section or if we could add this to one of the pre-existing sections.

Looking at the pre-existing sections, there are a couple of potential places where this could be added:

  • Space usage - though feels a bit odd as it would be the only one regarding blank lines.
  • Remove Trailing Spaces - in this case, it's a about trailing new lines, but not necessarily a bad match.
  • Brace style - doesn't feel right as the section is more about control structures with optional braces, while this rule is about function declarations. Adding it there could give the impression that the rule is not just about function declarations.

So, "Remove trailing spaces" seems the most appropriate one.

An extra paragraph there stating "there should be no trailing blank lines at the end of a function body" should suffice IMO.

I also think we can leave out the code sample as it's pretty clear what that means.

@dingo-d dingo-d marked this pull request as ready for review August 26, 2022 08:25
@dingo-d dingo-d force-pushed the function-closing-brace branch 2 times, most recently from b650342 to da9ba4f Compare August 26, 2022 12:18
@dingo-d dingo-d force-pushed the function-closing-brace branch from f4387fa to 46560be Compare August 26, 2022 12:58
@dingo-d dingo-d requested a review from jrfnl August 26, 2022 13:32
Copy link
Member

@jrfnl jrfnl left a comment

Choose a reason for hiding this comment

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

LGTM

Merging this now as @GaryJones is AFK for the next few weeks. If needs be, additional textual tweaks can still be made in a follow up commit.

@jrfnl jrfnl merged commit 0e15330 into master Aug 26, 2022
@jrfnl jrfnl deleted the function-closing-brace branch August 26, 2022 22:56
jrfnl added a commit to WordPress/WordPress-Coding-Standards that referenced this pull request Oct 28, 2022
…ose brace

> 1. There should be no blank line between the content of a function and the function’s closing brace.

Includes removing this rule from the WPCS native ruleset in which we already enforced it (as it will now be inherited from the `WordPress` ruleset).

Refs:
* https://make.wordpress.org/core/2020/03/20/updating-the-coding-standards-for-modern-php/ - Function closing brace section
* https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#remove-trailing-spaces
* WordPress/wpcs-docs#110

Loosely related to #1101
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.

2 participants