-
Notifications
You must be signed in to change notification settings - Fork 83
Allow short ternary (Elvis) operator in codebase #2436
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
base: trunk
Are you sure you want to change the base?
Conversation
Removes all inline phpcs ignore comments for the Universal.Operators.DisallowShortTernary rule and updates phpcs.xml to exclude this rule, permitting use of the short ternary (Elvis) operator throughout the codebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enables the use of short ternary operators (Elvis operator ?:) in the codebase by excluding the Universal.Operators.DisallowShortTernary PHPCS rule and removing all the phpcs:ignore comments that were previously needed to suppress warnings for this pattern.
Key Changes:
- Updated PHPCS configuration to allow short ternary operators
- Removed 11
phpcs:ignorecomments across 8 files where the Elvis operator is used
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| phpcs.xml | Added rule exclusion for Universal.Operators.DisallowShortTernary to allow Elvis operator usage |
| integration/class-wp-rest-cache.php | Removed phpcs:ignore comment for Elvis operator in comment type validation |
| integration/class-classic-editor.php | Removed phpcs:ignore comment for Elvis operator when setting default quote interaction policy |
| includes/transformer/class-post.php | Removed phpcs:ignore comment for Elvis operator when retrieving post content template |
| includes/model/class-user.php | Removed phpcs:ignore comment for Elvis operator when getting also known as values |
| includes/collection/class-inbox.php | Removed two phpcs:ignore comments for Elvis operators used in title retrieval |
| includes/class-move.php | Removed phpcs:ignore comment for Elvis operator when updating also known as values |
| includes/class-moderation.php | Removed four phpcs:ignore comments for Elvis operators in user block management |
| includes/class-avatars.php | Removed phpcs:ignore comment for Elvis operator in comment type validation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Deleted redundant 'phpcs:ignore Universal.Operators.DisallowShortTernary.Found' comments from multiple files after excluding the rule in phpcs.xml. This cleans up the code and maintains consistency with the project's coding standards configuration.
|
@obenland btw. is the short-ternary operator allowed on WP.com? |
|
It is not allowed on WP.com, so we have to keep it as is. |
We could add an exception for the activitypub plugin folder in the global phpcs.xml on Dotcom. There's precedent. |
- Consolidate duplicate WordPress ruleset references into single block with exclusion - Remove standalone PHPCompatibility rule (included in PHPCompatibilityWP) - Reorganize config values for better readability
Removes all inline phpcs ignore comments for the Universal.Operators.DisallowShortTernary rule and updates phpcs.xml to exclude this rule, permitting use of the short ternary (Elvis) operator throughout the codebase.
Proposed changes:
phpcs:ignorecomments across 8 files where the Elvis operator is usedOther information:
Testing instructions:
Changelog entry
Changelog Entry Details
Significance
Type
Message