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

Core: add sniffs to check the formatting of ::class class resolution #2141

Merged

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Dec 8, 2022

  1. There should be no space between ::class and the preceding class name it applies to.
  2. There should be no space between the double colon and the class keyword.
  3. The class keyword should be in lowercase.

The first two rules are covered via the new WordPress.WhiteSpace.ObjectOperatorSpacing sniff. The last rule via a new sniff from PHPCSExtra.

Refs:

> 1. There should be no space between `::class` and the preceding class name it applies to.
> 2. There should be no space between the double colon and the `class` keyword.
> 3. The `class` keyword should be in lowercase.

The first two rules are covered via the new `WordPress.WhiteSpace.ObjectOperatorSpacing` sniff.
The last rule via a new sniff from PHPCSExtra.

Refs:
* https://make.wordpress.org/core/2020/03/20/updating-the-coding-standards-for-modern-php/ - `::class` constant section
* https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#magic-constants
* WordPress/wpcs-docs 113
* WordPress/WordPress-Coding-Standards 1115
* WordPress/WordPress-Coding-Standards 1116
* WordPress/WordPress-Coding-Standards 2095
* PHPCSStandards/PHPCSExtra 72
Copy link
Member

@GaryJones GaryJones left a comment

Choose a reason for hiding this comment

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

@dingo-d dingo-d merged commit 90e6d49 into WordPress:develop Dec 8, 2022
@jrfnl jrfnl deleted the feature/core-class-resolution-formatting branch December 8, 2022 15:06
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.

3 participants