Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#49376 closed task (blessed) (fixed)

Adjust coding standards to always omit parenthesis for include/require statements

Reported by: desrosj's profile desrosj Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.4 Priority: low
Severity: trivial Version:
Component: General Keywords: has-patch commit
Focuses: coding-standards Cc:


This is a follow-up of #48082 and the changes committed in [47198].

Now that all parenthesis have been removed from include/include_once/require/require_once statements, the PHCS configuration file should also be updated to enforce this until the sniff is moved from the WordPress-Extra ruleset to the WordPress-Core ruleset upstream in the WordPress Coding Standards repo (pull request coming soon).

Running this sniff on trunk today produces 4 errors, all of them are instances where two spaces are included after return and echo statements instead of one. These instances are all typos and should be fixed.

The PHP coding standards in the handbook should also be updated to reflect that parenthesis should be omitted, and one space and one space only should follow these language constructs to satisfy this check.

Attachments (2)

49376.diff (3.4 KB) - added by desrosj 4 years ago.
49376.2.diff (3.7 KB) - added by desrosj 4 years ago.

Download all attachments as: .zip

Change History (7)

4 years ago

4 years ago

#1 @desrosj
4 years ago

49376.2.diff adds the rules for parenthesis that I missed in the first patch.

#2 @GaryJ
4 years ago

  • Keywords needs-refresh added

The Squiz.WhiteSpace.LanguageConstructSpacing sniff is deprecated and will be removed in PHPCS 4.0.

Consider using Generic.WhiteSpace.LanguageConstructSpacing instead. Though, since this change is intended as a temporary one until WPCS itself changes (which should happen before PHPCS 4.0), leave as is.

Last edited 4 years ago by GaryJ (previous) (diff)

#3 @jrf
4 years ago

  • Keywords commit added; needs-refresh removed


And yes, leave the LanguageContructSpacing one as is. Once it's moved in WPCS (and a new WPCS version released), these rules can be removed and that should be soon enough.
WPCS will then take care of the sniff change-over automatically if and when.

#4 @SergeyBiryukov
4 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 47207:

Coding Standards: Adjust coding standards to always omit parentheses for include/require statements.

These are language constructs, not function calls, so the parentheses are unnecessary.

This updates the PHPCS configuration file the enforce the sniff until it is moved from the WordPress-Extra ruleset to the WordPress-Core ruleset upstream.

Follow-up to [47198].

Props desrosj, jrf, GaryJ.
Fixes #49376.

This ticket was mentioned in Slack in #docs by joyously. View the logs.

4 years ago

Note: See TracTickets for help on using tickets.