Skip to content

Commit

Permalink
Merge pull request #364 from Yoast/JRF/yoastcs-more-docblock-comment-…
Browse files Browse the repository at this point in the history
…rules

YoastCS: more docblock/comment rules
  • Loading branch information
jrfnl authored Dec 14, 2023
2 parents 89ffdf4 + 5b93977 commit f209bca
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
1 change: 1 addition & 0 deletions Yoast/Reports/Threshold.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* @since 2.2.0
*
* @phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable -- Flags unused params which are required via the interface. Invalid.
* @phpcs:disable SlevomatCodingStandard.TypeHints.DisallowMixedTypeHint.DisallowedMixedTypeHint -- Type is too complex to document properly.
*/
final class Threshold implements Report {

Expand Down
76 changes: 76 additions & 0 deletions Yoast/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,82 @@
SNIFFS RELATED TO COMMENTS AND DOCBLOCKS
#############################################################################
-->
<!-- Undo the WPCS-Docs silencing of the @param tag formatting/alignment and grammar/punctuation rules. -->
<rule ref="Squiz.Commenting.FunctionComment.SpacingAfterParamName">
<severity>5</severity>
</rule>
<rule ref="Squiz.Commenting.FunctionComment.ParamCommentNotCapital">
<severity>5</severity>
</rule>

<!-- Undo the WPCS-Docs silencing of some @return tag related rules. -->
<rule ref="Squiz.Commenting.FunctionComment.MissingReturn">
<severity>5</severity>
</rule>
<rule ref="Squiz.Commenting.FunctionComment.InvalidReturnNotVoid">
<severity>5</severity>
</rule>

<!-- Enforces using shorthand scalar typehint variants. -->
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>

<!-- Enforces null type hint on last position. -->
<rule ref="SlevomatCodingStandard.TypeHints.NullTypeHintOnLastPosition"/>

<!-- Check property type information, but don't enforce native type declarations. -->
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint">
<properties>
<!-- PHP 7.4+. -->
<property name="enableNativeTypeHint" value="false"/>
<!-- PHP 8.0+. -->
<property name="enableMixedTypeHint" value="false"/>
<property name="enableUnionTypeHint" value="false"/>
<!-- PHP 8.1+. -->
<property name="enableIntersectionTypeHint" value="false"/>
<!-- PHP 8.2+. -->
<property name="enableStandaloneNullTrueFalseTypeHints" value="false"/>
</properties>
</rule>

<!-- Check parameter type information, but don't enforce native type declarations. -->
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint">
<properties>
<!-- PHP 8.0+. -->
<property name="enableMixedTypeHint" value="false"/>
<property name="enableUnionTypeHint" value="false"/>
<!-- PHP 8.1+. -->
<property name="enableIntersectionTypeHint" value="false"/>
<!-- PHP 8.2+. -->
<property name="enableStandaloneNullTrueFalseTypeHints" value="false"/>
</properties>

<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint"/>
</rule>

<!-- Check return type information, but don't enforce native type declarations. -->
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
<properties>
<!-- PHP 8.0+. -->
<property name="enableStaticTypeHint" value="false"/>
<property name="enableMixedTypeHint" value="false"/>
<property name="enableUnionTypeHint" value="false"/>
<!-- PHP 8.1+. -->
<property name="enableIntersectionTypeHint" value="false"/>
<property name="enableNeverTypeHint" value="false"/>
<!-- PHP 8.2+. -->
<property name="enableStandaloneNullTrueFalseTypeHints" value="false"/>
</properties>

<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint"/>
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.UselessAnnotation"/>
</rule>

<!-- Disallows usage of "mixed" type hint. -->
<rule ref="SlevomatCodingStandard.TypeHints.DisallowMixedTypeHint">
<!-- Make an exception for the tests as "mixed" is a valid type for testing type validation in code. -->
<exclude-pattern>*/tests/*\.php$</exclude-pattern>
</rule>

<!-- CS: don't allow "// end class" comments and the likes. -->
<rule ref="PSR12.Classes.ClosingBrace"/>

Expand Down

0 comments on commit f209bca

Please sign in to comment.