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: move rules related to object instantiations from Extra to Core #2133

Merged
merged 2 commits into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions WordPress-Core/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,25 @@
<rule ref="Squiz.WhiteSpace.ScopeKeywordSpacing"/>


<!--
#############################################################################
Handbook: Object-Oriented Programming - Object Instantiation.
Ref: https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#object-instantiation
#############################################################################
-->
<!-- Covers rule: When instantiating a new object instance, parenthesis must always be used, even when not strictly necessary. -->
<rule ref="PSR12.Classes.ClassInstantiation"/>
<rule ref="Universal.Classes.RequireAnonClassParentheses"/>

<!-- Covers rule: There should be no space between the name of the class being instantiated and the opening parenthesis. -->
<!-- Covered by the PEAR.Functions.FunctionCallSignature sniff for non-anonymous classes. -->
<rule ref="Universal.WhiteSpace.AnonClassKeywordSpacing">
<properties>
<property name="spacing" value="0"/>
</properties>
</rule>


<!--
#############################################################################
Handbook: Control Structures - Use elseif, not else if.
Expand Down
11 changes: 0 additions & 11 deletions WordPress-Extra/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,6 @@
<!-- Validates post type slugs for valid characters, length and reserved keywords. -->
<rule ref="WordPress.NamingConventions.ValidPostTypeSlug"/>

<!-- Check that object instantiations always have braces & are not assigned by reference.
https://github.com/WordPress/WordPress-Coding-Standards/issues/919
Note: there is a similar upstream sniff `PSR12.Classes.ClassInstantiation`, however
that sniff:
- does not cover JS files;
- does not demand parentheses for PHP anonymous classes;
- does not check the whitespace between the class name and the parentheses;
- does not check for PHP new by reference.
For those reasons, the WPCS version should remain. -->
<rule ref="WordPress.Classes.ClassInstantiation"/>

<!-- https://github.com/WordPress/WordPress-Coding-Standards/issues/1157 -->
<rule ref="WordPress.Security.PluginMenuSlug"/>
<rule ref="WordPress.WP.CronInterval"/>
Expand Down
205 changes: 0 additions & 205 deletions WordPress/Sniffs/Classes/ClassInstantiationSniff.php

This file was deleted.

106 changes: 0 additions & 106 deletions WordPress/Tests/Classes/ClassInstantiationUnitTest.inc

This file was deleted.

Loading