Skip to content

Commit 289ffb1

Browse files
committed
chore: overhaul the standard's ruleset to enable/disable specific sniffs
Enable and disable specific phpcs internal standards sniffs.
1 parent e1efcdf commit 289ffb1

File tree

1 file changed

+60
-37
lines changed

1 file changed

+60
-37
lines changed

yCodeTech/ruleset.xml

Lines changed: 60 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,17 @@
1515
* *
1616
* ********************************************** *
1717
* *
18-
* This standard enforces the following rules: *
18+
* This standard enforces the following rules: *
1919
* *
20-
* - Use `bool` type name instead of `boolean` in both *
21-
* docblocks and PHP type declarations. *
20+
* - Use `bool` and `int` type names instead of `boolean` *
21+
* and `integer` in all code contexts. *
2222
* *
23-
* - Use `int` type name instead of `integer` in both *
24-
* docblocks and PHP type declarations. *
23+
* - Require 1 single empty line before `@return` tag. *
2524
* *
26-
* - Require 1 single empty line before `@return` tag. *
25+
* - Require 1 single space between all @-tags' elements *
26+
* (type, variable, etc.). *
2727
* *
28-
* - Require 1 single space between each all @-tags' *
29-
* elements (type, variable, etc.). *
30-
* *
31-
* - Require a `@return` tag except when the return type is *
28+
* - Require a `@return` tag except when the return type is *
3229
* `void`. *
3330
* *
3431
****************************************************************
@@ -42,39 +39,65 @@
4239
<!-- Show sniff codes -->
4340
<arg value="s"/>
4441

42+
<!-- yCodeTech sniffs are included by default, so no need to include them here. -->
4543

46-
<!-- Include base PSR-12 standard but exclude some rules -->
47-
<rule ref="PSR12">
48-
<!-- Disable namespace requirement -->
49-
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace"/>
50-
<!-- Disable PSR12's type casts short names sniff, as we'll use our own implementation. -->
51-
<exclude name="PSR12.Keywords.ShortFormTypeKeywords"/>
52-
53-
<!-- Disable Squiz's space after close brace sniff. Allows newlines in between if...else braces. -->
54-
<exclude name="Squiz.ControlStructures.ControlSignature.SpaceAfterCloseBrace"></exclude>
55-
<!-- Disable Generic's line endings sniff. Allows different EOL characters. -->
56-
<exclude name="Generic.Files.LineEndings.InvalidEOLChar"></exclude>
57-
<!-- Disable PSR2's end file newline sniff. -->
58-
<exclude name="PSR2.Files.EndFileNewline.NoneFound"></exclude>
44+
<!-- Cherrypick sniffs from other standards. -->
5945

60-
</rule>
61-
62-
<!-- Docblock formatting -->
46+
<!-- Include Generic Docblock sniff, and exclude specific violations. -->
6347
<rule ref="Generic.Commenting.DocComment">
48+
<!-- This is disabled because the indentation/spacing is fixed the yCodeTech standard. -->
6449
<exclude name="Generic.Commenting.DocComment.TagValueIndent"/>
50+
51+
<!-- This is disabled because the it might interfere with yCodeTech's @return new line rules. So at the moment all non-param tags can be grouped with @param, but this may change in the future. -->
6552
<exclude name="Generic.Commenting.DocComment.NonParamGroup"/>
53+
54+
<!-- Allow other @tags to be first in a docblock. -->
55+
<exclude name="Generic.Commenting.DocComment.ParamNotFirst"/>
56+
</rule>
57+
58+
<!-- Line endings must be CRLF (\r\n) -->
59+
<rule ref="Generic.Files.LineEndings">
60+
<properties>
61+
<property name="eolChar" value="\r\n" />
62+
</properties>
6663
</rule>
6764

68-
<!-- Type hints -->
65+
<!-- Type hints must be lowercase. -->
6966
<rule ref="Generic.PHP.LowerCaseType"/>
70-
71-
<!-- Custom yCodeTech sniffs -->
72-
<!-- Disallow long type names in both docblocks and PHP type declarations -->
73-
<rule ref="yCodeTech.Types.DisallowTypeLongNames"/>
74-
75-
<!-- Docblock formatting and spacing rules -->
76-
<rule ref="yCodeTech.Commenting.DocblockFormat"/>
77-
78-
<!-- Function comment requirements -->
79-
<rule ref="yCodeTech.Commenting.FunctionComment"/>
67+
68+
<!-- Keywords must be lowercase. -->
69+
<rule ref="Generic.PHP.LowerCaseKeyword"/>
70+
71+
<!-- `true`, `false` and `null` constants must always be lowercase. -->
72+
<rule ref="Generic.PHP.LowerCaseConstant"/>
73+
74+
<!-- The code should use valid PHP syntax (ie. missing semicolons, etc.). -->
75+
<rule ref="Generic.PHP.Syntax"/>
76+
77+
<!-- No superfluous (unnecessary) whitespace is allowed. -->
78+
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>
79+
80+
<!-- Duplicate return tags are not allowed. -->
81+
<rule ref="Squiz.Commenting.FunctionComment.DuplicateReturn"/>
82+
83+
<!-- The type in the @return tag is missing. -->
84+
<rule ref="Squiz.Commenting.FunctionComment.MissingReturnType"/>
85+
86+
<!-- Exception type missing for @throws tag. -->
87+
<rule ref="Squiz.Commenting.FunctionComment.InvalidThrows"/>
88+
89+
<!-- Parameter type missing for @param tag. -->
90+
<rule ref="Squiz.Commenting.FunctionComment.MissingParamType"/>
91+
92+
<!-- Parameter name (variable) missing for @param tag. -->
93+
<rule ref="Squiz.Commenting.FunctionComment.MissingParamName"/>
94+
95+
<!-- @param name casing must match the variable name casing. -->
96+
<rule ref="Squiz.Commenting.FunctionComment.ParamNameNoCaseMatch"/>
97+
98+
<!-- @param comments must start with a capital letter. -->
99+
<rule ref="Squiz.Commenting.FunctionComment.ParamCommentNotCapital"/>
100+
101+
<!-- @param tag missing for the function parameter. -->
102+
<rule ref="Squiz.Commenting.FunctionComment.MissingParamTag"/>
80103
</ruleset>

0 commit comments

Comments
 (0)