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

YoastCS: more docblock/comment rules #364

Merged
merged 9 commits into from
Dec 14, 2023
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