Skip to content

Commit 3eb0e87

Browse files
committed
re-copy doctrine standard
1 parent aa503f2 commit 3eb0e87

File tree

1 file changed

+101
-16
lines changed

1 file changed

+101
-16
lines changed

src/PatchlevelCodingStandard/ruleset.xml

Lines changed: 101 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@
4242
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
4343
<!-- Forbid inline HTML in PHP code -->
4444
<rule ref="Generic.Files.InlineHTML"/>
45-
<!-- Force whitespace after a type cast -->
46-
<rule ref="Generic.Formatting.SpaceAfterCast">
45+
<!-- Align corresponding assignment statement tokens -->
46+
<rule ref="Generic.Formatting.MultipleStatementAlignment">
4747
<properties>
48-
<property name="spacing" value="0"/>
48+
<property name="error" value="true"/>
4949
</properties>
5050
</rule>
51-
<!-- Force no whitespace after `!` -->
52-
<rule ref="Generic.Formatting.SpaceAfterNot">
51+
<!-- Force whitespace after a type cast -->
52+
<rule ref="Generic.Formatting.SpaceAfterCast">
5353
<properties>
54-
<property name="spacing" value="0" />
54+
<property name="spacing" value="0"/>
5555
</properties>
5656
</rule>
5757
<!-- Forbid PHP 4 constructors -->
@@ -108,29 +108,60 @@
108108
<rule ref="PSR2.ControlStructures.ElseIfDeclaration.NotAllowed">
109109
<type>error</type>
110110
</rule>
111+
<!-- Disallow multiple attributes inside one #[] -->
112+
<rule ref="SlevomatCodingStandard.Attributes.DisallowAttributesJoining"/>
113+
<!-- Require only one attribute per line -->
114+
<rule ref="SlevomatCodingStandard.Attributes.DisallowMultipleAttributesPerLine"/>
115+
<!-- Attributes should be adjoined to the PHP element they belong to -->
116+
<rule ref="SlevomatCodingStandard.Attributes.AttributeAndTargetSpacing"/>
117+
<!-- Require PHPDoc always before attributes -->
118+
<rule ref="SlevomatCodingStandard.Attributes.RequireAttributeAfterDocComment"/>
111119
<!-- Require that single line arrays have the correct spacing: no space around brackets and one space after comma -->
112120
<rule ref="SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace"/>
113121
<!-- Require comma after last element in multi-line array -->
114122
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma"/>
123+
<!-- Require no space before : and 1 space before Enum type -->
124+
<rule ref="SlevomatCodingStandard.Classes.BackedEnumTypeSpacing"/>
115125
<!-- Require presence of constant visibility -->
116126
<rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility">
117127
<properties>
118128
<property name="fixable" value="true"/>
119129
</properties>
120130
</rule>
131+
<!-- Enforce consistent constant spacing -->
132+
<rule ref="SlevomatCodingStandard.Classes.ConstantSpacing"/>
121133
<!-- Forbid LSB for constants (static::FOO) -->
122134
<rule ref="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants"/>
123135
<!-- Forbid more than one constant declared per statement -->
124136
<rule ref="SlevomatCodingStandard.Classes.DisallowMultiConstantDefinition"/>
137+
<!-- Forbid string expression property fetch ($foo->{'bar'}) -->
138+
<rule ref="SlevomatCodingStandard.Classes.DisallowStringExpressionPropertyFetch"/>
125139
<!-- Forbid empty lines around type declarations -->
126140
<rule ref="SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces">
127141
<properties>
128142
<property name="linesCountAfterOpeningBrace" value="0"/>
129143
<property name="linesCountBeforeClosingBrace" value="0"/>
130144
</properties>
131145
</rule>
146+
<!-- Add one line around parent call in order to improve readability -->
147+
<rule ref="SlevomatCodingStandard.Classes.ParentCallSpacing"/>
148+
<!-- Ensure that there are consistent blank lines between properties. -->
149+
<rule ref="SlevomatCodingStandard.Classes.PropertySpacing">
150+
<properties>
151+
<property name="minLinesCountBeforeWithComment" value="0" />
152+
</properties>
153+
</rule>
132154
<!-- Require usage of ::class instead of __CLASS__, get_class(), get_class($this), get_called_class() and get_parent_class() -->
133155
<rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/>
156+
<!-- https://github.com/slevomat/coding-standard#slevomatcodingstandardclassespropertydeclaration- -->
157+
<rule ref="SlevomatCodingStandard.Classes.PropertyDeclaration">
158+
<properties>
159+
<property name="checkPromoted" value="true"/>
160+
<property name="enableMultipleSpacesBetweenModifiersCheck" value="true"/>
161+
</properties>
162+
</rule>
163+
<!-- Require usage of constructor property promotion -->
164+
<rule ref="SlevomatCodingStandard.Classes.RequireConstructorPropertyPromotion"/>
134165
<!-- Forbid uses of multiple traits separated by comma -->
135166
<rule ref="SlevomatCodingStandard.Classes.TraitUseDeclaration"/>
136167
<!-- Require no spaces before trait use, between trait uses and one space after trait uses -->
@@ -150,6 +181,8 @@
150181
<rule ref="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming"/>
151182
<!-- Forbid suffix "Trait" for traits -->
152183
<rule ref="SlevomatCodingStandard.Classes.SuperfluousTraitNaming"/>
184+
<!-- Forbid invalid annotation names in standard PHPDoc tags -->
185+
<rule ref="SlevomatCodingStandard.Commenting.AnnotationName"/>
153186
<!-- Require specific order of phpDoc annotations with empty newline between specific groups -->
154187
<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing">
155188
<properties>
@@ -172,8 +205,16 @@
172205
@ODM\,
173206
@PHPCR\,
174207
"/>
175-
<element value="@param"/>
176-
<element value="@return"/>
208+
<element value="
209+
@param,
210+
@psalm-param,
211+
@phpstan-param,
212+
"/>
213+
<element value="
214+
@return,
215+
@psalm-return,
216+
@phpstan-return,
217+
"/>
177218
<element value="@throws"/>
178219
</property>
179220
</properties>
@@ -211,8 +252,6 @@
211252
</rule>
212253
<!-- Report invalid format of inline phpDocs with @var -->
213254
<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration"/>
214-
<!-- Require comments with single line written as one-liners -->
215-
<rule ref="SlevomatCodingStandard.Commenting.RequireOneLinePropertyDocComment"/>
216255
<!-- Forbid assignments in conditions -->
217256
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/>
218257
<!-- Require consistent spacing for block structures -->
@@ -256,6 +295,8 @@
256295
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator"/>
257296
<!-- Require usage of null coalesce operator when possible -->
258297
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator"/>
298+
<!-- Require usage of null safe operator when possible -->
299+
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullSafeObjectOperator"/>
259300
<!-- Forbid usage of conditions when a simple return can be used -->
260301
<rule ref="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn"/>
261302
<!-- Forbid usage of boolean-only ternary operator usage (e.g. $foo ? true : false) -->
@@ -264,6 +305,8 @@
264305
<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch"/>
265306
<!-- Require using Throwable instead of Exception -->
266307
<rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly"/>
308+
<!-- Require non-capturing catch when the variable with exception is not used. -->
309+
<rule ref="SlevomatCodingStandard.Exceptions.RequireNonCapturingCatch" />
267310
<!-- Ensure Arrow Functions declaration format -->
268311
<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration">
269312
<properties>
@@ -272,6 +315,30 @@
272315
<property name="spacesCountAfterArrow" value="1"/>
273316
</properties>
274317
</rule>
318+
<!-- Disallow trailing commas in single line function calls -->
319+
<rule ref="SlevomatCodingStandard.Functions.DisallowTrailingCommaInCall">
320+
<properties>
321+
<property name="onlySingleLine" value="true" />
322+
</properties>
323+
</rule>
324+
<!-- Disallow trailing commas in single line closure use -->
325+
<rule ref="SlevomatCodingStandard.Functions.DisallowTrailingCommaInClosureUse">
326+
<properties>
327+
<property name="onlySingleLine" value="true" />
328+
</properties>
329+
</rule>
330+
<!-- Disallow trailing commas in single line function declarations -->
331+
<rule ref="SlevomatCodingStandard.Functions.DisallowTrailingCommaInDeclaration">
332+
<properties>
333+
<property name="onlySingleLine" value="true" />
334+
</properties>
335+
</rule>
336+
<!-- Require trailing commas in multiline function calls -->
337+
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInCall"/>
338+
<!-- Require trailing commas in multiline closure use -->
339+
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInClosureUse"/>
340+
<!-- Require trailing commas in multiline function declarations -->
341+
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInDeclaration"/>
275342
<!-- Require closures not referencing $this be static -->
276343
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/>
277344
<!-- Forbid unused variables passed to closures via `use` -->
@@ -358,7 +425,12 @@
358425
<!-- Forbid useless semicolon `;` -->
359426
<rule ref="SlevomatCodingStandard.PHP.UselessSemicolon"/>
360427
<!-- Require /* @var type $foo */ and similar simple inline annotations to be replaced by assert() -->
361-
<rule ref="SlevomatCodingStandard.PHP.RequireExplicitAssertion"/>
428+
<rule ref="SlevomatCodingStandard.PHP.RequireExplicitAssertion">
429+
<properties>
430+
<property name="enableAdvancedStringTypes" value="true"/>
431+
<property name="enableIntegerRanges" value="true"/>
432+
</properties>
433+
</rule>
362434
<!-- Require use of short versions of scalar types (i.e. int instead of integer) -->
363435
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>
364436
<!-- Require the `null` type hint to be in the last position of annotations -->
@@ -396,7 +468,6 @@
396468
</property>
397469
</properties>
398470
</rule>
399-
<rule ref="SlevomatCodingStandard.Classes.PropertyDeclaration"/>
400471
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
401472
<properties>
402473
<property name="traversableTypeHints" type="array">
@@ -407,8 +478,18 @@
407478
</property>
408479
</properties>
409480
</rule>
481+
<!-- Define unions style -->
482+
<rule ref="SlevomatCodingStandard.TypeHints.UnionTypeHintFormat">
483+
<properties>
484+
<property name="withSpaces" value="no" />
485+
<property name="shortNullable" value="no" />
486+
<property name="nullPosition" value="last" />
487+
</properties>
488+
</rule>
410489
<!-- Forbid useless @var for constants -->
411490
<rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint"/>
491+
<!-- Require One Line Doc Comment where there's only 1 annotation present -->
492+
<rule ref="SlevomatCodingStandard.Commenting.RequireOneLineDocComment"/>
412493
<!-- Forbid useless phpDocs for functions -->
413494
<rule ref="SlevomatCodingStandard.Commenting.UselessFunctionDocComment">
414495
<properties>
@@ -426,6 +507,8 @@
426507
<rule ref="SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable"/>
427508
<!-- Forbid useless variables -->
428509
<rule ref="SlevomatCodingStandard.Variables.UselessVariable"/>
510+
<!-- Require nowdoc syntax instead of heredoc when possible -->
511+
<rule ref="SlevomatCodingStandard.PHP.RequireNowdoc" />
429512
<!-- Forbid spaces around square brackets -->
430513
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
431514
<!-- Force array declaration structure -->
@@ -448,6 +531,11 @@
448531
<rule ref="Squiz.Classes.ClassFileName"/>
449532
<!-- Force `self::` for self-reference, force lower-case self, forbid spaces around `::` -->
450533
<rule ref="Squiz.Classes.SelfMemberReference"/>
534+
<!-- Force phpDoc alignment -->
535+
<rule ref="Squiz.Commenting.DocCommentAlignment">
536+
<!-- Allow extra spaces after star, i.e. for indented annotations -->
537+
<exclude name="Squiz.Commenting.DocCommentAlignment.SpaceAfterStar"/>
538+
</rule>
451539
<!-- Force rules for function phpDoc -->
452540
<rule ref="Squiz.Commenting.FunctionComment">
453541
<!-- Allow `@throws` without description -->
@@ -511,9 +599,6 @@
511599
</rule>
512600
<!-- Forbid strings in `"` unless necessary -->
513601
<rule ref="Squiz.Strings.DoubleQuoteUsage"/>
514-
<rule ref="Squiz.Strings.DoubleQuoteUsage.ContainsVar">
515-
<message>Variable "%s" not allowed in double quoted string; use sprintf() or concatenation instead</message>
516-
</rule>
517602
<!-- Forbid braces around string in `echo` -->
518603
<rule ref="Squiz.Strings.EchoedStrings"/>
519604
<!-- Forbid spaces in type casts -->
@@ -553,4 +638,4 @@
553638
<!-- turned off by PSR-12 -> turning back on -->
554639
<severity>5</severity>
555640
</rule>
556-
</ruleset>
641+
</ruleset>

0 commit comments

Comments
 (0)