Skip to content

Commit 045e241

Browse files
committed
Import advanced PHP 7.1 sniffs
1 parent 330605d commit 045e241

File tree

3 files changed

+150
-42
lines changed

3 files changed

+150
-42
lines changed

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
},
1717
"require": {
1818
"php": "^7.1",
19-
"squizlabs/php_codesniffer": "~3.0",
20-
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.2"
19+
"squizlabs/php_codesniffer": "^3.0.1",
20+
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.2",
21+
"slevomat/coding-standard": "^4.0"
2122
},
2223
"extra": {
2324
"branch-alias": {

lib/Doctrine/Sniffs/Spacing/SpaceOnReturnTypeSniff.php

Lines changed: 0 additions & 40 deletions
This file was deleted.

lib/Doctrine/ruleset.xml

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,151 @@
3030
<property name="ignoreNewlines" value="true"/>
3131
</properties>
3232
</rule>
33+
34+
<!-- Forbid using absolute class name references (except global ones) -->
35+
<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly">
36+
<properties>
37+
<property name="allowFullyQualifiedGlobalClasses" type="boolean" value="true"/>
38+
<property name="allowFullyQualifiedGlobalFunctions" type="boolean" value="true"/>
39+
<property name="allowFullyQualifiedGlobalConstants" type="boolean" value="true"/>
40+
<property name="allowFullyQualifiedNameForCollidingClasses" type="boolean" value="true"/>
41+
</properties>
42+
</rule>
43+
44+
<!-- Forbid empty lines around type declarations -->
45+
<rule ref="SlevomatCodingStandard.Types.EmptyLinesAroundTypeBraces">
46+
<properties>
47+
<property name="linesCountAfterOpeningBrace" value="0"/>
48+
<property name="linesCountBeforeClosingBrace" value="0"/>
49+
</properties>
50+
</rule>
51+
52+
<!-- Require space around colon in return types -->
53+
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing">
54+
<properties>
55+
<property name="spacesCountBeforeColon" value="1"/>
56+
</properties>
57+
</rule>
58+
59+
<!-- Require types to be written as natively if possible;
60+
require iterable types to specify phpDoc with their content;
61+
forbid useless/duplicated information in phpDoc -->
62+
<rule ref="SlevomatCodingStandard.TypeHints.TypeHintDeclaration">
63+
<properties>
64+
<property name="enableEachParameterAndReturnInspection" value="true"/>
65+
<property name="traversableTypeHints" type="array" value="Doctrine\Common\Collections\Collection"/>
66+
<property
67+
name="usefulAnnotations"
68+
type="array"
69+
value="
70+
@dataProvider,
71+
@deprecated,
72+
@expectedException,
73+
@expectedExceptionMessage,
74+
@expectedExceptionMessageRegExp,
75+
@expectedExceptionCode,
76+
@expectedDeprecation,
77+
@group,
78+
@internal,
79+
@link,
80+
@see,
81+
@throws
82+
"
83+
/>
84+
</properties>
85+
</rule>
86+
87+
<!-- Require using Throwable instead of Exception -->
88+
<rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly"/>
89+
90+
<!-- Require presence of declare(strict_types=1) -->
91+
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
92+
<properties>
93+
<property
94+
name="newlinesCountBetweenOpenTagAndDeclare"
95+
value="2"
96+
/>
97+
<property
98+
name="spacesCountAroundEqualsSign"
99+
value="0"
100+
/>
101+
</properties>
102+
</rule>
103+
104+
<!-- Forbid assignments in conditions -->
105+
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/>
106+
107+
<!-- Forbid weak comparisons -->
108+
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowEqualOperators"/>
109+
110+
<!-- Require language constructs without parentheses -->
111+
<rule ref="SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses"/>
112+
113+
<!-- Forbid dead code -->
114+
<rule ref="SlevomatCodingStandard.Classes.UnusedPrivateElements"/>
115+
116+
<!-- Forbid unused use statements -->
117+
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
118+
<properties>
119+
<property name="searchAnnotations" type="boolean" value="true"/>
120+
</properties>
121+
</rule>
122+
123+
<!-- Forbid useless uses of the same namespace -->
124+
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace"/>
125+
126+
<!-- Forbid useless unreachable catch blocks -->
127+
<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch"/>
128+
129+
<!-- Require comma after last element in multi-line array -->
130+
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma"/>
131+
132+
<!-- Forbid fancy yoda conditions -->
133+
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison"/>
134+
135+
<!-- Require use statements to be alphabetically sorted -->
136+
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/>
137+
138+
<!-- Require use of short versions of scalar types (i.e. int instead of integer) -->
139+
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>
140+
141+
<!-- Require presence of constant visibility -->
142+
<rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility"/>
143+
144+
<!-- Require ? when default value is null -->
145+
<rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/>
146+
147+
<!-- Require one space between typehint and variable, require no space between nullability sign and typehint -->
148+
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/>
149+
150+
<!-- Forbid fancy group uses -->
151+
<rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse"/>
152+
153+
<!-- Forbid multiple use statements on same line -->
154+
<rule ref="SlevomatCodingStandard.Namespaces.MultipleUsesPerLine"/>
155+
156+
<!-- Forbid superfluous leading backslash in use statements -->
157+
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash"/>
158+
159+
<!-- Forbid useless annotations - Git and LICENCE file provide more accurate information -->
160+
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenAnnotations">
161+
<properties>
162+
<property
163+
name="forbiddenAnnotations"
164+
type="array"
165+
value="
166+
@author,
167+
@copyright,
168+
@created,
169+
@license,
170+
@package,
171+
@since,
172+
@version
173+
"
174+
/>
175+
</properties>
176+
</rule>
177+
178+
<!-- report invalid format of inline phpDocs with @var -->
179+
<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration"/>
33180
</ruleset>

0 commit comments

Comments
 (0)