Skip to content

Commit d01b449

Browse files
committed
README splitted to more files
1 parent 6d08d34 commit d01b449

17 files changed

+1550
-1386
lines changed

README.md

+157-1,386
Large diffs are not rendered by default.

doc/arrays.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
## Arrays
2+
3+
#### SlevomatCodingStandard.Arrays.DisallowImplicitArrayCreation
4+
5+
Disallows implicit array creation.
6+
7+
#### SlevomatCodingStandard.Arrays.MultiLineArrayEndBracketPlacement 🔧
8+
9+
Enforces reasonable end bracket placement for multi-line arrays.
10+
11+
#### SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace 🔧
12+
13+
Checks whitespace in single line array declarations (whitespace between brackets, around commas, ...).
14+
15+
Sniff provides the following settings:
16+
17+
* `spacesAroundBrackets`: number of spaces you require to have around array brackets
18+
* `enableEmptyArrayCheck` (defaults to `false`): enables check for empty arrays
19+
20+
#### SlevomatCodingStandard.Arrays.TrailingArrayComma 🔧
21+
22+
Commas after last element in an array make adding a new element easier and result in a cleaner versioning diff.
23+
24+
This sniff enforces trailing commas in multi-line arrays and requires short array syntax `[]`.
25+
26+
Sniff provides the following settings:
27+
28+
* `enableAfterHeredoc`: enables/disables trailing commas after HEREDOC/NOWDOC, default based on PHP version.
29+
30+

