MO4/ruleset.xml
<?xml version="1.0"?>
<ruleset name="MO4">
<description>The MO4 PHP coding standard.</description>
<!-- There should not be any code in the bundle Resources directory. -->
<exclude-pattern>*/Resources/*</exclude-pattern>
<!-- Include the whole Symfony standard (which pulls in PSR2) -->
<rule ref="Symfony">
<!-- exclude sniffs that are extended by this standard -->
<exclude name="PEAR.Functions.FunctionCallSignature"/>
<exclude name="PSR2.Namespaces.UseDeclaration"/>
<!-- SlevomatCodingStandard.Classes.DisallowMultiPropertyDefinition supports autofixing -->
<exclude name="PSR2.Classes.PropertyDeclaration.Multiple"/>
<!-- exclude sniffs that are disabled on purpose by this standard -->
<exclude name="Symfony.Commenting.ClassComment.Missing"/>
<exclude name="Symfony.Commenting.License"/>
</rule>
<!-- Also include PSR12 -->
<rule ref="PSR12">
<!-- exclude sniffs that are disabled on purpose by this standard -->
<exclude name="Generic.Files.LineLength.TooLong"/>
<!-- not compatible with other rules we have later on -->
<exclude name="PSR12.Classes.AnonClassDeclaration.SpaceAfterKeyword"/>
<exclude name="PSR12.ControlStructures.ControlStructureSpacing"/>
<exclude name="PSR12.Files.DeclareStatement"/>
<exclude name="PSR12.Operators.OperatorSpacing"/>
</rule>
<!-- Forbid strings in `"` unless necessary -->
<rule ref="Squiz.Strings.DoubleQuoteUsage.NotRequired"/>
<!-- There must be at least one space around operators -->
<rule ref="Squiz.WhiteSpace.OperatorSpacing">
<properties>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule>
<!-- Split long if statements onto several lines by PEAR rules -->
<rule ref="PEAR.ControlStructures.MultiLineCondition"/>
<!-- Force array element indentation with 4 spaces -->
<rule ref="Generic.Arrays.ArrayIndent"/>
<!-- Forbid `array(...)` -->
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
<!-- Force whitespace after a type cast -->
<rule ref="Generic.Formatting.SpaceAfterCast"/>
<!-- Align corresponding assignment statement tokens -->
<rule ref="Generic.Formatting.MultipleStatementAlignment">
<properties>
<property name="error" value="true"/>
</properties>
</rule>
<!-- Forbid useless inline string concatenation -->
<rule ref="Generic.Strings.UnnecessaryStringConcat">
<!-- But multiline is useful for readability -->
<properties>
<property name="allowMultiline" value="true"/>
</properties>
</rule>
<!-- Require one blank line between methods -->
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
<properties>
<property name="spacing" value="1"/>
<property name="spacingAfterLast" value="0"/>
<property name="spacingBeforeFirst" value="0"/>
</properties>
</rule>
<!-- Require one blank line between properties -->
<rule ref="Squiz.WhiteSpace.MemberVarSpacing">
<properties>
<property name="spacingBeforeFirst" value="0"/>
</properties>
</rule>
<!-- Forbid spaces between parentheses and their content-->
<rule ref="Generic.WhiteSpace.ArbitraryParenthesesSpacing">
<properties>
<property name="ignoreNewlines" value="1"/>
</properties>
</rule>
<!-- Forbid multiple assignments -->
<rule ref="Squiz.PHP.DisallowMultipleAssignments"/>
<!-- Require exactly one blank line after trait use -->
<rule ref="PSR12.Traits.UseDeclaration"/>
<!-- Forbid whitespace between array access operator and the variable or between array access operators. -->
<rule ref="SlevomatCodingStandard.Arrays.ArrayAccess"/>
<!-- Sort attributes alphabetically -->
<rule ref="SlevomatCodingStandard.Attributes.AttributesOrder">
<properties>
<property name="orderAlphabetically" value="true"/>
</properties>
</rule>
<!-- Disallow multiple attributes inside one #[] -->
<rule ref="SlevomatCodingStandard.Attributes.DisallowAttributesJoining"/>
<!-- Require only one attribute per line -->
<rule ref="SlevomatCodingStandard.Attributes.DisallowMultipleAttributesPerLine"/>
<!-- Force Enum Spacing-->
<rule ref="SlevomatCodingStandard.Classes.BackedEnumTypeSpacing"/>
<!-- Require presence of constant visibility -->
<rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility"/>
<!-- Forbid multi constant definition -->
<rule ref="SlevomatCodingStandard.Classes.DisallowMultiConstantDefinition"/>
<!-- Forbid multi property definition -->
<rule ref="SlevomatCodingStandard.Classes.DisallowMultiPropertyDefinition"/>
<!-- Forbid empty lines after class/interface/trait opening and before closing braces -->
<rule ref="SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces">
<properties>
<property name="linesCountAfterOpeningBrace" value="0"/>
<property name="linesCountBeforeClosingBrace" value="0"/>
</properties>
</rule>
<!-- Forbid empty lines around Enum cases -->
<rule ref="SlevomatCodingStandard.Classes.EnumCaseSpacing">
<properties>
<property name="minLinesCountBeforeWithComment" value="0"/>
<property name="maxLinesCountBeforeWithComment" value="0"/>
<property name="minLinesCountBeforeWithoutComment" value="0"/>
<property name="maxLinesCountBeforeWithoutComment" value="0"/>
</properties>
</rule>
<!-- Forbid properties to be public -->
<rule ref="SlevomatCodingStandard.Classes.ForbiddenPublicProperty">
<properties>
<property name="checkPromoted" value="true"/>
</properties>
</rule>
<!-- Require usage of ::class instead of __CLASS__, get_class(), get_class($this), get_called_class() and get_parent_class() -->
<rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/>
<!-- report invalid format of inline phpDocs with @var -->
<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration"/>
<!-- Forbid useless @inheritDoc comments -->
<rule ref="SlevomatCodingStandard.Commenting.UselessInheritDocComment"/>
<!-- Forbid assignments in conditions -->
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/>
<!-- Require consistent spacing for control structures -->
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing">
<properties>
<property name="controlStructures" type="array">
<element value="if"/>
<element value="do"/>
<element value="while"/>
<element value="for"/>
<element value="foreach"/>
<element value="switch"/>
<element value="try"/>
</property>
</properties>
</rule>
<!-- Require usage of early exit -->
<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit"/>
<!-- Require consistent spacing for jump statements -->
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing"/>
<!-- Require new instances with parentheses -->
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses"/>
<!-- Require usage of null coalesce operator when possible -->
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator"/>
<!-- Require usage of ternary operator when possible -->
<rule ref="SlevomatCodingStandard.ControlStructures.RequireTernaryOperator">
<!-- But multiline is useful for readability -->
<properties>
<property name="ignoreMultiLine" value="true"/>
</properties>
</rule>
<!-- Enforce consistent spacing of named arguments -->
<rule ref="SlevomatCodingStandard.Functions.NamedArgumentSpacing"/>
<!-- Require static closures for microoptimization -->
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/>
<!-- Forbid unused function parameters -->
<rule ref="SlevomatCodingStandard.Functions.UnusedParameter"/>
<!-- Forbids useless parameter default values -->
<rule ref="SlevomatCodingStandard.Functions.UselessParameterDefaultValue"/>
<!-- Require global functions to be referenced via a fully qualified name -->
<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalFunctions"/>
<!-- Forbid multiple use statements on same line -->
<rule ref="SlevomatCodingStandard.Namespaces.MultipleUsesPerLine"/>
<!-- Require one newline around namespace declaration -->
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceSpacing">
<properties>
<property name="linesCountBeforeNamespace" value="1"/>
<property name="linesCountAfterNamespace" value="1"/>
</properties>
</rule>
<!-- Forbid unused use statements -->
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
<properties>
<property name="searchAnnotations" value="true"/>
<property name="ignoredAnnotationNames" type="array">
<element value="@group"/>
</property>
</properties>
</rule>
<!-- Forbid useless alias for classes, constants and functions -->
<rule ref="SlevomatCodingStandard.Namespaces.UselessAlias"/>
<!-- Require empty newlines before and after uses -->
<rule ref="SlevomatCodingStandard.Namespaces.UseSpacing">
<properties>
<property name="linesCountBeforeFirstUse" value="1"/>
<property name="linesCountBetweenUseTypes" value="0"/>
<property name="linesCountAfterLastUse" value="1"/>
</properties>
</rule>
<!-- Require the usage of assignment operators, eg `+=`, `.=` when possible -->
<rule ref="SlevomatCodingStandard.Operators.RequireCombinedAssignmentOperator"/>
<!-- Report ++ and minus-minus operators not used standalone -->
<rule ref="SlevomatCodingStandard.Operators.RequireOnlyStandaloneIncrementAndDecrementOperators"/>
<!-- Enforce no spacing after spread operator -->
<rule ref="SlevomatCodingStandard.Operators.SpreadOperatorSpacing"/>
<!-- Report (...) used with opcode optimized builtin functions -->
<rule ref="SlevomatCodingStandard.PHP.OptimizedFunctionsWithoutUnpacking"/>
<!-- Forbid `list(...)` syntax -->
<rule ref="SlevomatCodingStandard.PHP.ShortList"/>
<!-- Forbid useless semicolon `;` -->
<rule ref="SlevomatCodingStandard.PHP.UselessSemicolon"/>
<!-- Enforce generics syntax in array typehints -->
<rule ref="SlevomatCodingStandard.TypeHints.DisallowArrayTypeHintSyntax"/>
<!-- Require use of short versions of scalar types (i.e. int instead of integer) -->
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>
<!-- Require ? when default value is null -->
<rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/>
<!-- Enforces null type hint on last position in @var, @param and @return annotations. -->
<rule ref="SlevomatCodingStandard.TypeHints.NullTypeHintOnLastPosition"/>
<!-- Require one space between typehint and variable, require no space between nullability sign and typehint -->
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/>
<!-- Require one space after and no space before colon in return types -->
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing"/>
<!-- Require parameter type hints to be declared -->
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint">
<properties>
<property name="enableMixedTypeHint" value="false"/>
<property name="enableUnionTypeHint" value="false"/>
<property name="enableIntersectionTypeHint" value="false"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint.UselessAnnotation">
<severity>0</severity>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingTraversableTypeHintSpecification">
<severity>0</severity>
</rule>
<!-- Require return type hints to be declared -->
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
<properties>
<property name="enableMixedTypeHint" value="false"/>
<property name="enableUnionTypeHint" value="false"/>
<property name="enableIntersectionTypeHint" value="false"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.UselessAnnotation">
<severity>0</severity>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification">
<severity>0</severity>
</rule>
<!-- Forbid useless @var for constants -->
<rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint"/>
<!-- Forbid duplicate assignments to a variable -->
<rule ref="SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable"/>
<!-- Forbid unused variables -->
<rule ref="SlevomatCodingStandard.Variables.UnusedVariable">
<properties>
<property name="ignoreUnusedValuesWhenOnlyKeysAreUsedInForeach" value="true"/>
</properties>
</rule>
<!-- These should get handled by the upstream Symfony standard later -->
<rule ref="SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace"/>
<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly">
<properties>
<property name="allowFullyQualifiedGlobalClasses" value="true"/>
<property name="allowFullyQualifiedGlobalConstants" value="true"/>
<property name="allowFullyQualifiedGlobalFunctions" value="true"/>
<property name="allowFullyQualifiedExceptions" value="true"/>
<property name="searchAnnotations" value="true"/>
</properties>
</rule>
</ruleset>