1<?xml version="1.0" encoding="UTF-8"?>
2<ruleset name="osu!web Coding Standard">
3 <description>Based on core PSR-2 and PSR-12 rules, with adjustments to accommodate Laravel</description>
4
5 <file>app</file>
6 <file>config</file>
7 <file>database</file>
8 <file>resources</file>
9 <file>routes</file>
10 <file>tests</file>
11
12 <exclude-pattern>*.blade.php</exclude-pattern>
13 <exclude-pattern>.phpstorm.meta.php</exclude-pattern>
14 <exclude-pattern>_ide_helper.php</exclude-pattern>
15 <exclude-pattern>_ide_helper_models.php</exclude-pattern>
16 <exclude-pattern>resources/docs/source/_tmp/*</exclude-pattern>
17 <exclude-pattern>resources/lang/(?!en)[^/]*/.*</exclude-pattern>
18
19 <arg name="basepath" value="."/>
20 <arg name="extensions" value="php"/>
21 <arg name="report" value="code"/>
22 <arg value="npsv"/>
23
24 <rule ref="PSR2"/>
25 <rule ref="PSR12"/>
26
27 <!-- Additional rules to more strictly adhere to PSR-12 -->
28 <rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
29 <rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop"/>
30 <rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall"/>
31 <rule ref="Generic.CodeAnalysis.JumbledIncrementer"/>
32 <rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"/>
33 <rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
34 <rule ref="Generic.PHP.DeprecatedFunctions"/>
35 <rule ref="Generic.PHP.ForbiddenFunctions"/>
36 <rule ref="Generic.PHP.NoSilencedErrors"/>
37 <rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma"/>
38 <rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility">
39 <properties>
40 <property name="fixable" type="boolean" value="true"/>
41 </properties>
42 </rule>
43 <rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/>
44 <rule ref="SlevomatCodingStandard.Commenting.DisallowOneLinePropertyDocComment"/>
45 <rule ref="SlevomatCodingStandard.Commenting.EmptyComment"/>
46 <rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration"/>
47 <rule ref="SlevomatCodingStandard.Commenting.UselessFunctionDocComment"/>
48 <rule ref="SlevomatCodingStandard.ControlStructures.DisallowContinueWithoutIntegerOperandInSwitch"/>
49 <rule ref="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison"/>
50 <rule ref="SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses"/>
51 <rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator"/>
52 <rule ref="SlevomatCodingStandard.Exceptions.DeadCatch"/>
53 <rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
54 <exclude-pattern>database/migrations/*</exclude-pattern>
55 <properties>
56 <property name="rootNamespaces" type="array">
57 <element key="app" value="App"/>
58 <element key="database/factories" value="Database\Factories"/>
59 <element key="database/seeders" value="Database\Seeders"/>
60 <element key="tests" value="Tests"/>
61 </property>
62 </properties>
63 </rule>
64 <rule ref="SlevomatCodingStandard.Functions.NamedArgumentSpacing"/>
65 <rule ref="SlevomatCodingStandard.Functions.StrictCall"/>
66 <rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/>
67 <rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation"/>
68 <rule ref="SlevomatCodingStandard.Namespaces.NamespaceDeclaration"/>
69 <rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
70 <properties>
71 <property name="searchAnnotations" type="boolean" value="true"/>
72 </properties>
73 </rule>
74 <rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash"/>
75 <rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace"/>
76 <rule ref="SlevomatCodingStandard.Namespaces.UseSpacing"/>
77 <rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/>
78 <rule ref="SlevomatCodingStandard.PHP.ShortList"/>
79 <rule ref="SlevomatCodingStandard.PHP.UselessParentheses"/>
80 <rule ref="SlevomatCodingStandard.PHP.UselessSemicolon"/>
81 <rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>
82 <rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/>
83 <rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing"/>
84 <rule ref="SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable"/>
85 <rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
86 <rule ref="Squiz.Classes.ClassFileName">
87 <exclude-pattern>database/migrations/*</exclude-pattern>
88 </rule>
89 <rule ref="Squiz.Classes.LowercaseClassKeywords"/>
90 <rule ref="Squiz.Commenting.DocCommentAlignment"/>
91 <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
92 <properties>
93 <property name="equalsSpacing" value="1"/>
94 </properties>
95 </rule>
96 <rule ref="Squiz.Operators.ValidLogicalOperators"/>
97 <rule ref="Squiz.PHP.DisallowSizeFunctionsInLoops"/>
98 <rule ref="Squiz.PHP.Eval"/>
99 <rule ref="Squiz.PHP.NonExecutableCode"/>
100 <rule ref="Squiz.Scope.MemberVarScope"/>
101 <rule ref="Squiz.Scope.StaticThisUsage"/>
102 <rule ref="Squiz.Strings.ConcatenationSpacing">
103 <properties>
104 <property name="ignoreNewlines" type="boolean" value="true" />
105 </properties>
106 </rule>
107 <rule ref="Squiz.Strings.DoubleQuoteUsage">
108 <exclude name="Squiz.Strings.DoubleQuoteUsage.ContainsVar"/>
109 </rule>
110 <rule ref="Squiz.WhiteSpace.CastSpacing"/>
111 <rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/>
112 <rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
113 <rule ref="Squiz.WhiteSpace.OperatorSpacing">
114 <properties>
115 <property name="ignoreNewlines" type="boolean" value="true" />
116 </properties>
117 </rule>
118 <rule ref="Squiz.WhiteSpace.ScopeClosingBrace"/>
119 <rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
120 <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>
121
122 <!-- Rules we don't care about -->
123
124 <!-- Contradictions with Laravel and/or PSR-12 -->
125 <rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace">
126 <exclude-pattern>database/migrations/*</exclude-pattern>
127 </rule>
128 <rule ref="PSR1.Files.SideEffects">
129 <exclude-pattern>public/index.php</exclude-pattern>
130 </rule>
131 <rule ref="PSR2.ControlStructures.ControlStructureSpacing.SpacingAfterOpenBrace">
132 <severity>0</severity>
133 </rule>
134 <rule ref="PSR12.Operators.OperatorSpacing.NoSpaceAfter">
135 <severity>0</severity>
136 </rule>
137 <rule ref="PSR12.Operators.OperatorSpacing.NoSpaceBefore">
138 <severity>0</severity>
139 </rule>
140 <rule ref="PSR12.Traits.UseDeclaration.MultipleImport">
141 <type>warning</type>
142 </rule>
143 <rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference.ClassNameReferencedViaFunctionCall">
144 <type>warning</type>
145 </rule>
146
147 <!-- To silence complaints about phpdoc docblock/comments -->
148 <rule ref="SlevomatCodingStandard.Commenting.DisallowOneLinePropertyDocComment.OneLinePropertyComment">
149 <type>warning</type>
150 </rule>
151 <rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation.NonFullyQualifiedClassName">
152 <type>warning</type>
153 </rule>
154
155 <!-- Rules to revisit later -->
156
157 <!-- Almost none of our constants have visibility defined yet and explicitly defining them as public to fix this (which they implicitly are) would be misleading -->
158 <rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility.MissingConstantVisibility">
159 <type>warning</type>
160 </rule>
161</ruleset>