Repository navigation
Expand file tree
/
Copy pathpsr12.neon
More file actions
164 lines (150 loc) · 5.89 KB
/
Copy pathpsr12.neon
File metadata and controls
164 lines (150 loc) · 5.89 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# PSR-12 Extended Coding Style
#
# PSR-12, section by section; the specification defines the style and this preset adds nothing of its own.
severity:
file.longLines: warning # what nothing could spread only warns, the limit being soft
file:
bom: forbidden
openingTag: required # `<?php`, not `<?` or `<?PHP`
strictTypes:
position: nextLine # §3, `<?php` on a line of its own
closingTagAtEnd: forbidden # a `?>` before HTML stays
lineEnding: majority # as most lines of the file, LF on a tie
finalLineEndings: 1
trailingWhitespace: forbidden # the text of a string stays
lineLength: 120 # what is wider is spread
longLines: forbidden
statementsPerLine: 1 # `foo(); bar();` takes two lines
indentation:
unit: '4 spaces'
binaryOperator: 0 # `&& $b` right below `$a`, a level deeper after `$x =` or `return`
ternary: 1 # `?` and `:` opening a line
switchCase: 1 # `case` inside `switch`
chain: flat # every link one level below the start of the chain
commentLines: aligned
# names are reported, never renamed
naming:
class: PascalCase
method: camelCase # `__construct()` passes
constant: UPPER_CASE
casing:
keyword: lowercase # `self`, `parent` too
trueFalseNull: lowercase
type: lowercase # `int`, `string`, `void`
imports:
leadingBackslash: forbidden # `use Foo\Bar;`, not `use \Foo\Bar;`
order:
kinds: [class, function, constant] # the names of a kind in the order written
spacing:
declare: 'declare(strict_types=1)'
call: 'foo($a, $b)' # `function foo($a)` too
padding: # `foo($a)`, `if ($a)`, `($a + $b)`
argument: forbidden
parameter: forbidden
closureUse: forbidden
controlStructure: forbidden
grouping: forbidden
keyword: 'return $x' # `if (`, `} else {`, `new`, `class Foo extends Bar` too
openBrace: 'if ($a) {'
alternativeSyntax: 'if ($a):'
body: 'function () { return 1; }'
import: 'use Acme\{Foo, Bar};'
comma: '$a, $b'
alignment:
comma: forbidden # no extra spaces after a comma
cast: '(int) $x'
reference: '&$x'
spread: '...$x'
unaryOperator: '-$x' # `++$i` too
logicalNot: ['!$x', '! $x'] # `! $x` may stay
binaryOperator: '$a + $b' # `=`, `=>`, `instanceof` too
concatenation: '$a . $b'
ternary: '$a ? $b : $c' # `$a ?: $b` too
anonymousClass: 'new class ($a)'
anonymousFunction: 'function ($x)'
typeDeclaration: '?int $x' # `): int` too
catchType: 'catch (A | B $e)'
switchCase: 'case 1:'
multiline:
items:
argument: perLine # an argument per line once spread
parameter: perLine # a parameter per line once spread or too wide
for: perLine # a section of `for` per line
implements: perLine # an interface per line below `implements`
matchCondition: perLine # a condition of a `match` arm per line, `=>` after the last
# the parts of a condition and the operands as their author spread them, a line each where too wide
condition: [perLine, fill]
logical: [perLine, fill]
concatenation: [perLine, fill]
arithmetic: [perLine, fill]
bitwise: [perLine, fill]
edges:
argument: apart # `foo(` above the arguments, `)` below them
parameter: apart
implements: apart
condition: apart # `if (` above `$a`, `) {` below the last part
operatorPosition: # `+ $b` opens the line, not ends the one before
operators: lineStart
concatenation: keep
ternary: keep
braces:
position:
class: nextLine
function: nextLine # one with parameters on one line
multilineSignature: sameLine # `) {` on a line of their own
closure: sameLine
anonymousClass: sameLine
controlStructure: sameLine
continuingKeyword: sameLine # `} else {`
emptyBody: # not `{}`
class: expanded
function: expanded
closure: expanded
propertyHook: expanded
bracelessBody: forbidden # `if ($a) foo();` gets braces
singlelineClosure: forbidden # `function () { return 1; }` is spread
blankLines:
afterOpeningTag: 1
afterDeclare: 1
beforeNamespace: 1
afterNamespace: 1
afterImports: 1
beforeDeclaration: 1
betweenImports: 0
betweenImportKinds: 1
beforeOpenBrace:
class: 0 # §4.1: no blank line between the head and `{` below it
bodyStart:
class: 0
anonymousClass: 0
controlStructure: 0 # §5: the body on the next line after `{`
bodyEnd:
class: 0
anonymousClass: 0
function: 0 # §4.4, §7: `}` on the next line following the body
closure: 0
controlStructure: 0 # §5
branch: 0
betweenTraitUses: 0
afterTraitUses: 1
classes:
visibility: required # `var` is `public`; interface methods and set visibility too
modifiers:
order: canonical # `final public static`
members:
order: [traitUse]
grouping: # `public $a, $b;` is split
property: separated
traitUse: separated
emptyParentheses:
instantiation: required # `new Foo()`
controlFlow:
elseif: 'elseif' # not `else if`
switch:
fallThroughComment: no break # the comment of a fall-through
emptyStatement: forbidden # `foo();;`
expressions:
cast: canonical # `(int)`, not `(integer)` or `( int )`
upgrading:
php:
caseSemicolon: forbidden # `case 1:`, not `case 1;`