doc/attributes.md

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
## Attributes
2+
3+
#### SlevomatCodingStandard.Attributes.AttributeAndTargetSpacing 🔧
4+
5+
Checks lines count between attribute and its target (or target's documentation comment).
6+
7+
Sniff provides the following settings:
8+
9+
* `linesCount`: lines count between attribute and its target
10+
11+
#### SlevomatCodingStandard.Attributes.AttributesOrder 🔧
12+
13+
Requires order of attributes. When more attributes are in one `#[]`, eg. `#[One, Two]`, the first attribute name is used to resolve the order.
14+
15+
Sniff provides the following settings:
16+
17+
* `order`: required order of attributes. Supports prefixes, eg. `ORM\`.
18+
19+
```xml
20+
<rule ref="SlevomatCodingStandard.Attributes.AttributesOrder">
21+
<properties>
22+
<property name="order" type="array">
23+
<element value="ORM\Table"/>
24+
<element value="ORM\"/>
25+
<element value="One"/>
26+
<element value="Two"/>
27+
</property>
28+
</properties>
29+
</rule>
30+
```
31+
32+
#### SlevomatCodingStandard.Attributes.DisallowAttributeJoining 🔧
33+
34+
Requires that only one attribute can be placed inside `#[]` (no comma-separated list). In case of more attributes applied, they are split into individual `#[]` blocks.
35+
36+
#### SlevomatCodingStandard.Attributes.RequireAttributeAfterDocComment 🔧
37+
38+
Requires that attributes are always after documentation comment.
39+

doc/classes.md

+260
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,260 @@
1+
## Classes
2+
3+
#### SlevomatCodingStandard.Classes.BackedEnumTypeSpacing 🔧
4+
5+
* Checks number of spaces before `:` and before type.
6+
7+
Sniff provides the following settings:
8+
9+
* `spacesCountBeforeColon`: the number of spaces before `:`.
10+
* `spacesCountBeforeType`: the number of spaces before type.
11+
12+
#### SlevomatCodingStandard.Classes.ClassLength
13+
14+
Disallows long classes. This sniff provides the following settings:
15+
16+
* `includeComments`: should comments be included in the count (default value is false).
17+
* `includeWhitespace`: should empty lines be included in the count (default value is false).
18+
* `maxLinesLength`: specifies max allowed function lines length (default value is 250).
19+
20+
#### SlevomatCodingStandard.Classes.ClassConstantVisibility 🔧
21+
22+
In PHP 7.1+ it's possible to declare [visibility of class constants](https://wiki.php.net/rfc/class_const_visibility). In a similar vein to optional declaration of visibility for properties and methods which is actually required in sane coding standards, this sniff also requires declaring visibility for all class constants.
23+
24+
Sniff provides the following settings:
25+
26+
* `fixable`: the sniff is not fixable by default because we think it's better to decide about each constant one by one, however you can enable fixability with this option.
27+
28+
```php
29+
const FOO = 1; // visibility missing!
30+
public const BAR = 2; // correct
31+
```
32+
33+
#### SlevomatCodingStandard.Classes.ClassMemberSpacing 🔧
34+
35+
Checks lines count between different class members, eg. between last property and first method.
36+
37+
Sniff provides the following settings:
38+
39+
* `linesCountBetweenMembers`: lines count between different class members
40+
41+
#### SlevomatCodingStandard.Classes.ClassStructure 🔧
42+
43+
Checks that class/trait/interface members are in the correct order.
44+
45+
Sniff provides the following settings:
46+
47+
* `groups`: order of groups. Use multiple groups in one `<element value="">` to not differentiate among them. You can use specific groups or shortcuts.
48+
49+
**List of supported groups**:
50+
uses,
51+
enum cases,
52+
public constants, protected constants, private constants,
53+
public properties, public static properties, protected properties, protected static properties, private properties, private static properties,
54+
constructor, static constructors, destructor, magic methods,
55+
public methods, protected methods, private methods,
56+
public final methods, public static final methods, protected final methods, protected static final methods,
57+
public abstract methods, public static abstract methods, protected abstract methods, protected static abstract methods,
58+
public static methods, protected static methods, private static methods,
59+
private methods
60+
61+
**List of supported shortcuts**:
62+
constants, properties, static properties, methods, all public methods, all protected methods, all private methods, static methods, final methods, abstract methods
63+
64+
```xml
65+
<rule ref="SlevomatCodingStandard.Classes.ClassStructure">
66+
<properties>
67+
<property name="groups" type="array">
68+
<element value="uses"/>
69+
70+
<element value="enum cases"/>
71+
72+
<!-- Public constants are first but you don't care about the order of protected or private constants -->
73+
<element value="public constants"/>
74+
<element value="constants"/>
75+
76+
<!-- You don't care about the order among the properties. The same can be done with "properties" shortcut -->
77+
<element value="public properties, protected properties, private properties"/>
78+
79+
<!-- Constructor is first, then all public methods, then protected/private methods and magic methods are last -->
80+
<element value="constructor"/>
81+
<element value="all public methods"/>
82+
<element value="methods"/>
83+
<element value="magic methods"/>
84+
</property>
85+
</properties>
86+
</rule>
87+
```
88+
89+
#### SlevomatCodingStandard.Classes.ConstantSpacing 🔧
90+
91+
Checks that there is a certain number of blank lines between constants.
92+
93+
Sniff provides the following settings:
94+
95+
* `minLinesCountBeforeWithComment`: minimum number of lines before constant with a documentation comment or attribute
96+
* `maxLinesCountBeforeWithComment`: maximum number of lines before constant with a documentation comment or attribute
97+
* `minLinesCountBeforeWithoutComment`: minimum number of lines before constant without a documentation comment or attribute
98+
* `maxLinesCountBeforeWithoutComment`: maximum number of lines before constant without a documentation comment or attribute
99+
100+
#### SlevomatCodingStandard.Classes.DisallowConstructorPropertyPromotion
101+
102+
Disallows usage of constructor property promotion.
103+
104+
#### SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants 🔧
105+
106+
Disallows late static binding for constants.
107+
108+
#### SlevomatCodingStandard.Classes.DisallowMultiConstantDefinition 🔧
109+
110+
Disallows multi constant definition.
111+
112+
#### SlevomatCodingStandard.Classes.DisallowMultiPropertyDefinition 🔧
113+
114+
Disallows multi property definition.
115+
116+
#### SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces 🔧
117+
118+
Enforces one configurable number of lines after opening class/interface/trait brace and one empty line before the closing brace.
119+
120+
Sniff provides the following settings:
121+
122+
* `linesCountAfterOpeningBrace`: allows to configure the number of lines after opening brace.
123+
* `linesCountBeforeClosingBrace`: allows to configure the number of lines before closing brace.
124+
125+
#### SlevomatCodingStandard.Classes.ForbiddenPublicProperty
126+
127+
Disallows using public properties.
128+
129+
This sniff provides the following setting:
130+
131+
* `checkPromoted`: will check promoted properties too.
132+
133+
#### SlevomatCodingStandard.Classes.MethodSpacing 🔧
134+
135+
Checks that there is a certain number of blank lines between methods.
136+
137+
Sniff provides the following settings:
138+
139+
* `minLinesCount`: minimum number of blank lines
140+
* `maxLinesCount`: maximum number of blank lines
141+
142+
#### SlevomatCodingStandard.Classes.ModernClassNameReference 🔧
143+
144+
Reports use of `__CLASS__`, `get_parent_class()`, `get_called_class()`, `get_class()` and `get_class($this)`.
145+
Class names should be referenced via `::class` constant when possible.
146+
147+
Sniff provides the following settings:
148+
149+
* `enableOnObjects`: Enable `::class` on all objects. It's on by default if you're on PHP 8.0+
150+
151+
#### SlevomatCodingStandard.Classes.ParentCallSpacing 🔧
152+
153+
Enforces configurable number of lines around parent method call.
154+
155+
Sniff provides the following settings:
156+
157+
* `linesCountBefore`: allows to configure the number of lines before parent call.
158+
* `linesCountBeforeFirst`: allows to configure the number of lines before first parent call.
159+
* `linesCountAfter`: allows to configure the number of lines after parent call.
160+
* `linesCountAfterLast`: allows to configure the number of lines after last parent call.
161+
162+
#### SlevomatCodingStandard.Classes.PropertyDeclaration 🔧
163+
164+
* Checks that there's a single space between a typehint and a property name: `Foo $foo`
165+
* Checks that there's no whitespace between a nullability symbol and a typehint: `?Foo`
166+
* Checks that there's a single space before nullability symbol or a typehint: `private ?Foo` or `private Foo`
167+
* Checks order of modifiers
168+
169+
Sniff provides the following settings:
170+
171+
* `modifiersOrder`: allows to configure order of modifiers.
172+
* `checkPromoted`: will check promoted properties too.
173+
* `enableMultipleSpacesBetweenModifiersCheck`: checks multiple spaces between modifiers.
174+
175+
#### SlevomatCodingStandard.Classes.PropertySpacing 🔧
176+
177+
Checks that there is a certain number of blank lines between properties.
178+
179+
Sniff provides the following settings:
180+
181+
* `minLinesCountBeforeWithComment`: minimum number of lines before property with a documentation comment or attribute
182+
* `maxLinesCountBeforeWithComment`: maximum number of lines before property with a documentation comment or attribute
183+
* `minLinesCountBeforeWithoutComment`: minimum number of lines before property without a documentation comment or attribute
184+
* `maxLinesCountBeforeWithoutComment`: maximum number of lines before property without a documentation comment or attribute
185+
186+
#### SlevomatCodingStandard.Classes.RequireAbstractOrFinal 🔧
187+
188+
Requires the class to be declared either as abstract or as final.
189+
190+
#### SlevomatCodingStandard.Classes.RequireConstructorPropertyPromotion 🔧
191+
192+
Requires use of constructor property promotion.
193+
194+
This sniff provides the following setting:
195+
196+
* `enable`: either to enable or not this sniff. By default, it is enabled for PHP versions 8.0 or higher.
197+
198+
#### SlevomatCodingStandard.Classes.RequireMultiLineMethodSignature 🔧
199+
200+
Enforces method signature to be splitted to more lines so each parameter is on its own line.
201+
202+
Sniff provides the following settings:
203+
204+
* `minLineLength`: specifies min line length to enforce signature to be splitted. Use 0 value to enforce for all methods, regardless of length.
205+
206+
* `includedMethodPatterns`: allows to configure which methods are included in sniff detection. This is an array of regular expressions (PCRE) with delimiters. You should not use this with `excludedMethodPatterns`, as it will not work properly.
207+
208+
* `excludedMethodPatterns`: allows to configure which methods are excluded from sniff detection. This is an array of regular expressions (PCRE) with delimiters. You should not use this with `includedMethodPatterns`, as it will not work properly.
209+
210+
#### SlevomatCodingStandard.Classes.RequireSingleLineMethodSignature 🔧
211+
212+
Enforces method signature to be on a single line.
213+
214+
Sniff provides the following settings:
215+
216+
* `maxLineLength`: specifies max allowed line length. If signature would fit on it, it's enforced. Use 0 value to enforce for all methods, regardless of length.
217+
218+
* `includedMethodPatterns`: allows to configure which methods are included in sniff detection. This is an array of regular expressions (PCRE) with delimiters. You should not use this with `excludedMethodPatterns`, as it will not work properly.
219+
220+
* `excludedMethodPatterns`: allows to configure which methods are excluded from sniff detection. This is an array of regular expressions (PCRE) with delimiters. You should not use this with `includedMethodPatterns`, as it will not work properly.
221+
222+
#### SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming
223+
224+
Reports use of superfluous prefix or suffix "Abstract" for abstract classes.
225+
226+
#### SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming
227+
228+
Reports use of superfluous prefix or suffix "Interface" for interfaces.
229+
230+
#### SlevomatCodingStandard.Classes.SuperfluousExceptionNaming
231+
232+
Reports use of superfluous suffix "Exception" for exceptions.
233+
234+
#### SlevomatCodingStandard.Classes.SuperfluousErrorNaming
235+
236+
Reports use of superfluous suffix "Error" for errors.
237+
238+
#### SlevomatCodingStandard.Classes.SuperfluousTraitNaming
239+
240+
Reports use of superfluous suffix "Trait" for traits.
241+
242+
#### SlevomatCodingStandard.Classes.TraitUseDeclaration 🔧
243+
244+
Prohibits multiple traits separated by commas in one `use` statement.
245+
246+
#### SlevomatCodingStandard.Classes.TraitUseSpacing 🔧
247+
248+
Enforces configurable number of lines before first `use`, after last `use` and between two `use` statements.
249+
250+
Sniff provides the following settings:
251+
252+
* `linesCountBeforeFirstUse`: allows to configure the number of lines before first `use`.
253+
* `linesCountBeforeFirstUseWhenFirstInClass`: allows to configure the number of lines before first `use` when the `use` is the first statement in the class.
254+
* `linesCountBetweenUses`: allows to configure the number of lines between two `use` statements.
255+
* `linesCountAfterLastUse`: allows to configure the number of lines after last `use`.
256+
* `linesCountAfterLastUseWhenLastInClass`: allows to configure the number of lines after last `use` when the `use` is the last statement in the class.
257+
258+
#### SlevomatCodingStandard.Classes.UselessLateStaticBinding 🔧
259+
260+
Reports useless late static binding.

0 commit comments

Comments
 (0)