WordPress-Extra: demand for exit/die to always use parentheses #2647
+3
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Follow up after PR #2646, pulled separately as the decision point is different.
PHPCSExtra offers two new sniffs to choose from related to whether
exit/diecalls should use parentheses or not.This PR proposes to add one of these rules to WordPress-Extra, with an eye to eventually moving the rule to WordPress-Core after a Make post.
WordPress Core currently contains 395 calls to
exit/die.If we look at the metrics the new sniffs generate, the current state of WordPress-Core is inconsistent, though leans towards only requiring parentheses when parameters are passed:
Having said that, the WordPress Coding Standards handbook already contains the following rule regarding object instantiations, for which parentheses are also optional:
Ref: https://github.com/WordPress/wpcs-docs/blob/master/wordpress-coding-standards/php.md#object-instantiation
In this commit, I propose to add a rule to demand that calls to
exit/diealways use parentheses.Reasoning:
exit/die.👉🏻 Having said this, I can also imagine us holding off on adding this rule to WordPress-Extra and going straight for a Make post to add the rule to WordPress-Core.
This would avoid/prevent confusion if a discussion about this on Make would yield another decision (forbid parentheses except when there are parameters).
In other words, this PR is very much a suggestion, not a definitive proposal, and whether or not we should merge it will depend on people leaving opinions about this topic.
So.... opinions please ?
Suggested changelog entry
WordPress-Extra: the following additional sniffs has been added to the ruleset:Universal.PHP.RequireExitDieParentheses.