Skip to content

Commit 2c91445

Browse files
authored
Merge pull request #1587 from WordPress-Coding-Standards/feature/add-some-dev-documentation
Extra: Document why two WPCS native sniffs are not (yet) replaced
2 parents 54fced5 + 366b8fb commit 2c91445

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

WordPress-Extra/ruleset.xml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
</rule>
2828

2929
<!-- Duplicate of upstream. Can be removed once minimum PHPCS requirement has gone up.
30-
https://github.com/squizlabs/PHP_CodeSniffer/pull/1594 -->
30+
https://github.com/squizlabs/PHP_CodeSniffer/pull/1594
31+
Note: the "assignment in ternary" part of the sniff is currently not yet covered in
32+
the upstream version. This needs to be pulled first before we can defer to upstream. -->
3133
<rule ref="WordPress.CodeAnalysis.AssignmentInCondition"/>
3234

3335
<!-- More generic PHP best practices.
@@ -145,7 +147,14 @@
145147
<rule ref="WordPress.NamingConventions.PrefixAllGlobals"/>
146148

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

151160
<!-- https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1157 -->

0 commit comments

Comments
 (0)