Skip to content

Commit

Permalink
Merge pull request #2133 from WordPress/feature/core-move-object-inst…
Browse files Browse the repository at this point in the history
…antiation-rules

Core: move rules related to object instantiations from Extra to Core
  • Loading branch information
dingo-d authored Dec 8, 2022
2 parents acbca75 + 47d93c0 commit 2880e5b
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 523 deletions.
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

0 comments on commit 2880e5b

Please sign in to comment.