-
-
Notifications
You must be signed in to change notification settings - Fork 86
Expand file tree
/
Copy pathcoding-standards.xml
More file actions
108 lines (75 loc) · 5.61 KB
/
Copy pathcoding-standards.xml
File metadata and controls
108 lines (75 loc) · 5.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?xml version="1.0"?>
<!-- in command line, use -s to find out what rule was applied for each error -->
<ruleset name="zebra">
<description>Coding standards</description>
<file>Zebra_Session.php</file>
<!-- the test suite is held to the same standard as the library -->
<file>tests</file>
<!-- written by the tests as they run, or not ours to begin with -->
<exclude-pattern>tests/tmp/*</exclude-pattern>
<exclude-pattern>tests/coverage-html/*</exclude-pattern>
<ini name="memory_limit" value="64M"/>
<arg name="report-width" value="130"/>
<rule ref="PSR12">
<!-- Let the Git manage the EOL cross the platforms. -->
<exclude name="Generic.Files.LineEndings.InvalidEOLChar"/>
<!-- Don't warn about lines being too long -->
<exclude name="Generic.Files.LineLength.TooLong"/>
<!-- Allow class names to be written in snake_case -->
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps"/>
<!-- The class is deliberately not in a namespace - putting it in one is a major version's work -->
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace"/>
<!-- Don't force braces being on the same line as the function's declaration -->
<exclude name="PSR2.Classes.ClassDeclaration.OpenBraceNewLine" />
<exclude name="Squiz.Classes.ClassDeclaration.OpenBraceNewLine" />
<exclude name="PEAR.Functions.FunctionDeclaration.BraceOnSameLine" />
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine" />
<!-- Allow method names to be written in snake_case -->
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps" />
<!-- Allow blank line before the closing brace of a class -->
<exclude name="PSR2.Classes.ClassDeclaration.CloseBraceAfterBody" />
<!-- Allow blank line after the CASE and DEFAULT keywords -->
<exclude name="PSR2.ControlStructures.SwitchDeclaration.BodyOnNextLineCASE" />
<exclude name="PSR2.ControlStructures.SwitchDeclaration.BodyOnNextLineDEFAULT" />
<!-- I write queries as multiline but the first thing after the opening parenthesis is the opening quote -->
<exclude name="PSR2.Methods.FunctionCallSignature.ContentAfterOpenBracket" />
<!-- Allow blank line before the closing brace of a function -->
<exclude name="PSR2.Methods.FunctionClosingBrace.SpacingBeforeClose" />
<!-- Allow private methods to have underscore as their name's first character -->
<exclude name="PSR2.Methods.MethodDeclaration.Underscore" />
<!-- Allow blank line after the opening brace of a class -->
<exclude name="PSR12.Classes.OpeningBraceSpace.Found" />
<!-- In multi-line control structures, the first expression can be on the next line -->
<exclude name="PSR12.ControlStructures.ControlStructureSpacing.FirstExpressionLine" />
<!-- In multi-line control structures, the parenthesis after the last expression can be on the next line -->
<exclude name="PSR12.ControlStructures.ControlStructureSpacing.CloseParenthesisLine" />
<!-- Allow blank lines at the start/end of control structures -->
<exclude name="Squiz.WhiteSpace.ControlStructureSpacing.SpacingAfterOpen" />
<exclude name="Squiz.WhiteSpace.ControlStructureSpacing.SpacingBeforeClose" />
<!-- Single statement bodies are written without braces throughout this library - "if (!$this->_connected()) return false" -->
<exclude name="Generic.ControlStructures.InlineControlStructure"/>
<!-- Covered by the FunctionKeywordSpacing rule below, which allows the space on a named declaration
and forbids it on a closure. Both codes are named because the Squiz sniff extends the PEAR one. -->
<exclude name="PEAR.Functions.FunctionDeclaration.SpaceAfterFunction" />
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.SpaceAfterFunction" />
<!-- A closure short enough to sit on one line is written on one line - "function($value) { return $value; }".
The Kernighan/Ritchie rule below still checks named declarations, its checkClosures property being off. -->
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.ContentAfterBrace" />
<exclude name="Squiz.WhiteSpace.ScopeClosingBrace.ContentBefore" />
<!-- Covered by the ClosureAwareMultipleStatements rule below, which allows the statement inside a one line closure -->
<exclude name="Generic.Formatting.DisallowMultipleStatements" />
</rule>
<!-- One space after the "function" keyword when a name follows it, none when it does not - so
"function get_tables($database)" and "function($value) { ... }" are both correct. -->
<rule ref="tests/standards/Zebra/Sniffs/Functions/FunctionKeywordSpacingSniff.php" />
<!-- Each statement on a line by itself, except inside a closure - so "array_map(function($row) { return
$row['id']; }, $rows)" is fine while "$a = 1; $b = 2;" is still reported. -->
<rule ref="tests/standards/Zebra/Sniffs/Formatting/ClosureAwareMultipleStatementsSniff.php" />
<!-- Function declarations follow the "Kernighan/Ritchie style". The function brace is on the same line as the
function declaration. One space is required between the closing parenthesis and the brace. -->
<rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie" />
<!-- Every test file declares a class and includes the bootstrap beside it, which this sniff counts as a side effect -->
<rule ref="PSR1.Files.SideEffects">
<exclude-pattern>tests/*</exclude-pattern>
</rule>
</ruleset>