606 lines
29 KiB
XML
606 lines
29 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<ruleset name="CCS-SCS-1">
|
|
|
|
<description>extension of Slevomat Coding Standard</description>
|
|
|
|
<!-- https://github.com/slevomat/coding-standard -->
|
|
|
|
<!-- See https://github.com/slevomat/coding-standard/#sniffs-included-in-this-standard -->
|
|
|
|
<!-- Checks for missing property typehints in case they can be declared natively -->
|
|
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint">
|
|
<properties>
|
|
<property name="enableNativeTypeHint" value="true"/>
|
|
<property name="traversableTypeHints" type="array">
|
|
<element value="array"/>
|
|
<element value="iterable"/>
|
|
<element value="Traversable"/>
|
|
<element value="\Illuminate\Support\Collection"/>
|
|
</property>
|
|
</properties>
|
|
|
|
<!-- Disabled since subclasses can't always overrule parents -->
|
|
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint"/>
|
|
|
|
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingTraversableTypeHintSpecification"/>
|
|
</rule>
|
|
|
|
<!-- Checks for missing return typehints in case they can be declared natively -->
|
|
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
|
|
<properties>
|
|
<property name="enableObjectTypeHint" value="true"/>
|
|
<property name="traversableTypeHints" type="array">
|
|
<element value="array"/>
|
|
<element value="iterable"/>
|
|
<element value="Traversable"/>
|
|
<element value="\Illuminate\Support\Collection"/>
|
|
</property>
|
|
</properties>
|
|
|
|
<!-- Disabled since subclasses can't always overrule parents -->
|
|
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint"/>
|
|
|
|
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification"/>
|
|
|
|
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingAnyTypeHint"/>
|
|
</rule>
|
|
|
|
<!-- Reports useless @var annotation (or whole documentation comment) for constants because the type of constant is always clear -->
|
|
<rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint"/>
|
|
|
|
<!-- Use the php 7.0+ Throwable interface instead of `Exception` -->
|
|
<rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly"/>
|
|
|
|
<!-- Enforce declare strict types -->
|
|
<!-- Covered by PSR-12: Generic.PHP.RequireStrictTypes -->
|
|
<!--<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes"/>-->
|
|
|
|
<!-- Disallows implicit array creation -->
|
|
<rule ref="SlevomatCodingStandard.Arrays.DisallowImplicitArrayCreation"/>
|
|
|
|
<!-- Disallows implicit array creation -->
|
|
<rule ref="SlevomatCodingStandard.Classes.ClassStructure">
|
|
<properties>
|
|
<property name="groups" type="array">
|
|
<element value="uses"/>
|
|
<element value="public constants"/>
|
|
<element value="protected constants"/>
|
|
<element value="private constants"/>
|
|
<element value="public static properties"/>
|
|
<element value="protected static properties"/>
|
|
<element value="private static properties"/>
|
|
<element value="public properties, protected properties, private properties"/>
|
|
<element value="public static abstract methods"/>
|
|
<element value="protected static abstract methods"/>
|
|
<element value="public abstract methods"/>
|
|
<element value="protected abstract methods"/>
|
|
<element value="static constructors"/>
|
|
<element value="constructor"/>
|
|
<element value="destructor"/>
|
|
<element value="public methods, protected methods, private methods"/>
|
|
<element value="public static methods, protected static methods, private static methods"/>
|
|
<element value="magic methods"/>
|
|
</property>
|
|
</properties>
|
|
</rule>
|
|
|
|
<!-- Prefer self:: over static:: for CONST which should not be changed -->
|
|
<rule ref="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants"/>
|
|
|
|
<!-- Prefer self:: over static:: for class vars of final class -->
|
|
<rule ref="SlevomatCodingStandard.Classes.UselessLateStaticBinding"/>
|
|
|
|
<!-- Don't allow `if($x = something()){}` -->
|
|
<!-- Also covered by Generic.CodeAnalysis.AssignmentInCondition, but this one is more permissive in while loops -->
|
|
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/>
|
|
|
|
<!-- Disallows use of continue without integer operand in switch because it's emits warning in PHP 7.3 and higher -->
|
|
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowContinueWithoutIntegerOperandInSwitch"/>
|
|
|
|
<!-- Disallow `empty` language construct to prevent unexisting variable usage -->
|
|
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowEmpty"/>
|
|
|
|
<!-- Only allow `===` and `!===` -->
|
|
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/>
|
|
|
|
<!-- Prefer `$x ?? 5` over `isset($x) ? $x : 5` -->
|
|
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator"/>
|
|
|
|
<!-- Requires use of null coalesce equal operator when possible -->
|
|
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator"/>
|
|
|
|
<!-- Some functions have $strict parameter. This sniff reports calls to these functions without the parameter or with $strict = false. -->
|
|
<!-- Enabled in `phased-coding-standard` for now -->
|
|
<!-- <rule ref="SlevomatCodingStandard.Functions.StrictCall"/> -->
|
|
|
|
<!-- Reports closures not using $this that are not declared static -->
|
|
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/>
|
|
|
|
<!-- Disallows direct call of __invoke() -->
|
|
<rule ref="SlevomatCodingStandard.PHP.DisallowDirectMagicInvokeCall"/>
|
|
|
|
<!-- Disabled since we are not interested in disabling `$i++`. Use unary statement wisely though -->
|
|
<!--<rule ref="SlevomatCodingStandard.Operators.DisallowIncrementAndDecrementOperators"/>-->
|
|
|
|
<!-- Only allow unary statement as standalone to avoid hard to read code -->
|
|
<!-- Disabled since we allow the responsible usage of unary statements -->
|
|
<!--<rule ref="SlevomatCodingStandard.Operators.RequireOnlyStandaloneIncrementAndDecrementOperators"/>-->
|
|
|
|
<!-- Enforce `$i += 1` instead of `$i = $i + 1` -->
|
|
<rule ref="SlevomatCodingStandard.Operators.RequireCombinedAssignmentOperator"/>
|
|
|
|
<!-- Detect unused variables passed to closures via `use` statement-->
|
|
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure"/>
|
|
|
|
<!-- Detect unused parameters -->
|
|
<!-- Disabled since we often have unused optional arguments -->
|
|
<!--<rule ref="SlevomatCodingStandard.Functions.UnusedParameter"/>-->
|
|
|
|
<!-- Detect useless default value for parameter -->
|
|
<rule ref="SlevomatCodingStandard.Functions.UselessParameterDefaultValue"/>
|
|
|
|
<!-- Detect unused use statements -->
|
|
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
|
|
<properties>
|
|
<!-- properties: searchAnnotations, ignoredAnnotationNames, ignoredAnnotations -->
|
|
<!-- Search in annotations to avoid false positives -->
|
|
<property name="searchAnnotations" value="true"/>
|
|
</properties>
|
|
</rule>
|
|
|
|
<!-- Detect use statements from same namespace -->
|
|
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace"/>
|
|
|
|
<!-- Detect use-statements with alias to the same name -->
|
|
<!-- <rule ref="SlevomatCodingStandard.Namespaces.UselessAlias"/>-->
|
|
|
|
<!-- Disallows references -->
|
|
<!-- Disabled since the code contains enough occurrences which can't easily be removed as of yet -->
|
|
<!--<rule ref="SlevomatCodingStandard.PHP.DisallowReference"/>-->
|
|
|
|
<!-- Reports usage of forbidden classes, interfaces, parent classes and traits -->
|
|
<rule ref="SlevomatCodingStandard.PHP.ForbiddenClasses">
|
|
<properties>
|
|
<property name="forbiddenClasses" type="array">
|
|
<!-- More facades from Illuminate to add: see app.php from any laravel installation -->
|
|
<element key="Validator" value="Illuminate\Support\Facades\Validator"/>
|
|
</property>
|
|
<property name="forbiddenExtends" type="array">
|
|
<element key="Exception" value="null"/>
|
|
</property>
|
|
<!--
|
|
<property name="forbiddenInterfaces" type="array">
|
|
</property>
|
|
<property name="forbiddenTraits" type="array">
|
|
</property>
|
|
-->
|
|
</properties>
|
|
</rule>
|
|
|
|
<!-- Requires assertion via assert instead of inline documentation comments -->
|
|
<!-- Disabled since we use `Assert::that` for this functionality -->
|
|
<!--<rule ref="SlevomatCodingStandard.PHP.RequireExplicitAssertion"/>-->
|
|
|
|
<!-- Requires nowdoc syntax instead of heredoc when possible -->
|
|
<rule ref="SlevomatCodingStandard.PHP.RequireNowdoc"/>
|
|
|
|
<!-- Detect random parentheses -->
|
|
<rule ref="SlevomatCodingStandard.PHP.UselessParentheses"/>
|
|
|
|
<!-- PHP optimizes some internal functions into special opcodes on VM level.
|
|
Such optimization results in much faster execution compared to calling standard function.
|
|
This only works when these functions are not invoked with argument unpacking -->
|
|
<rule ref="SlevomatCodingStandard.PHP.OptimizedFunctionsWithoutUnpacking"/>
|
|
|
|
<!-- Detect rogue semicolons -->
|
|
<rule ref="SlevomatCodingStandard.PHP.UselessSemicolon"/>
|
|
|
|
<!-- Disallows use of super global variables -->
|
|
<rule ref="SlevomatCodingStandard.Variables.DisallowSuperGlobalVariable"/>
|
|
|
|
<!-- Looks for duplicate assignments to a variable -->
|
|
<rule ref="SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable"/>
|
|
|
|
<!-- Detect unused variables -->
|
|
<rule ref="SlevomatCodingStandard.Variables.UnusedVariable"/>
|
|
|
|
<!-- Detect useless variables -->
|
|
<rule ref="SlevomatCodingStandard.Variables.UselessVariable"/>
|
|
|
|
<!-- Detect unreachable catch statement -->
|
|
<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch"/>
|
|
|
|
<!-- Enforces reasonable end bracket placement for multiline arrays -->
|
|
<rule ref="SlevomatCodingStandard.Arrays.MultiLineArrayEndBracketPlacement"/>
|
|
|
|
<!-- Checks whitespace in single line array declarations (whitespace between brackets, around commas, ...) -->
|
|
<rule ref="SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace">
|
|
<properties>
|
|
<property name="enableEmptyArrayCheck" value="true"/>
|
|
</properties>
|
|
</rule>
|
|
|
|
<!-- Checks lines count between different class members, eg. between last property and first method. -->
|
|
<!-- Disabled since it's covered by Generic.WhiteSpace.FunctionSpacing -->
|
|
<!--<rule ref="SlevomatCodingStandard.Classes.ClassMemberSpacing"/>-->
|
|
|
|
<!-- Add trailing comma to multiline arrays -->
|
|
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma"/>
|
|
|
|
<!-- Checks that there is a certain number of blank lines between constants -->
|
|
<rule ref="SlevomatCodingStandard.Classes.ConstantSpacing">
|
|
<properties>
|
|
<property name="minLinesCountBeforeWithComment" value="1"/>
|
|
<property name="maxLinesCountBeforeWithComment" value="1"/>
|
|
<property name="minLinesCountBeforeWithoutComment" value="0"/>
|
|
<property name="maxLinesCountBeforeWithoutComment" value="1"/>
|
|
</properties>
|
|
</rule>
|
|
|
|
<!-- Disallows multi constant definition -->
|
|
<rule ref="SlevomatCodingStandard.Classes.DisallowMultiConstantDefinition"/>
|
|
|
|
<!-- Disallows multi property definition -->
|
|
<!-- Disabled since it's covered by PSR2.Classes.PropertyDeclaration.Multiple -->
|
|
<!--<rule ref="SlevomatCodingStandard.Classes.DisallowMultiPropertyDefinition"/>-->
|
|
|
|
<!-- Checks that there is a certain number of blank lines between methods -->
|
|
<!-- Disabled since it's covered by Squiz.WhiteSpace.FunctionSpacing.After -->
|
|
<!--<rule ref="SlevomatCodingStandard.Classes.MethodSpacing"/>-->
|
|
|
|
<!-- Detect use of __CLASS__, get_parent_class(), get_called_class(), get_class(). Use ::class constant -->
|
|
<rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/>
|
|
|
|
<!-- Enforces configurable number of lines around parent method call -->
|
|
<rule ref="SlevomatCodingStandard.Classes.ParentCallSpacing"/>
|
|
|
|
<!-- Checks that there is a certain number of blank lines between properties -->
|
|
<rule ref="SlevomatCodingStandard.Classes.PropertySpacing">
|
|
<properties>
|
|
<property name="minLinesCountBeforeWithComment" value="1"/>
|
|
<property name="maxLinesCountBeforeWithComment" value="1"/>
|
|
<property name="minLinesCountBeforeWithoutComment" value="0"/>
|
|
<property name="maxLinesCountBeforeWithoutComment" value="1"/>
|
|
</properties>
|
|
</rule>
|
|
|
|
<!-- Enforces method signature to be splitted to more lines so each parameter is on its own line -->
|
|
<rule ref="SlevomatCodingStandard.Classes.RequireMultiLineMethodSignature">
|
|
<properties>
|
|
<property name="minLineLength" value="121"/>
|
|
</properties>
|
|
</rule>
|
|
|
|
<!-- Enforces method signature to be on a single line -->
|
|
<rule ref="SlevomatCodingStandard.Classes.RequireSingleLineMethodSignature">
|
|
<properties>
|
|
<property name="maxLineLength" value="120"/>
|
|
</properties>
|
|
</rule>
|
|
|
|
<!-- Detects use of superfluous prefix or suffix "Abstract" for abstract classes -->
|
|
<!--<rule ref="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming"/>-->
|
|
|
|
<!-- Detects use of superfluous prefix or suffix "Interface" for interfaces -->
|
|
<rule ref="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming"/>
|
|
|
|
<!-- Detects use of superfluous suffix "Exception" for exceptions -->
|
|
<!--<rule ref="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming"/>-->
|
|
|
|
<!-- Reports use of superfluous suffix "Error" for errors -->
|
|
<!--<rule ref="SlevomatCodingStandard.Classes.SuperfluousErrorNaming"/>-->
|
|
|
|
<!-- Reports use of superfluous suffix "Trait" for traits -->
|
|
<!--<rule ref="SlevomatCodingStandard.Classes.SuperfluousTraitNaming"/>-->
|
|
|
|
<!-- Prohibits multiple traits separated by commas in one use statement -->
|
|
<rule ref="SlevomatCodingStandard.Classes.TraitUseDeclaration"/>
|
|
|
|
<!-- Enforces configurable number of lines before first trait use, after last use and between two use statements -->
|
|
<!-- Disabled since it's covered by PSR12.Traits.UseDeclaration -->
|
|
<!--<rule ref="SlevomatCodingStandard.Classes.TraitUseSpacing"/>-->
|
|
|
|
<!-- Enforces configurable number of lines around block control structures (if, foreach, ...) -->
|
|
<!-- Disabled since enforcing this is not requested -->
|
|
<!--<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing"/>-->
|
|
|
|
<!-- Enforces configurable number of lines around jump statements (continue, return, ...) -->
|
|
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
|
|
<properties>
|
|
<property name="allowSingleLineYieldStacking" value="true"/>
|
|
<property name="linesCountBeforeControlStructure" value="1"/>
|
|
<property name="linesCountBeforeFirstControlStructure" value="0"/>
|
|
<property name="linesCountAfterControlStructure" value="1"/>
|
|
<property name="linesCountAfterLastControlStructure" value="0"/>
|
|
|
|
<property name="tokensToCheck" type="array">
|
|
<element value="T_RETURN"/>
|
|
</property>
|
|
</properties>
|
|
</rule>
|
|
|
|
<!-- Detect language construct used with parentheses `exit()`-->
|
|
<rule ref="SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses"/>
|
|
|
|
<!-- Enforce new with parentheses -->
|
|
<!-- Disabled since it's covered by PSR12.Classes.ClassInstantiation -->
|
|
<!--<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses"/>-->
|
|
|
|
<!-- Disabled since common senses points toward new with parentheses -->
|
|
<!-- Enforce new without parentheses -->
|
|
<!--<rule ref="SlevomatCodingStandard.ControlStructures.NewWithoutParentheses"/>-->
|
|
|
|
<!-- Disabled since we are not interested in prohibiting `$x ?: $y` -->
|
|
<!--<rule ref="SlevomatCodingStandard.ControlStructures.DisallowShortTernaryOperator"/>-->
|
|
|
|
<!-- Ternary operator has to be reformatted to more lines when the line length exceeds the given limit -->
|
|
<rule ref="SlevomatCodingStandard.ControlStructures.RequireMultiLineTernaryOperator">
|
|
<properties>
|
|
<property name="lineLengthLimit" value="120"/>
|
|
</properties>
|
|
</rule>
|
|
|
|
<!-- Enforces conditions of if, elseif, while and do-while to be on a single line -->
|
|
<rule ref="SlevomatCodingStandard.ControlStructures.RequireSingleLineCondition">
|
|
<properties>
|
|
<property name="maxLineLength" value="120"/>
|
|
<property name="alwaysForSimpleConditions" value="false"/>
|
|
</properties>
|
|
</rule>
|
|
|
|
<!-- Enforces conditions of if, elseif, while and do-while with one or more boolean operators to be splitted to more lines so each condition part is on its own line -->
|
|
<rule ref="SlevomatCodingStandard.ControlStructures.RequireMultiLineCondition">
|
|
<properties>
|
|
<property name="minLineLength" value="121"/>
|
|
<property name="booleanOperatorOnPreviousLine" value="false"/>
|
|
<property name="alwaysSplitAllConditionParts" value="false"/>
|
|
</properties>
|
|
</rule>
|
|
|
|
<!-- Enforce `$x ?: $y` in contrary to `$x ? $x : $y` whenever possible -->
|
|
<rule ref="SlevomatCodingStandard.ControlStructures.RequireShortTernaryOperator"/>
|
|
|
|
<!-- Requires ternary operator when possible -->
|
|
<rule ref="SlevomatCodingStandard.ControlStructures.RequireTernaryOperator"/>
|
|
|
|
<!-- Yoda conditions decrease code comprehensibility and readability -->
|
|
<!-- Disabled since it's covered by Generic.ControlStructures.DisallowYodaConditions -->
|
|
<!--<rule ref="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison"/>-->
|
|
<!--<rule ref="SlevomatCodingStandard.ControlStructures.RequireYodaComparison"/>-->
|
|
|
|
<!-- Enforces maximum length of a single line of code -->
|
|
<rule ref="SlevomatCodingStandard.Files.LineLength">
|
|
<properties>
|
|
<property name="lineLengthLimit" value="120"/>
|
|
<property name="ignoreComments" value="false"/>
|
|
<property name="ignoreImports" value="true"/>
|
|
</properties>
|
|
</rule>
|
|
|
|
<!-- Checks fn declaration -->
|
|
<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration"/>
|
|
|
|
<!-- Reports empty functions body and requires at least a comment inside -->
|
|
<rule ref="SlevomatCodingStandard.Functions.DisallowEmptyFunction"/>
|
|
|
|
<!-- Disallows arrow functions -->
|
|
<!-- Disabled since we haven't made a choice what we want yet -->
|
|
<!--<rule ref="SlevomatCodingStandard.Functions.DisallowArrowFunction"/>-->
|
|
<!--<rule ref="SlevomatCodingStandard.Functions.RequireArrowFunction"/>-->
|
|
|
|
<!-- Enforces function call to be splitted to more lines so each parameter is on its own line -->
|
|
<rule ref="SlevomatCodingStandard.Functions.RequireMultiLineCall">
|
|
<properties>
|
|
<property name="minLineLength" value="121"/>
|
|
</properties>
|
|
</rule>
|
|
|
|
<!-- Enforces function call to be on a single line -->
|
|
<rule ref="SlevomatCodingStandard.Functions.RequireSingleLineCall">
|
|
<properties>
|
|
<property name="maxLineLength" value="120"/>
|
|
<property name="ignoreWithComplexParameter" value="true"/>
|
|
</properties>
|
|
</rule>
|
|
|
|
<!-- Enforce alphabetically ordered use statement list -->
|
|
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses">
|
|
<properties>
|
|
<property name="psr12Compatible" value="true"/>
|
|
<property name="caseSensitive" value="false"/>
|
|
</properties>
|
|
</rule>
|
|
|
|
<!-- Enforce only one namespace in a file -->
|
|
<rule ref="SlevomatCodingStandard.Namespaces.RequireOneNamespaceInFile"/>
|
|
|
|
<!-- Restrict namespace declaration spacing -->
|
|
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceDeclaration"/>
|
|
|
|
<!-- Restrict namespace newline wrapping -->
|
|
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceSpacing">
|
|
<properties>
|
|
<property name="linesCountBeforeNamespace" value="1"/>
|
|
<property name="linesCountAfterNamespace" value="1"/>
|
|
</properties>
|
|
</rule>
|
|
|
|
<!-- Restrict use newline wrapping -->
|
|
<!-- Disabled since it's covered by PSR12.Files.FileHeader -->
|
|
<!--<rule ref="SlevomatCodingStandard.Namespaces.UseSpacing"/>-->
|
|
|
|
<!-- Disallows numeric literal separators -->
|
|
<rule ref="SlevomatCodingStandard.Numbers.DisallowNumericLiteralSeparator"/>
|
|
|
|
<!-- Requires use of numeric literal separators -->
|
|
<!-- Disabled since we prefer purity in code over random separators in numbers making them impossible to use elsewhere -->
|
|
<!--<rule ref="SlevomatCodingStandard.Numbers.RequireNumericLiteralSeparator"/>-->
|
|
|
|
<!-- Enforces configurable number of spaces after reference -->
|
|
<rule ref="SlevomatCodingStandard.PHP.ReferenceSpacing"/>
|
|
|
|
<!-- Enforces configurable number of spaces after ! -->
|
|
<!-- Disabled since it's covered by Generic.Formatting.SpaceAfterNot -->
|
|
<!--<rule ref="SlevomatCodingStandard.PHP.NegationOperatorSpacing"/>-->
|
|
|
|
<!-- Enforces configurable number of spaces after the ... operator -->
|
|
<!-- Disabled since it's covered by Generic.WhiteSpace.SpreadOperatorSpacingAfter -->
|
|
<!--<rule ref="SlevomatCodingStandard.Operators.SpreadOperatorSpacing"/>-->
|
|
|
|
<!-- Disallows usage of "mixed" type hint in phpDocs -->
|
|
<rule ref="SlevomatCodingStandard.TypeHints.DisallowMixedTypeHint"/>
|
|
|
|
<!-- Enforce typehints with native scalar for consistency -->
|
|
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>
|
|
|
|
<!-- prefer string|null over null|string in type hints -->
|
|
<rule ref="SlevomatCodingStandard.TypeHints.NullTypeHintOnLastPosition"/>
|
|
|
|
<!-- Enforce `[...]` over `list(...)` -->
|
|
<rule ref="SlevomatCodingStandard.PHP.ShortList"/>
|
|
|
|
<!-- Enforces shorthand cast operators, forbids unset and binary cast operators. `(bool)` instead of (boolean) -->
|
|
<!-- Also covered by PSR12.Functions.NullableTypeDeclaration, but this one is more extensive -->
|
|
<rule ref="SlevomatCodingStandard.PHP.TypeCast"/>
|
|
|
|
<!-- Checks duplicate spaces anywhere because there aren't sniffs for every part of code to check formatting -->
|
|
<rule ref="SlevomatCodingStandard.Whitespaces.DuplicateSpaces"/>
|
|
|
|
<!-- Detect PSR-4 compliance between Filepath and Namespace -->
|
|
<!-- Customized in phpcs-laravel and phpcs-module -->
|
|
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName"/>
|
|
|
|
<!-- Enforce visibility notation for class constants -->
|
|
<rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility"/>
|
|
|
|
<!-- Restrict return type hint spacing -->
|
|
<!-- Disabled since it's covered by PSR12.Functions.NullableTypeDeclaration & PSR12.Functions.ReturnTypeDeclaration -->
|
|
<!--<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing"/>-->
|
|
|
|
<!-- Enforce nullability ? symbol before each nullable and optional parameter -->
|
|
<rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/>
|
|
|
|
<!-- Restrict parameter type hint spacing -->
|
|
<!-- Disabled since it's covered by PSR12.Functions.NullableTypeDeclaration -->
|
|
<!--<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/>-->
|
|
|
|
<!-- Prohibit group use statements https://wiki.php.net/rfc/group_use_declarations -->
|
|
<rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse"/>
|
|
|
|
<!-- Disabled since we want FQN's as `use` statement -->
|
|
<!--<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameAfterKeyword"/>-->
|
|
|
|
<!-- Disabled since we want FQN's as `use` statement -->
|
|
<!--<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedExceptions"/>-->
|
|
|
|
<!-- Disabled since this is more annoying than useful -->
|
|
<!--<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalConstants"/>-->
|
|
|
|
<!-- Disabled since this is more annoying than useful -->
|
|
<!--<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalFunctions"/>-->
|
|
|
|
<!-- Multiple uses per line is against PSR-2 -->
|
|
<rule ref="SlevomatCodingStandard.Namespaces.MultipleUsesPerLine"/>
|
|
|
|
<!-- Enforce `use` statements for FQN's in contrary to inline FQN's -->
|
|
<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly">
|
|
<properties>
|
|
<property name="searchAnnotations" value="true"/>
|
|
</properties>
|
|
</rule>
|
|
|
|
<!-- Disabled since we want all FQN's as `use` statement -->
|
|
<!--<rule ref="SlevomatCodingStandard.Namespaces.UseOnlyWhitelistedNamespaces"/>-->
|
|
|
|
<!-- Enforce clean use-statements without prefixed backslash -->
|
|
<!-- Disabled since it's covered by PSR12.Files.ImportStatement -->
|
|
<!--<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash"/>-->
|
|
|
|
<!-- Disabled since PSR-2 enforces direct closing after body -->
|
|
<!--<rule ref="SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces"/>-->
|
|
|
|
<!-- Disabled since we want all FQN's as `use` statement -->
|
|
<!--<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation"/>-->
|
|
|
|
<!-- Reports @deprecated annotations without description -->
|
|
<rule ref="SlevomatCodingStandard.Commenting.DeprecatedAnnotationDeclaration"/>
|
|
|
|
<!-- Prohibit annotations as they're useless with version control -->
|
|
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenAnnotations">
|
|
<properties>
|
|
<property name="forbiddenAnnotations" type="array">
|
|
<element value="@api"/>
|
|
<element value="@author"/>
|
|
<element value="@category"/>
|
|
<element value="@copyright"/>
|
|
<element value="@created"/>
|
|
<element value="@filesource"/>
|
|
<element value="@global"/>
|
|
<element value="@ignore"/>
|
|
<element value="@license"/>
|
|
<element value="@package"/>
|
|
<element value="@since"/>
|
|
<element value="@subpackage"/>
|
|
<element value="@uses"/>
|
|
<element value="@version"/>
|
|
</property>
|
|
</properties>
|
|
</rule>
|
|
|
|
<!-- Disallow comments after code -->
|
|
<!-- Disabled since comments after code are a concise way of adding context -->
|
|
<!--<rule ref="SlevomatCodingStandard.Commenting.DisallowInlineCommentAfterCode"/>-->
|
|
|
|
<!-- Prohibit certain comments since there's useless -->
|
|
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenComments">
|
|
<properties>
|
|
<property name="forbiddenCommentPatterns" type="array">
|
|
<element value="~^Created by \S+\.?\z~i"/>
|
|
<element value="~^\w* ?Constructor\.?$~i"/>
|
|
<element value="~^(User|Date|Time): \S+\z~i"/>
|
|
<element value="~^\S+ [gs]etter\.?\z~i"/>
|
|
<element value="~^(Class|Trait|Interface) \S*\.?$~i"/>
|
|
</property>
|
|
</properties>
|
|
</rule>
|
|
|
|
<!-- Restrict doc comment spacing -->
|
|
<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing"/>
|
|
|
|
<!-- Prohibit empty comments since they're useless-->
|
|
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment"/>
|
|
|
|
<!-- Restrict inline doc comment declaration (/** @var <type> $<var> */) -->
|
|
<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration">
|
|
<exclude name="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration.NoAssignment"/>
|
|
</rule>
|
|
|
|
<!-- Restrict multi-line comment with one line to 1 line comment -->
|
|
<rule ref="SlevomatCodingStandard.Commenting.RequireOneLinePropertyDocComment"/>
|
|
|
|
<!-- Disabled since we're interested in RequireOneLinePropertyDocComment -->
|
|
<!--<rule ref="SlevomatCodingStandard.Commenting.DisallowOneLinePropertyDocComment"/>-->
|
|
|
|
<!-- Checks for useless doc comments. If the native method declaration contains everything and the phpDoc does not add anything useful -->
|
|
<rule ref="SlevomatCodingStandard.Commenting.UselessFunctionDocComment">
|
|
<properties>
|
|
<property name="traversableTypeHints" type="array">
|
|
<element value="array"/>
|
|
<element value="iterable"/>
|
|
<element value="Traversable"/>
|
|
<element value="\Illuminate\Support\Collection"/>
|
|
</property>
|
|
</properties>
|
|
</rule>
|
|
|
|
<!-- Inheritance is automatic and it's not needed to use a special annotation -->
|
|
<rule ref="SlevomatCodingStandard.Commenting.UselessInheritDocComment"/>
|
|
|
|
<!-- Reports useless conditions where both branches return true or false -->
|
|
<rule ref="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn"/>
|
|
|
|
<!-- Reports useless ternary operator where both branches return true or false -->
|
|
<rule ref="SlevomatCodingStandard.ControlStructures.UselessTernaryOperator"/>
|
|
|
|
</ruleset>
|