Skip to content

Latest commit

 

History

History
1735 lines (973 loc) · 113 KB

File metadata and controls

1735 lines (973 loc) · 113 KB

Rules

Generated by composer reference from the rule classes; do not edit. 214 rules.

By category

Arrays (7): arraySpacing, multilineArray, noManualListTests, noNullArrayKeys, shortArraySyntax, spreadForArrayMerge, trailingComma

Classes (32): classConstantForConstantCall, classDefinitionSpacing, classNameReferenceForString, finalInternalClass, getClassNotation, kindInClassName, nameCasing, noConstructorReturnValues, noFinalParents, noNullDebugInfo, noSleepAndWakeup, noStaticThis, noUnimplementedAbstractMethods, orderedMembers, overrideAttributeRequired, overrideSignature, promotedPropertyForAssignment, readonlyClassForReadonlyMembers, readonlyForAnnotation, readonlyForUnwrittenProperty, selfForCurrentClass, serializeMethodsRequired, singleMemberPerDeclaration, singleMemberPerLine, staticForMethodWithoutThis, staticSetStateRequired, stringableRequired, uselessModifier, uselessNullInitialization, uselessOverridingMethod, uselessReturnTypeWillChange, visibilityRequired

Comments (3): commentSpacing, noEmptyComments, noHashComments

ControlFlow (24): arrayFunctionForFilter, arrayFunctionForForeach, controlStructureBraces, earlyExit, elseifKeyword, fallThroughComment, matchForSwitch, multilineCondition, noAlternativeSyntax, noContinueInSwitch, noEmptyStatements, noFinallyReturns, noUnreachableCatches, referenceThrowableOnly, returnForBooleanIf, switchCaseColon, switchCaseSpacing, ternaryForIf, throwExpressionForNullGuard, uselessBraces, uselessCatchVariable, uselessConstructParentheses, uselessElse, uselessReturn

Expressions (30): binaryOperatorSpacing, castCanonicalType, castSpacing, cloneWithNotation, combinedAssignmentForRepeatedTarget, concatSpacing, doubleColonSpacing, emptyArgumentParentheses, explicitOperatorPrecedence, incrementForAddOne, multilineChain, multilineTernary, noErrorSuppression, noShortBoolCasts, notEqualsNotation, nullCoalescingForNullTernary, nullsafeForGuardedAccess, objectOperatorSpacing, offsetBracketSpacing, pipeOperator, referenceSpacing, shortTernaryForRepeatedCondition, spreadOperatorSpacing, strictComparison, symbolicLogicalOperators, ternaryOperatorSpacing, unaryOperatorSpacing, uselessParenthesesAroundNew, uselessTernaryOperator, yoda

Files (10): declareSpacing, eofLineEnding, fullOpeningTag, lineEnding, lineLength, noBom, noClosingTag, noInvisibleCharacters, noTrailingWhitespace, strictTypesRequired

Functions (35): arrayFirstNotation, arrowFunction, callableNotation, clampForMinMax, commentedOutFunction, csvEscapeArgumentRequired, firstClassCallableForStrings, functionNameSpacing, getDebugTypeForTernary, jsonValidateForDecode, mbConvertEncodingForUtf8, multilineCall, multilineSignature, namedArgumentSpacing, newInitializerForNullDefault, noAliasFunctions, noCallUserFunc, noConversionFunctions, noDeprecatedArguments, noDeprecatedFunctions, noDirectInvokeCalls, noDirnameOfFile, noInnerFunctions, noIsNull, noManualEmptyStringTests, noManualSubstringTests, noSettype, optimizedCallNotation, roundingModeNotation, sensitiveParameterRequired, staticClosure, strictCall, uselessArguments, uselessNoOpCall, uselessParameterDefault

Literals (11): complexStringVariable, heredocIndentation, keywordCasing, noBacktickOperators, noImplicitBackslashes, noTrailingWhitespaceInString, nowdocWithoutInterpolation, numericLiteralSeparator, octalNotation, stringQuotes, uselessStringConcat

Namespaces (12): importNotation, multilineImport, nameFallback, nameNotation, nativeNameCasing, noReservedNames, noUnlistedNamespacedDeclarations, orderedImports, unusedImports, uselessAlias, uselessLeadingBackslash, uselessSameNamespaceImport

PhpDoc (19): annotationCasing, attributeAfterPhpdoc, deprecatedAttributeForAnnotation, explicitAssertion, forbiddenAnnotations, forbiddenPhpdocLines, noConsecutivePhpdocs, noEmptyPhpdocs, noMismatchedFunctionAnnotations, noMismatchedPropertyAnnotations, phpdocAlignment, phpdocTrim, phpdocTypeNotation, promotedPropertyAnnotationPosition, propertyPhpdocRequired, propertyPhpdocSingleline, uselessConstantVarAnnotation, uselessFunctionPhpdoc, uselessInheritdoc

Types (5): neverForThrowingFunction, nullableTypeForDefaultNull, typeHintRequired, typeHintSpacing, typeNotation

Upgrading (11): attributeForAnnotation, attributeForMember, forbiddenClasses, forbiddenFunctions, forbiddenMembers, noDeprecatedClasses, noDeprecatedMembers, replacedCalls, replacedClasses, replacedFunctions, replacedMembers

Variables (4): combinedIssets, combinedUnsets, noDuplicateAssignments, noGlobalStatements

Whitespace (11): attributePosition, attributeSpacing, blankLines, bracesPosition, commaSpacing, constructSpacing, indentation, parenthesesSpacing, semicolonSpacing, singleLevelIndentation, singleStatementPerLine

By kind of problem

Alignment (1): phpdocAlignment

Casing (4): annotationCasing, keywordCasing, nameCasing, nativeNameCasing

Forbidden (45): noAliasFunctions, noBacktickOperators, noBom, noCallUserFunc, noClosingTag, noConsecutivePhpdocs, noConstructorReturnValues, noContinueInSwitch, noConversionFunctions, noDeprecatedArguments, noDeprecatedClasses, noDeprecatedFunctions, noDeprecatedMembers, noDirectInvokeCalls, noDirnameOfFile, noDuplicateAssignments, noEmptyComments, noEmptyPhpdocs, noEmptyStatements, noErrorSuppression, noFinalParents, noFinallyReturns, noGlobalStatements, noHashComments, noImplicitBackslashes, noInnerFunctions, noInvisibleCharacters, noIsNull, noManualEmptyStringTests, noManualListTests, noManualSubstringTests, noMismatchedFunctionAnnotations, noMismatchedPropertyAnnotations, noNullArrayKeys, noNullDebugInfo, noReservedNames, noSettype, noShortBoolCasts, noSleepAndWakeup, noStaticThis, noTrailingWhitespace, noTrailingWhitespaceInString, noUnimplementedAbstractMethods, noUnlistedNamespacedDeclarations, noUnreachableCatches

Indentation (2): heredocIndentation, singleLevelIndentation

Line breaks (7): multilineArray, multilineCall, multilineChain, multilineCondition, multilineImport, multilineSignature, multilineTernary

Notation (15): arrayFirstNotation, callableNotation, castCanonicalType, cloneWithNotation, getClassNotation, importNotation, nameNotation, noAlternativeSyntax, notEqualsNotation, octalNotation, optimizedCallNotation, phpdocTypeNotation, roundingModeNotation, shortArraySyntax, typeNotation

Other (47): arrowFunction, attributeAfterPhpdoc, blankLines, combinedIssets, combinedUnsets, commentedOutFunction, complexStringVariable, controlStructureBraces, earlyExit, elseifKeyword, emptyArgumentParentheses, eofLineEnding, explicitAssertion, explicitOperatorPrecedence, fallThroughComment, finalInternalClass, forbiddenAnnotations, forbiddenClasses, forbiddenFunctions, forbiddenMembers, forbiddenPhpdocLines, fullOpeningTag, indentation, kindInClassName, lineEnding, lineLength, nameFallback, nowdocWithoutInterpolation, numericLiteralSeparator, overrideSignature, phpdocTrim, pipeOperator, propertyPhpdocSingleline, referenceThrowableOnly, replacedCalls, replacedClasses, replacedFunctions, replacedMembers, staticClosure, strictCall, strictComparison, stringQuotes, switchCaseColon, symbolicLogicalOperators, trailingComma, unusedImports, yoda

Position (3): attributePosition, bracesPosition, promotedPropertyAnnotationPosition

Redundancy (21): uselessAlias, uselessArguments, uselessBraces, uselessCatchVariable, uselessConstantVarAnnotation, uselessConstructParentheses, uselessElse, uselessFunctionPhpdoc, uselessInheritdoc, uselessLeadingBackslash, uselessModifier, uselessNoOpCall, uselessNullInitialization, uselessOverridingMethod, uselessParameterDefault, uselessParenthesesAroundNew, uselessReturn, uselessReturnTypeWillChange, uselessSameNamespaceImport, uselessStringConcat, uselessTernaryOperator

Replacement (31): arrayFunctionForFilter, arrayFunctionForForeach, attributeForAnnotation, attributeForMember, clampForMinMax, classConstantForConstantCall, classNameReferenceForString, combinedAssignmentForRepeatedTarget, deprecatedAttributeForAnnotation, firstClassCallableForStrings, getDebugTypeForTernary, incrementForAddOne, jsonValidateForDecode, matchForSwitch, mbConvertEncodingForUtf8, neverForThrowingFunction, newInitializerForNullDefault, nullCoalescingForNullTernary, nullableTypeForDefaultNull, nullsafeForGuardedAccess, promotedPropertyForAssignment, readonlyClassForReadonlyMembers, readonlyForAnnotation, readonlyForUnwrittenProperty, returnForBooleanIf, selfForCurrentClass, shortTernaryForRepeatedCondition, spreadForArrayMerge, staticForMethodWithoutThis, ternaryForIf, throwExpressionForNullGuard

Required (10): csvEscapeArgumentRequired, overrideAttributeRequired, propertyPhpdocRequired, sensitiveParameterRequired, serializeMethodsRequired, staticSetStateRequired, strictTypesRequired, stringableRequired, typeHintRequired, visibilityRequired

Shape (5): orderedImports, orderedMembers, singleMemberPerDeclaration, singleMemberPerLine, singleStatementPerLine

Spacing (23): arraySpacing, attributeSpacing, binaryOperatorSpacing, castSpacing, classDefinitionSpacing, commaSpacing, commentSpacing, concatSpacing, constructSpacing, declareSpacing, doubleColonSpacing, functionNameSpacing, namedArgumentSpacing, objectOperatorSpacing, offsetBracketSpacing, parenthesesSpacing, referenceSpacing, semicolonSpacing, spreadOperatorSpacing, switchCaseSpacing, ternaryOperatorSpacing, typeHintSpacing, unaryOperatorSpacing

By group

A project asks for a group by name (use: [cleanup]) and gets every rule of it with the options it defaults to.

no group, so a standard chooses it or the project names it (107): annotationCasing, arraySpacing, attributeAfterPhpdoc, attributeForAnnotation, attributeForMember, attributePosition, attributeSpacing, binaryOperatorSpacing, blankLines, bracesPosition, castSpacing, classDefinitionSpacing, commaSpacing, commentSpacing, concatSpacing, constructSpacing, controlStructureBraces, declareSpacing, doubleColonSpacing, earlyExit, elseifKeyword, emptyArgumentParentheses, eofLineEnding, explicitAssertion, explicitOperatorPrecedence, fallThroughComment, finalInternalClass, forbiddenAnnotations, forbiddenClasses, forbiddenFunctions, forbiddenMembers, forbiddenPhpdocLines, fullOpeningTag, functionNameSpacing, heredocIndentation, importNotation, incrementForAddOne, indentation, keywordCasing, kindInClassName, lineEnding, lineLength, multilineArray, multilineCall, multilineChain, multilineCondition, multilineImport, multilineSignature, multilineTernary, nameCasing, nameFallback, nameNotation, namedArgumentSpacing, nativeNameCasing, noAlternativeSyntax, noBom, noClosingTag, noGlobalStatements, noHashComments, noImplicitBackslashes, noInnerFunctions, noShortBoolCasts, noTrailingWhitespace, noUnlistedNamespacedDeclarations, notEqualsNotation, nowdocWithoutInterpolation, numericLiteralSeparator, objectOperatorSpacing, offsetBracketSpacing, orderedImports, orderedMembers, overrideAttributeRequired, parenthesesSpacing, phpdocAlignment, phpdocTrim, promotedPropertyAnnotationPosition, propertyPhpdocRequired, propertyPhpdocSingleline, readonlyClassForReadonlyMembers, readonlyForAnnotation, readonlyForUnwrittenProperty, referenceSpacing, replacedCalls, replacedClasses, replacedFunctions, replacedMembers, selfForCurrentClass, semicolonSpacing, sensitiveParameterRequired, singleLevelIndentation, singleMemberPerDeclaration, singleMemberPerLine, singleStatementPerLine, spreadOperatorSpacing, staticClosure, staticForMethodWithoutThis, strictComparison, strictTypesRequired, stringQuotes, switchCaseSpacing, symbolicLogicalOperators, ternaryOperatorSpacing, trailingComma, typeHintSpacing, unaryOperatorSpacing, visibilityRequired, yoda

modernization (31): arrayFirstNotation, arrayFunctionForFilter, arrayFunctionForForeach, arrowFunction, callableNotation, clampForMinMax, classConstantForConstantCall, cloneWithNotation, combinedAssignmentForRepeatedTarget, combinedIssets, combinedUnsets, deprecatedAttributeForAnnotation, getClassNotation, getDebugTypeForTernary, jsonValidateForDecode, matchForSwitch, newInitializerForNullDefault, noManualListTests, noManualSubstringTests, noSleepAndWakeup, nullCoalescingForNullTernary, nullsafeForGuardedAccess, octalNotation, pipeOperator, promotedPropertyForAssignment, roundingModeNotation, shortArraySyntax, shortTernaryForRepeatedCondition, spreadForArrayMerge, ternaryForIf, throwExpressionForNullGuard

deprecations (20): castCanonicalType, complexStringVariable, csvEscapeArgumentRequired, firstClassCallableForStrings, mbConvertEncodingForUtf8, noBacktickOperators, noConstructorReturnValues, noDeprecatedArguments, noDeprecatedClasses, noDeprecatedFunctions, noDeprecatedMembers, noFinalParents, noFinallyReturns, noNullArrayKeys, noReservedNames, noUnimplementedAbstractMethods, nullableTypeForDefaultNull, overrideSignature, serializeMethodsRequired, switchCaseColon

cleanup (32): classNameReferenceForString, commentedOutFunction, noAliasFunctions, noCallUserFunc, noDirectInvokeCalls, noEmptyComments, noEmptyPhpdocs, noEmptyStatements, noManualEmptyStringTests, returnForBooleanIf, unusedImports, uselessAlias, uselessArguments, uselessBraces, uselessCatchVariable, uselessConstantVarAnnotation, uselessConstructParentheses, uselessElse, uselessFunctionPhpdoc, uselessInheritdoc, uselessLeadingBackslash, uselessModifier, uselessNoOpCall, uselessNullInitialization, uselessOverridingMethod, uselessParameterDefault, uselessParenthesesAroundNew, uselessReturn, uselessReturnTypeWillChange, uselessSameNamespaceImport, uselessStringConcat, uselessTernaryOperator

types (5): neverForThrowingFunction, phpdocTypeNotation, stringableRequired, typeHintRequired, typeNotation

correctness (14): noConsecutivePhpdocs, noContinueInSwitch, noDuplicateAssignments, noErrorSuppression, noInvisibleCharacters, noMismatchedFunctionAnnotations, noMismatchedPropertyAnnotations, noNullDebugInfo, noStaticThis, noTrailingWhitespaceInString, noUnreachableCatches, referenceThrowableOnly, staticSetStateRequired, strictCall

optimizedCalls (5): noConversionFunctions, noDirnameOfFile, noIsNull, noSettype, optimizedCallNotation

By the version of PHP a rule needs

A rule writing a construct older than PHP 8.0, which every target has, is in none of these.

PHP 8.1 (9): callableNotation, firstClassCallableForStrings, neverForThrowingFunction, newInitializerForNullDefault, noManualListTests, octalNotation, readonlyForAnnotation, readonlyForUnwrittenProperty, spreadForArrayMerge

PHP 8.2 (2): readonlyClassForReadonlyMembers, sensitiveParameterRequired

PHP 8.3 (3): classConstantForConstantCall, jsonValidateForDecode, overrideAttributeRequired

PHP 8.4 (5): arrayFunctionForFilter, arrayFunctionForForeach, deprecatedAttributeForAnnotation, roundingModeNotation, uselessParenthesesAroundNew

PHP 8.5 (3): arrayFirstNotation, cloneWithNotation, pipeOperator

PHP 8.6 (1): clampForMinMax

The rules

dresscode/annotationCasing

Writes known annotations in their canonical case.

Stage: Structure. Covers: SlevomatCodingStandard.Commenting.AnnotationName. Modifies comments.

dresscode/arrayFirstNotation

Replaces reset(), end() and the other ways of reading the first or the last element of an array with array_first() and array_last().

Stage: Structure. Needs PHP >=8.5. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

dresscode/arrayFunctionForFilter

Replaces an array_filter() built only to ask whether any or every item passes, or which passes first, with array_any(), array_all(), array_find() or array_find_key().

Stage: Structure. Needs PHP >=8.4. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

dresscode/arrayFunctionForForeach

Replaces a foreach that only searches or tests its items with array_any(), array_all(), array_find() or array_find_key().

Stage: Structure. Needs PHP >=8.4.

dresscode/arraySpacing

Removes whitespace inside the brackets of an array.

Stage: Formatting. Covers: trim_array_spaces, SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace.

dresscode/arrowFunction

Replaces a closure returning a single expression with an arrow function.

Stage: Structure. Covers: SlevomatCodingStandard.Functions.RequireArrowFunction.

Option Type Default
nested bool true A closure containing another closure or arrow function is converted too

dresscode/attributeAfterPhpdoc

Moves a doc comment written after the attributes above them.

Stage: Structure. Covers: SlevomatCodingStandard.Attributes.RequireAttributeAfterDocComment. Modifies comments.

dresscode/attributeForAnnotation

Writes the attribute a project or its libraries read instead of an annotation.

Stage: Structure. Modifies comments.

Options: The annotation, without the @, the class of an attribute, fully qualified, or a namespace of annotations, Acme\Validation\* → the attribute written instead, its class fully qualified, with its arguments where it has any, or the namespace of the attributes, Acme\Validation\*.

dresscode/attributeForMember

Writes the attribute of a class a library reads instead of a member the class declares.

Stage: Structure. Modifies comments.

Options: The member of an ancestor, Class::$name, Class::method() or 'Class::$name = literal' for that value only, or an interface the class implements → the attribute written instead, $value standing for the value of the property or what the method returns.

dresscode/attributePosition

Puts the attributes of a declaration on lines of their own above it.

Stage: Formatting. Covers: SlevomatCodingStandard.Attributes.DisallowMultipleAttributesPerLine.

Option Type Default
parameter ownLine | keep "ownLine" ownLine puts the attributes of a parameter on lines of their own in a list of parameters spread over lines and on the line of the parameter in a list on one line, keep leaves them

dresscode/attributeSpacing

Removes whitespace inside the brackets of an attribute group.

Stage: Formatting. Covers: attribute_block_no_spaces.

dresscode/binaryOperatorSpacing

Puts spaces around binary operators.

Stage: Formatting. Covers: binary_operator_spaces, PSR12.Operators.OperatorSpacing, Squiz.ControlStructures.ForEachLoopDeclaration, Squiz.WhiteSpace.LogicalOperatorSpacing, Squiz.WhiteSpace.OperatorSpacing.

Option Type Default
alignment none | spaces | tabs | keep "spaces" Which alignment around an operator stays: none collapses it to a single space, spaces and tabs keep the one written with them, keep keeps any
operatorPosition keep | start "keep" Where a binary operator at a line break stands, except a boolean operator chaining a condition, which dresscode/multilineCondition places: keep leaves it where it is, start moves one ending a line to the start of the next unless a comment follows it or the rule joins the lines

dresscode/blankLines

Sets how many blank lines stand in the header of a file, around declarations, among the members of a class, inside a block and between statements of a kind.

Stage: Formatting. Covers: blank_line_after_namespace, blank_line_after_opening_tag, blank_line_before_statement, blank_line_between_import_groups, blank_lines_before_namespace, no_blank_lines_after_class_opening, no_blank_lines_after_phpdoc, no_extra_blank_lines, single_line_after_imports, PSR12.Classes.OpeningBraceSpace, PSR12.Files.FileHeader, PSR12.Files.OpenTag, PSR12.Traits.UseDeclaration, PSR2.Methods.FunctionClosingBrace, PSR2.Namespaces.UseDeclaration, SlevomatCodingStandard.Attributes.AttributeAndTargetSpacing, SlevomatCodingStandard.Classes.ConstantSpacing, SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces, SlevomatCodingStandard.Classes.PropertySpacing, SlevomatCodingStandard.Classes.TraitUseSpacing, SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing, SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing, Squiz.WhiteSpace.ControlStructureSpacing, Squiz.WhiteSpace.FunctionOpeningBraceSpace, Squiz.WhiteSpace.FunctionSpacing.

Option Type Default
afterOpeningTag keep | int | [int, ?int] 1 After the line of <?php, which then carries no code; a file with markup outside PHP keeps its tag
beforeNamespace keep | int | [int, ?int] 1 Before the namespace declaration and, where a doc comment of the file stands above it, also between the two
afterNamespace keep | int | [int, ?int] 1 After an unbraced namespace declaration
afterImports keep | int | [int, ?int] 1 After the last import, before the rest of the code
betweenImportGroups keep | int | [int, ?int] 1 Between imports of classes, functions and constants; imports of one group never have a blank line between them
beforeDeclaration keep | int | [int, ?int] "keep" Before a class, interface, trait, enum or function that follows the namespace or the imports, in place of afterNamespace and afterImports
betweenDeclarations keep | int | [int, ?int] 2 Before and after a class, interface, trait, enum or function declared among statements, where the header above it does not decide
betweenMethods keep | int | [int, ?int] 2 Before and after a method; the first and last method of a class use beforeFirstMethod and afterLastMethod
betweenInterfaceMethods keep | int | [int, ?int] 1 In place of betweenMethods among the methods of an interface
beforeFirstMethod keep | int | [int, ?int] 0 Before a method that is the first member of its class
afterLastMethod keep | int | [int, ?int] 0 After a method that is the last member of its class
beforeFirstMember keep | int | [int, ?int] 0 Before the first member, unless it is a method: then beforeFirstMethod applies
afterLastMember keep | int | [int, ?int] 0 After the last member, unless it is a method: then afterLastMethod applies
betweenTraitUses keep | int | [int, ?int] 0
afterTraitUses keep | int | [int, ?int] 1 Before the first member after the trait uses, a method included
betweenMembers keep | int | [int, ?int] [0,1] Between properties, constants and enum cases without a doc comment or attribute
beforeDocumentedMember keep | int | [int, ?int] 1 Before a property, constant or enum case with a doc comment or an attribute
afterPhpdoc keep | int | [int, ?int] 0 Between a doc comment or an attribute and the declaration it belongs to
afterBlockOpeningBrace keep | int | [int, ?int] 0 After the opening brace of a block
beforeBlockClosingBrace keep | int | [int, ?int] "keep" Before the closing brace of a block; kept by default, because such a line separates the branches of a } catch or } else chain
betweenBranches lastSetApart | keep | int | [int, ?int] "keep" Before the closing brace of a branch of if or try that else, elseif, catch or finally follows, in place of beforeBlockClosingBrace; lastSetApart asks for one where the last statement of the branch is set apart by a blank line, which would otherwise read as belonging to the next branch, and keeps the others
betweenCases lastSetApart | keep | int | [int, ?int] "keep" Before a case or default of a switch that follows a case with statements, below a comment right under those statements; lastSetApart asks for one where the last statement of that case is set apart by a blank line, and keeps the others
before array {"return":[1,null]} Blank lines before a statement of the kind, as a count or a range [min, max] with null for no bound; yield means a statement made of a yield expression
after array [] Blank lines after a statement of the kind, before the next statement

dresscode/bracesPosition

Positions the braces of classes, functions and control structures, and the keywords between them.

Stage: Formatting. Covers: braces_position, control_structure_continuation_position, PSR12.Classes.AnonClassDeclaration, PSR12.Files.DeclareStatement, PSR2.Classes.ClassDeclaration, Squiz.ControlStructures.ControlSignature, Squiz.Functions.MultiLineFunctionDeclaration, Squiz.WhiteSpace.ScopeClosingBrace.

Option Type Default
multilineParameters sameLine | nextLine | nextLineAfterReturnType "sameLine" The opening brace of a function whose parameters span several lines; nextLineAfterReturnType puts it on the next line only after a return type
class sameLine | nextLine "nextLine" Classes, interfaces, traits and enums
anonymousClass sameLine | nextLine "sameLine"
anonymousFunction sameLine | nextLine "sameLine"
controlStructure sameLine | nextLine "sameLine"
singlelineAnonymousFunction always | keep "keep" A closure written whole on one line: always gives its braces the position of any other, keep leaves it there
emptyAnonymousClass sameLine | ownLine "sameLine" sameLine leaves an empty anonymous class written on one line there, ownLine puts its closing brace on a line of its own as in any other anonymous class
emptyBody sameLine | ownLine "ownLine" sameLine writes an empty body of a class, function, closure, anonymous class or property hook as {} on the line of its head, ownLine places its braces as those of any other body; a comment inside makes a body not empty
continuation sameLine | nextLine "sameLine" The keyword continuing a structure (else, elseif, catch, finally, the while of do) on the line of the closing brace, or on the next one

dresscode/callableNotation

Writes Closure::fromCallable() and a closure forwarding its arguments to one call as a first-class callable, or from PHP 8.6 as a partial application.

Stage: Structure. Needs PHP >=8.1. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

dresscode/castCanonicalType

Writes a cast with the short type name in lowercase.

Stage: Structure. Covers: lowercase_cast, short_scalar_cast, Generic.PHP.LowerCaseType, PSR12.Keywords.ShortFormTypeKeywords, SlevomatCodingStandard.PHP.TypeCast, Squiz.WhiteSpace.CastSpacing.

dresscode/castSpacing

Puts a single space between a cast and its operand.

Stage: Formatting. Covers: cast_spaces.

Option Type Default
spacing single | none "single"

dresscode/clampForMinMax

Replaces a max() around a min() holding a value between bounds with clamp().

Stage: Structure. Needs PHP >=8.6. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

dresscode/classConstantForConstantCall

Replaces constant() asking for a class constant by its name with the fetch of the constant, X::{$name}.

Stage: Structure. Needs PHP >=8.3.

dresscode/classDefinitionSpacing

Puts single spaces in the head of a class declaration.

Stage: Formatting. Covers: class_definition, PSR12.Classes.AnonClassDeclaration, PSR2.Classes.ClassDeclaration.SpaceBeforeKeyword.

Option Type Default
beforeParenthesis single | none "single" Between class and the arguments of an anonymous class: single writes new class ($a), none writes new class($a)

dresscode/classNameReferenceForString

Writes a class name held in a string as ::class.

Stage: Structure. Covers: class_keyword. Needs the types of the code, so it runs only with types: phpstan. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

dresscode/cloneWithNotation

Writes a clone followed by assignments to the properties of the copy as clone($object, [...]).

Stage: Structure. Needs PHP >=8.5. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

dresscode/combinedAssignmentForRepeatedTarget

Writes an assignment repeating its target, $a = $a + $b, with the combined operator, $a += $b.

Stage: Structure. Covers: assign_null_coalescing_to_coalesce_equal, SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator, SlevomatCodingStandard.Operators.RequireCombinedAssignmentOperator. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

dresscode/combinedIssets

Merges the isset() calls of a && chain into one isset() of several variables.

Stage: Structure. Covers: combine_consecutive_issets.

dresscode/combinedUnsets

Joins consecutive unset() statements into one.

Stage: Structure. Covers: combine_consecutive_unsets.

dresscode/commaSpacing

Puts a single space after a comma and none before it.

Stage: Formatting. Covers: no_whitespace_before_comma_in_array, whitespace_after_comma_in_array, Generic.Functions.FunctionCallArgumentSpacing, Squiz.Functions.FunctionDeclarationArgumentSpacing.

Option Type Default
alignment none | spaces | tabs | keep "tabs" Which alignment after a comma stays: none collapses it to a single space, spaces and tabs keep the one written with them, keep keeps any

dresscode/commentSpacing

Puts a space after the marker of a comment and before a comment following code.

Stage: Finishing. Covers: PhpCsFixerCustomFixers/comment_surrounded_by_spaces, single_line_comment_spacing. Modifies comments.

Option Type Default
before atLeastOne | single | keep "atLeastOne" Whitespace before a comment following code on its line: atLeastOne keeps a wider gap such as an alignment, single collapses it to one space, keep leaves it alone

dresscode/commentedOutFunction

Comments out statements calling the configured debugging functions.

Stage: Structure. Covers: PhpCsFixerCustomFixers/commented_out_function. Modifies comments. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

Option Type Default
functions list of string ["print_r","var_dump","var_export"]

dresscode/complexStringVariable

Replaces the deprecated ${name} interpolation with {$name}.

Stage: Structure. Covers: simple_to_complex_string_variable.

dresscode/concatSpacing

Puts a single space around the concatenation operator.

Stage: Formatting. Covers: concat_space, PSR12.Operators.OperatorSpacing, Squiz.Strings.ConcatenationSpacing.

Option Type Default
spacing single | none "single"
operatorPosition keep | start "keep" Where the concatenation operator at a line break stands: keep leaves it where it is, start moves one ending a line to the start of the next unless a comment follows it

dresscode/constructSpacing

Puts a single space after a language construct and around the keyword continuing one, and none between fn and its parenthesis unless arrowFunction says otherwise.

Stage: Formatting. Covers: function_declaration, single_space_around_construct, Generic.WhiteSpace.LanguageConstructSpacing, PSR12.Traits.UseDeclaration, PSR2.ControlStructures.SwitchDeclaration, SlevomatCodingStandard.Functions.ArrowFunctionDeclaration, Squiz.ControlStructures.ForEachLoopDeclaration, Squiz.Functions.FunctionDeclaration.

Option Type Default
arrowFunction none | single | keep "none" Between fn and its parenthesis: none for fn(), as PER Coding Style writes it, single for fn (), keep leaves it as written
allowMultilineExpression bool false An expression spanning several lines may begin on the line below return, throw, yield, print or echo

dresscode/controlStructureBraces

Encloses the body of every control structure in braces.

Stage: Structure. Covers: control_structure_braces, Generic.ControlStructures.InlineControlStructure.

dresscode/csvEscapeArgumentRequired

Writes out the escape argument of the CSV functions, whose default PHP 8.4 deprecated.

Stage: Structure.

dresscode/declareSpacing

Removes whitespace inside a declare statement.

Stage: Formatting. Covers: declare_equal_normalize, declare_parentheses, PSR12.Files.DeclareStatement.

dresscode/deprecatedAttributeForAnnotation

Replaces the @deprecated annotation with the #[\Deprecated] attribute.

Stage: Structure. Needs PHP >=8.4. Modifies comments. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

dresscode/doubleColonSpacing

Removes whitespace around the double colon.

Stage: Formatting. Covers: no_space_around_double_colon, Squiz.WhiteSpace.ScopeKeywordSpacing.

dresscode/earlyExit

Turns a trailing if into a guard that leaves early, and an else that leaves into the first branch.

Stage: Structure. Covers: SlevomatCodingStandard.ControlStructures.EarlyExit.

Option Type Default
minStatements int 2 A trailing if is turned into a guard only when its body has at least this many statements

dresscode/elseifKeyword

Replaces else if with elseif.

Stage: Structure. Covers: elseif, PSR2.ControlStructures.ElseIfDeclaration.

dresscode/emptyArgumentParentheses

Adds or removes the empty parentheses of new and of an attribute, as the options choose.

Stage: Structure. Covers: attribute_empty_parentheses, new_with_braces, new_with_parentheses, PSR12.Classes.ClassInstantiation, SlevomatCodingStandard.ControlStructures.NewWithoutParentheses.

Option Type Default
namedClass required | forbidden | keep "required" new Foo, new static and new $class alike; new Foo()->bar() keeps them whatever this says, PHP 8.4 needing them there
anonymousClass required | forbidden | keep "required"
attribute required | forbidden | keep "forbidden"

dresscode/eofLineEnding

Ends the file with exactly one line ending.

Stage: Formatting. Covers: single_blank_line_at_eof, PSR2.Files.EndFileNewline.

dresscode/explicitAssertion

Replaces an inline @var annotation with an assert() of the type.

Stage: Structure. Covers: SlevomatCodingStandard.PHP.RequireExplicitAssertion. Modifies comments. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

dresscode/explicitOperatorPrecedence

Parenthesizes an operand where the precedence of logical or bitwise operators is easy to misread.

Stage: Structure. Covers: Generic.CodeAnalysis.RequireExplicitBooleanOperatorPrecedence.

dresscode/fallThroughComment

Marks a non-empty case falling through to the next one with a comment, and removes the comment where the case cannot fall through.

Stage: Structure. Covers: no_break_comment, PSR2.ControlStructures.SwitchDeclaration. Modifies comments.

Option Type Default
comment string "no break" Text of the fall-through comment, matched case-insensitively and inserted as a line comment

dresscode/finalInternalClass

Declares a class annotated with @internal as final.

Stage: Structure. Covers: final_internal_class. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

Option Type Default
requiredAnnotations list of string ["@internal"] Annotations a class must all carry to become final
exemptAnnotations list of string ["@final","@Entity","@ORM\\Entity","@ORM\\Mapping\\Entity","@Mapping\\Entity","@Document","@ODM\\Document"] Annotations that keep a class as it is

dresscode/firstClassCallableForStrings

Writes a callable naming self, parent or static in a string as a first-class callable.

Stage: Structure. Needs PHP >=8.1.

dresscode/forbiddenAnnotations

Removes the configured annotations from doc comments.

Stage: Structure. Covers: SlevomatCodingStandard.Commenting.ForbiddenAnnotations. Modifies comments.

Option Type Default
annotations list of string [] Annotations to remove, written with the @

dresscode/forbiddenClasses

Reports references of the configured classes with what to do instead.

Stage: Structure.

Options: The forbidden class, fully qualified → what to do instead, as the end of the message, or null for none.

dresscode/forbiddenFunctions

Reports calls of the configured functions with what to do instead.

Stage: Structure. Covers: Generic.PHP.ForbiddenFunctions, Generic.PHP.SAPIUsage, Squiz.PHP.DiscouragedFunctions.

Options: The forbidden function or a pattern with *, a name without a backslash meaning the global function → what to do instead, as the end of the message, or null for none.

dresscode/forbiddenMembers

Reports uses and declarations of the configured members with what to do instead.

Stage: Structure. Needs the types of the code, so it runs only with types: phpstan.

Options: The forbidden member, Class::name (a constant or a method), Class::name(...$args) (a method), Class::$name (a property), Class::$name::get or ::set (a read or a write of it), Class::__construct(...$args), or a call with the shape of its arguments, Class::name() being one without any → what to do instead, as the end of the message, or null for none.

dresscode/forbiddenPhpdocLines

Removes description lines matching the configured patterns from doc comments.

Stage: Structure. Covers: SlevomatCodingStandard.Commenting.ForbiddenComments. Modifies comments.

Option Type Default
patterns list of string [] Regular expressions matched against every line of a description

dresscode/fullOpeningTag

Writes the opening tag <? or <?PHP as <?php.

Stage: Structure. Covers: full_opening_tag, Generic.PHP.DisallowShortOpenTag.

dresscode/functionNameSpacing

Removes whitespace between a function name and its parentheses.

Stage: Formatting. Covers: no_spaces_after_function_name, Generic.Functions.FunctionCallArgumentSpacing.SpaceBeforeOpenBracket, PSR2.Methods.FunctionCallSignature, Squiz.Functions.FunctionDeclaration.

dresscode/getClassNotation

Replaces get_class(), get_called_class(), get_parent_class() and __CLASS__ with ::class.

Stage: Structure. Covers: SlevomatCodingStandard.Classes.ModernClassNameReference. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

Option Type Default
onObjects bool false get_class($object) becomes $object::class

dresscode/getDebugTypeForTernary

Replaces a ternary asking whether a value is an object with get_debug_type().

Stage: Structure. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

dresscode/heredocIndentation

Indents the body and the closing marker of a heredoc relative to its starting line.

Stage: Formatting. Covers: heredoc_indentation.

Option Type Default
indentation startPlusOne | sameAsStart "startPlusOne" startPlusOne indents the body one level deeper than the line the heredoc starts on, sameAsStart the same

dresscode/importNotation

Writes the imports of each kind one per use or all in one use, and expands a group use or writes the imports sharing a namespace as one.

Stage: Structure. Covers: group_import, single_import_per_statement, SlevomatCodingStandard.Namespaces.DisallowGroupUse, SlevomatCodingStandard.Namespaces.MultipleUsesPerLine.

Option Type Default
class single | combined | keep "single" single gives every class a use of its own, combined imports all classes of the file in one use, one per namespace declaration where the file has several; keep leaves them alone
function single | combined | keep "single"
constant single | combined | keep "single"
group expand | keep | combine "expand" expand turns a group use of a checked kind into the shape of that kind, keep leaves it as it is, combine writes the imports sharing a namespace as one group use
groupFrom int 2 With group: combine, the imports sharing a namespace stand in a group use once there are at least this many of them, inclusive, and in imports of their own while there are fewer

dresscode/incrementForAddOne

Replaces += 1 and -= 1 with ++ and --.

Stage: Structure. Covers: standardize_increment. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

dresscode/indentation

Indents every line by the construct it continues, one level per nesting.

Stage: Finishing. Covers: array_indentation, indentation_type, method_chaining_indentation, no_leading_namespace_whitespace, statement_indentation, Generic.WhiteSpace.DisallowSpaceIndent, Generic.WhiteSpace.DisallowTabIndent, Generic.WhiteSpace.ScopeIndent, PEAR.WhiteSpace.ObjectOperatorIndent, PSR12.ControlStructures.ControlStructureSpacing, PSR2.ControlStructures.SwitchDeclaration, PSR2.Methods.FunctionCallSignature, PSR2.Namespaces.NamespaceDeclaration, SlevomatCodingStandard.Arrays.MultiLineArrayEndBracketPlacement, Squiz.WhiteSpace.ScopeClosingBrace. Modifies comments.

Option Type Default
binary keep | int 0 Levels a line opened by a binary operator steps in by from the start of its expression, 1 at least where the expression shares its line with what holds it or begins its statement; keep leaves such lines alone
ternary keep | int 1 Levels the ? and : of a ternary opening a line step in by; keep leaves them alone
ternaryBelowCondition bool false The ? and : below a condition spread over lines step in from its last line, by a level at least, instead of lining up with its operators
switchCase keep | int 1 Levels the cases of a switch step in by; keep leaves them alone
chain single | nesting | keep "single" single puts every link of a chain one level below its start, nesting lets a link stand one level deeper or shallower than the link before it; keep leaves chains alone

dresscode/jsonValidateForDecode

Replaces json_decode() called only to test the input with json_validate().

Stage: Structure. Needs PHP >=8.3. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

dresscode/keywordCasing

Writes keywords in lowercase, and true, false, null and the magic constants in the case the options choose.

Stage: Structure. Covers: constant_case, lowercase_keywords, lowercase_static_reference, magic_constant_casing, Generic.PHP.LowerCaseConstant, Generic.PHP.LowerCaseKeyword, Generic.PHP.LowerCaseType, PSR2.ControlStructures.SwitchDeclaration, Squiz.ControlStructures.ForEachLoopDeclaration, Squiz.ControlStructures.LowercaseDeclaration, Squiz.Functions.LowercaseFunctionKeywords.

Option Type Default
keyword lower | keep "lower" Keywords, self and parent included
trueFalseNull lower | upper | keep "lower"
magicConstant upper | lower | keep "upper" __DIR__, __CLASS__ and the others

dresscode/kindInClassName

Reports a name repeating the kind of its type (FooInterface, AbstractFoo), or with required an interface, trait or abstract class whose name does not.

Stage: Structure. Covers: SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming, SlevomatCodingStandard.Classes.SuperfluousErrorNaming, SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming, SlevomatCodingStandard.Classes.SuperfluousTraitNaming. One decision, so a value written for the rule fills kind.

Option Type Default
kind forbidden | required "forbidden" forbidden reports a name repeating the kind, required reports one that does not carry it: FooInterface, FooTrait, AbstractFoo

dresscode/lineEnding

Ends every line with the line ending of the style, which may follow the file.

Stage: Finishing. Covers: line_ending, Generic.Files.LineEndings.

dresscode/lineLength

Reports lines longer than the line length.

Stage: Finishing. Covers: Generic.Files.LineLength, SlevomatCodingStandard.Files.LineLength.

Option Type Default
ignoreImports bool true A use import is never reported, it cannot be broken
ignorePatterns list of string [] Regular expressions; a line matching one is never reported

dresscode/matchForSwitch

Writes a switch whose every case assigns or returns one value as a match.

Stage: Structure. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

dresscode/mbConvertEncodingForUtf8

Replaces the deprecated utf8_encode() and utf8_decode() with mb_convert_encoding().

Stage: Structure. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

dresscode/multilineArray

Lays out an array written over several lines or too wide for one, an item on each line or several filling a line, the opening bracket staying on the line of the code before it.

Stage: Formatting.

Option Type Default
shape perLine | keep "perLine" perLine gives every item a line of its own, keep lets the items of an array spread by its author stand as they are
maxWidth ?int null An array of several items written on one line is spread over lines when it is wider than this, measured from bracket to bracket; with keep more than five items then fill each line up to the line length, and null never spreads an array for its width

dresscode/multilineCall

Puts every argument of a multi-line call on its own line, or only the parentheses on lines of their own.

Stage: Formatting. Covers: method_argument_space, PSR2.Methods.FunctionCallSignature.

Option Type Default
shape perLine | frame "perLine" perLine gives every argument a line of its own, frame only breaks the line after the opening parenthesis and before the closing one

dresscode/multilineChain

Puts every link of a multi-line chain of calls on its own line, the first one too unless leadingLinks is sameLine.

Stage: Formatting.

Option Type Default
leadingLinks ownLine | sameLine "ownLine" The links before the first one that begins a line: ownLine gives each of them a line too, sameLine leaves them on the line the chain starts on

dresscode/multilineCondition

Writes a condition of if, elseif, while and do-while in the shape the configuration asks for.

Stage: Formatting. Covers: PSR12.ControlStructures.BooleanOperatorPlacement, PSR12.ControlStructures.ControlStructureSpacing, SlevomatCodingStandard.ControlStructures.RequireMultiLineCondition.

Option Type Default
shape perLine | compact | keep | list of (perLine | compact) "perLine" The shape of a condition on several lines: perLine begins it on the line after the parenthesis, compact on the line of it, both closing the parenthesis on a line of its own; a list of the two lets either pass and writes anything else in the first, keep leaves every condition as it is
operatorPosition keep | start "keep" Where a boolean operator of the condition at a line break stands: keep leaves it where it is, start moves one ending a line to the start of the next unless a comment follows it

dresscode/multilineImport

Spreads a group use over lines where its line would be too long, its names filling the lines.

Stage: Formatting.

dresscode/multilineSignature

Splits long signatures and constructors with promoted properties into one parameter per line.

Stage: Formatting. Covers: multiline_promoted_properties, SlevomatCodingStandard.Classes.RequireMultiLineMethodSignature.

Option Type Default
promotedProperty always | keep "always" always splits a signature declaring a promoted property whatever its length, keep leaves the length to decide

dresscode/multilineTernary

Puts the two operators of a multi-line ternary on lines of their own.

Stage: Formatting.

dresscode/nameCasing

Reports declared names that do not follow the case convention configured for their kind.

Stage: Structure. Covers: Generic.NamingConventions.CamelCapsFunctionName, Generic.NamingConventions.UpperCaseConstantName, PSR1.Methods.CamelCapsMethodName, Squiz.Classes.ValidClassName, Squiz.NamingConventions.ValidFunctionName, Squiz.NamingConventions.ValidVariableName.

Option Type Default
class PascalCase | camelCase | UPPER_CASE | snake_case | keep null Classes, interfaces, traits and enums
method PascalCase | camelCase | UPPER_CASE | snake_case | keep null
function PascalCase | camelCase | UPPER_CASE | snake_case | keep null
constant PascalCase | camelCase | UPPER_CASE | snake_case | keep null Class constants and constants declared with const outside a class; a constant of an enum may also follow enumCase
enumCase PascalCase | camelCase | UPPER_CASE | snake_case | keep null
property PascalCase | camelCase | UPPER_CASE | snake_case | keep null Declared properties, promoted constructor parameters included
variable PascalCase | camelCase | UPPER_CASE | snake_case | keep null Variables and parameters, except $this and the superglobals; each name once per function
ignorePatterns list of string [] Regular expressions; a name matching one is never reported, whatever its kind, as the methods of a stream wrapper or a replacement for a native function are

dresscode/nameFallback

Writes a global function or constant in a namespace qualified, or bare and reached by the fallback at run time.

Stage: Structure. Covers: native_function_invocation, native_constant_invocation, SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalConstants, SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalFunctions. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

Option Type Default
function ?keep | qualified | fallback | array null Every global function: qualified, fallback, keep, or a map from a name or a pattern with * to one
optimizedFunction ?keep | qualified | fallback null A global function the compiler or opcache treats specially, where it is called with arguments PHP optimizes: qualified, fallback or keep
constant ?keep | qualified | fallback | array null Every global constant, decided as the functions are, a pattern matching its name case-sensitively
optimizedConstant ?keep | qualified | fallback null A constant PHP declares where the compiler computes with it, in a constant expression or condition: qualified, fallback or keep

dresscode/nameNotation

Writes a referenced name imported or with the leading backslash.

Stage: Structure. Covers: fully_qualified_strict_types, global_namespace_import, native_function_invocation, native_constant_invocation, SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalConstants, SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalFunctions, SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.

Option Type Default
class ?keep | import | backslash | array null Every class, interface, trait and enum: import, backslash, keep, or a map from a name or a pattern with * to one
globalClass ?keep | import | backslash | array null A class of the global namespace, written as the classes are
function ?keep | import | backslash | array null Every function, written as the classes are
globalFunction ?keep | import | backslash | array null A function of the global namespace once it is qualified, whether it stands bare being decided by dresscode/nameFallback
constant ?keep | import | backslash | array null Every constant, written as the classes are, a pattern matching its name case-sensitively
globalConstant ?keep | import | backslash | array null A constant of the global namespace, written as the global functions are

dresscode/namedArgumentSpacing

Removes whitespace before the colon of a named argument and puts a single space after it.

Stage: Formatting. Covers: SlevomatCodingStandard.Functions.NamedArgumentSpacing.

dresscode/nativeNameCasing

Writes the names of internal classes, functions and types in their declared case.

Stage: Structure. Covers: class_reference_name_casing, native_function_casing, native_type_declaration_casing, Generic.PHP.LowerCaseType, Squiz.PHP.LowercasePHPFunctions.

Option Type Default
class declared | keep "declared" Classes, interfaces and enums
function declared | keep "declared"
type declared | keep "declared" The built-in types of a declaration, such as int and void; array, callable, static, self and parent are keywords, left to dresscode/keywordCasing

dresscode/neverForThrowingFunction

Declares a function that always throws or exits as returning never.

Stage: Structure. Needs PHP >=8.1.

Option Type Default
anonymousFunction bool false A closure gets the type too, though its signature usually belongs to the call it is passed to

dresscode/newInitializerForNullDefault

Replaces a null default that the body swaps for a new object with that object, Clock $clock = new SystemClock.

Stage: Structure. Needs PHP >=8.1. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

dresscode/noAliasFunctions

Replaces the alias of a function with its canonical name.

Stage: Structure. Covers: no_alias_functions. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

Option Type Default
sets list of (all | internal | imap | ldap | mysqli | pg | oci | odbc | openssl | sodium | ftp | posix | pcntl | time) ["internal","imap","pg"] Groups of aliases to replace: all, internal (core functions), imap, ldap, mysqli, pg, oci, odbc, openssl, sodium, ftp, posix, pcntl, time (mktime() without arguments)

dresscode/noAlternativeSyntax

Replaces the alternative syntax with braces.

Stage: Structure. Covers: no_alternative_syntax.

dresscode/noBacktickOperators

Replaces the backtick operator with a call of shell_exec().

Stage: Structure. Covers: backtick_to_shell_exec.

dresscode/noBom

Removes the UTF-8 byte order mark.

Stage: Structure. Covers: encoding, Generic.Files.ByteOrderMark.

dresscode/noCallUserFunc

Replaces call_user_func() and call_user_func_array() with a direct call of the callable.

Stage: Structure. Covers: regular_callable_call. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

dresscode/noClosingTag

Removes the closing tag at the end of the file.

Stage: Structure. Covers: no_closing_tag, PSR2.Files.ClosingTag.

dresscode/noConsecutivePhpdocs

Reports a doc comment followed by another one.

Stage: Finishing.

dresscode/noConstructorReturnValues

Removes the value returned from a constructor or a destructor, which PHP 8.6 deprecated.

Stage: Structure.

dresscode/noContinueInSwitch

Replaces a continue that leaves a switch with break.

Stage: Structure. Covers: switch_continue_to_break, SlevomatCodingStandard.ControlStructures.DisallowContinueWithoutIntegerOperandInSwitch.

dresscode/noConversionFunctions

Replaces intval() and the other conversion functions with a cast.

Stage: Structure. Covers: modernize_types_casting. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

dresscode/noDeprecatedArguments

Reports the values of arguments PHP deprecated.

Stage: Structure.

dresscode/noDeprecatedClasses

Replaces deprecated classes with the class their deprecation names, and reports the rest.

Stage: Structure. Needs the types of the code, so it runs only with types: phpstan. Modifies comments.

dresscode/noDeprecatedFunctions

Reports calls of internal functions PHP deprecated.

Stage: Structure. Covers: Generic.PHP.DeprecatedFunctions.

dresscode/noDeprecatedMembers

Replaces deprecated constants, methods and properties with the member their deprecation names, and reports the rest.

Stage: Structure. Needs the types of the code, so it runs only with types: phpstan.

dresscode/noDirectInvokeCalls

Replaces a call of the __invoke() method with a call of the object itself.

Stage: Structure. Covers: SlevomatCodingStandard.PHP.DisallowDirectMagicInvokeCall.

dresscode/noDirnameOfFile

Replaces dirname(__FILE__) with __DIR__ and nested dirname() calls with the levels argument.

Stage: Structure. Covers: PhpCsFixerCustomFixers/no_useless_dirname_call, combine_nested_dirname, dir_constant. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

dresscode/noDuplicateAssignments

Reports an assignment repeated to the same variable in one expression.

Stage: Structure. Covers: SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable.

dresscode/noEmptyComments

Removes empty comments.

Stage: Finishing. Covers: no_empty_comment. Modifies comments.

dresscode/noEmptyPhpdocs

Removes empty doc comments.

Stage: Finishing. Covers: no_empty_phpdoc. Modifies comments.

dresscode/noEmptyStatements

Removes empty statements.

Stage: Structure. Covers: no_empty_statement, SlevomatCodingStandard.PHP.UselessSemicolon.

dresscode/noErrorSuppression

Reports the @ error suppression operator.

Stage: Structure.

dresscode/noFinalParents

Reports a class extending a final one.

Stage: Structure. Needs the types of the code, so it runs only with types: phpstan.

dresscode/noFinallyReturns

Reports a return inside finally, which PHP 8.6 deprecated.

Stage: Structure.

dresscode/noGlobalStatements

Reports the global statement.

Stage: Structure. Covers: Squiz.PHP.GlobalKeyword.

dresscode/noHashComments

Writes single-line comments with //, not #.

Stage: Finishing. Covers: single_line_comment_style, PEAR.Commenting.InlineComment. Modifies comments.

dresscode/noImplicitBackslashes

Writes every backslash of a string escaped.

Stage: Structure. Covers: escape_implicit_backslashes, string_implicit_backslashes.

dresscode/noInnerFunctions

Reports a function declared inside another function.

Stage: Structure. Covers: Squiz.PHP.InnerFunctions.

dresscode/noInvisibleCharacters

Removes or escapes invisible characters in comments and strings, reports them in names.

Stage: Structure. Covers: non_printable_character. Modifies comments.

dresscode/noIsNull

Replaces is_null() with a comparison with null.

Stage: Structure. Covers: is_null. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

dresscode/noManualEmptyStringTests

Replaces a test of the length of a string against zero with a comparison with ''.

Stage: Structure. Covers: PhpCsFixerCustomFixers/no_useless_strlen, string_length_to_empty. Needs the types of the code, so it runs only with types: phpstan.

dresscode/noManualListTests

Replaces a hand-written test for a list with array_is_list().

Stage: Structure. Needs PHP >=8.1. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

dresscode/noManualSubstringTests

Replaces a hand-written test for a substring with str_contains(), str_starts_with() or str_ends_with().

Stage: Structure. Covers: modernize_strpos. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

dresscode/noMismatchedFunctionAnnotations

Reports an annotation of a function that does not agree with its signature: a @param of an unknown parameter, a second @return, a @param or @return without content.

Stage: Structure. Covers: Squiz.Commenting.FunctionComment.DuplicateReturn, Squiz.Commenting.FunctionComment.ExtraParamComment.

dresscode/noMismatchedPropertyAnnotations

Reports an annotation of a property that does not agree with it: a second @var, a @var or @see without content.

Stage: Structure. Covers: Squiz.Commenting.VariableComment.

dresscode/noNullArrayKeys

Writes a null array key as the empty string it becomes.

Stage: Structure.

dresscode/noNullDebugInfo

Returns an empty array from __debugInfo() where it returns null.

Stage: Structure. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

dresscode/noReservedNames

Reports the names of declarations and imports that PHP 8.6 reserved.

Stage: Structure.

dresscode/noSettype

Replaces a settype() statement with the assignment of a cast.

Stage: Structure. Covers: set_type_to_cast. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

dresscode/noShortBoolCasts

Replaces !! with a (bool) cast.

Stage: Structure. Covers: no_short_bool_cast.

dresscode/noSleepAndWakeup

Reports the __sleep() and __wakeup() methods PHP 8.5 soft-deprecated.

Stage: Structure.

dresscode/noStaticThis

Reports $this used where no object is available.

Stage: Structure. Covers: Squiz.Scope.StaticThisUsage.

dresscode/noTrailingWhitespace

Removes whitespace at the end of lines.

Stage: Finishing. Covers: no_trailing_whitespace, no_trailing_whitespace_in_comment, no_whitespace_in_blank_line, Squiz.WhiteSpace.SuperfluousWhitespace.

dresscode/noTrailingWhitespaceInString

Removes the whitespace at the end of the lines of a multi-line string or of inline HTML.

Stage: Structure. Covers: no_trailing_whitespace_in_string. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

dresscode/noUnimplementedAbstractMethods

Reports an abstract method a class that is not abstract inherits and does not implement.

Stage: Structure. Needs the types of the code, so it runs only with types: phpstan.

dresscode/noUnlistedNamespacedDeclarations

Reports a function or a constant declared in a namespace that the configuration does not list.

Stage: Structure.

dresscode/noUnreachableCatches

Reports a catch block following one that catches Throwable.

Stage: Structure. Covers: SlevomatCodingStandard.Exceptions.DeadCatch.

dresscode/notEqualsNotation

Writes != instead of <>.

Stage: Structure. Covers: standardize_not_equals.

dresscode/nowdocWithoutInterpolation

Writes a heredoc that interpolates nothing as a nowdoc.

Stage: Structure. Covers: heredoc_to_nowdoc, SlevomatCodingStandard.PHP.RequireNowdoc.

dresscode/nullCoalescingForNullTernary

Replaces a ternary testing for null with the null coalescing operator.

Stage: Structure. Covers: ternary_to_null_coalescing, SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

dresscode/nullableTypeForDefaultNull

Marks the type of a parameter defaulting to null as nullable.

Stage: Structure. Covers: nullable_type_declaration_for_default_null_value, SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue.

dresscode/nullsafeForGuardedAccess

Replaces a ternary guarding a member access against null with the nullsafe operator.

Stage: Structure.

dresscode/numericLiteralSeparator

Groups the digits of long numbers with underscores.

Stage: Structure. Covers: PhpCsFixerCustomFixers/numeric_literal_separator, numeric_literal_separator, SlevomatCodingStandard.Numbers.RequireNumericLiteralSeparator.

Option Type Default
minIntegerDigits int 4 An integer part with at least this many digits is grouped
minFractionDigits int 4 A fraction with at least this many digits is grouped

dresscode/objectOperatorSpacing

Removes whitespace around the object operator.

Stage: Formatting. Covers: object_operator_without_whitespace, Squiz.WhiteSpace.ObjectOperatorSpacing.

dresscode/octalNotation

Writes octal numbers with the 0o prefix.

Stage: Structure. Covers: octal_notation. Needs PHP >=8.1.

dresscode/offsetBracketSpacing

Removes whitespace around the brackets of an offset access.

Stage: Formatting. Covers: no_spaces_around_offset, Squiz.Arrays.ArrayBracketSpacing.

dresscode/optimizedCallNotation

Writes the arguments of a call PHP optimizes positionally and reports unpacking in it.

Stage: Structure. Covers: SlevomatCodingStandard.PHP.OptimizedFunctionsWithoutUnpacking. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

dresscode/orderedImports

Sorts the imports alphabetically, classes before functions before constants.

Stage: Structure. Covers: ordered_imports, SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.

Option Type Default
caseSensitive bool false
order byName | byKind "byName" byName sorts the names within each kind, byKind only puts classes before functions before constants and keeps the order within a kind

dresscode/orderedMembers

Orders class members by kind and visibility.

Stage: Structure. Covers: ordered_class_elements, PSR12.Traits.UseDeclaration.

Option Type Default
order list of (traitUse | enumCase | constant | publicConstant | protectedConstant | privateConstant | property | publicProperty | protectedProperty | privateProperty | publicStaticProperty | protectedStaticProperty | privateStaticProperty | method | publicMethod | protectedMethod | privateMethod | publicStaticMethod | protectedStaticMethod | privateStaticMethod | constructor | destructor | magicMethod) ["traitUse","constant","publicConstant","protectedConstant","privateConstant","publicProperty","protectedProperty","privateProperty"] Kinds of members in the required order; a member takes the most specific kind listed, unlisted kinds follow in the order written

dresscode/overrideAttributeRequired

Marks a member overriding an inherited one with #[\Override].

Stage: Structure. Needs PHP >=8.3. Needs the types of the code, so it runs only with types: phpstan.

dresscode/overrideSignature

Declares an overriding method the way the ancestor declares it: its types, its parameters and their names.

Stage: Structure. Needs the types of the code, so it runs only with types: phpstan. Modifies comments. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky. One decision, so a value written for the rule fills parameterNames.

Option Type Default
parameterNames bool true A parameter is renamed to the name the ancestor gives it

dresscode/parenthesesSpacing

Removes whitespace inside parentheses.

Stage: Formatting. Covers: no_spaces_inside_parenthesis, spaces_inside_parentheses, PSR12.Classes.AnonClassDeclaration, PSR12.ControlStructures.ControlStructureSpacing, PSR2.ControlStructures.ControlStructureSpacing, PSR2.Methods.FunctionCallSignature, Squiz.ControlStructures.ForEachLoopDeclaration, Squiz.ControlStructures.ForLoopDeclaration.

dresscode/phpdocAlignment

Aligns the stars of a doc comment with its opening.

Stage: Formatting. Covers: Squiz.Commenting.DocCommentAlignment. Modifies comments.

dresscode/phpdocTrim

Removes the blank lines at the start and the end of a doc comment and leaves at most one in a row inside it.

Stage: Finishing. Covers: phpdoc_trim, phpdoc_trim_consecutive_blank_line_separation. Modifies comments.

dresscode/phpdocTypeNotation

Writes the types in doc comments in one notation: short lowercase built-in types, one array notation, each type of a union once, and null and ?T as its options choose.

Stage: Finishing. Covers: PhpCsFixerCustomFixers/phpdoc_array_style, PhpCsFixerCustomFixers/phpdoc_type_list, phpdoc_array_type, phpdoc_list_type, phpdoc_scalar, phpdoc_types, phpdoc_types_no_duplicates, phpdoc_types_order, SlevomatCodingStandard.TypeHints.DisallowArrayTypeHintSyntax, SlevomatCodingStandard.TypeHints.LongTypeHints, SlevomatCodingStandard.TypeHints.NullTypeHintOnLastPosition. Modifies comments.

Option Type Default
shortNullable bool false T|null is written ?T
nullPosition last | first | keep "keep" Where null stands in a union type
order byName | keep "keep" byName sorts the types beside null by name, case-insensitively; keep leaves their order alone
arrayNotation generic | brackets | keep "generic" generic writes int[] as array<int>, brackets writes array<int> as int[]; keep leaves both alone

dresscode/pipeOperator

Writes nested calls passing one result into the next with the pipe operator.

Stage: Structure. Needs PHP >=8.5. One decision, so a value written for the rule fills minCalls.

Option Type Default
minCalls int 3 The pipe operator is written for a nest of at least this many calls

dresscode/promotedPropertyAnnotationPosition

Moves the @param annotation of a promoted property to a doc comment at the property.

Stage: Structure. Modifies comments.

dresscode/promotedPropertyForAssignment

Promotes a constructor parameter that is only assigned to a property.

Stage: Structure. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

dresscode/propertyPhpdocRequired

Reports a plain comment in place of a property doc comment.

Stage: Structure. Covers: Squiz.Commenting.VariableComment.

dresscode/propertyPhpdocSingleline

Writes a property doc comment with a single line of content on one line.

Stage: Formatting. Covers: SlevomatCodingStandard.Commenting.RequireOneLinePropertyDocComment. Modifies comments.

dresscode/readonlyClassForReadonlyMembers

Marks a class whose every property is readonly as readonly.

Stage: Structure. Needs PHP >=8.2.

dresscode/readonlyForAnnotation

Replaces the @readonly annotation with the readonly keyword.

Stage: Structure. Covers: phpdoc_readonly_class_comment_to_keyword. Needs PHP >=8.1. Modifies comments. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

dresscode/readonlyForUnwrittenProperty

Marks a property written only in the constructor, or not at all, as readonly.

Stage: Structure. Needs PHP >=8.1. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

dresscode/referenceSpacing

Removes whitespace between & and its operand.

Stage: Formatting. Covers: SlevomatCodingStandard.Operators.ReferenceSpacing.

dresscode/referenceThrowableOnly

Reports references to the general Exception where Throwable belongs.

Stage: Structure. Covers: SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly.

dresscode/replacedCalls

Writes a call, an access or an instantiation the way a project or its libraries write it instead.

Stage: Structure. Needs the types of the code, so it runs only with types: phpstan. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

Options: The replaced use, Class::name($a, true), Class::name(...$args) with any arguments, Class::name() without any, Class::__construct($a), Class::$name::get, Class::$name::set or a magic method for the syntax PHP calls it by → the expression written instead, with the placeholders of the key, $value what is assigned.

dresscode/replacedClasses

Writes the class a project or its libraries write instead of another one.

Stage: Structure. Modifies comments.

Options: The class → the class written instead, both fully qualified.

dresscode/replacedFunctions

Writes the function a project or its libraries call instead of another one.

Stage: Structure. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

Options: The function, global or of a namespace → the function or the static method written instead.

dresscode/replacedMembers

Writes the member a project or its libraries write instead of another one.

Stage: Structure. Needs the types of the code, so it runs only with types: phpstan. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

Options: The replaced member, Class::name (a constant or a method), Class::name() (a method) or Class::$name (a property) → the member written instead: its name alone in the same class, Other::name in another one, or \function for the global function a method becomes.

dresscode/returnForBooleanIf

Replaces an if returning true or false with a return of the condition.

Stage: Structure. Covers: SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn.

dresscode/roundingModeNotation

Writes the rounding mode of round() as a case of the RoundingMode enum.

Stage: Structure. Needs PHP >=8.4.

dresscode/selfForCurrentClass

Replaces the name of the current class with self.

Stage: Structure. Covers: self_accessor, self_static_accessor, SlevomatCodingStandard.Classes.UselessLateStaticBinding, Squiz.Classes.SelfMemberReference. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

Option Type Default
onStatic bool false Where no subclass can exist, static means this class too and becomes self

dresscode/semicolonSpacing

Removes whitespace before a semicolon and puts a single space after it.

Stage: Formatting. Covers: no_singleline_whitespace_before_semicolons, space_after_semicolon, PSR12.Traits.UseDeclaration, Squiz.ControlStructures.ForLoopDeclaration, Squiz.Functions.FunctionDeclaration, Squiz.WhiteSpace.SemicolonSpacing.

Option Type Default
before none | keep "none"
after single | keep "single"
allowOwnLine bool false A semicolon may stand on a line of its own below a statement spanning several lines

dresscode/sensitiveParameterRequired

Marks the parameters the configuration names with #[\SensitiveParameter].

Stage: Structure. Needs PHP >=8.2. One decision, so a value written for the rule fills parameters.

Option Type Default
parameters list of string ["password","passwd","pwd","secret","apiKey","api_key","privateKey","private_key"] Names of the parameters that hold a secret, whatever their letter case

dresscode/serializeMethodsRequired

Reports a class implementing Serializable without __serialize() and __unserialize().

Stage: Structure.

dresscode/shortArraySyntax

Writes arrays and destructuring with the short syntax.

Stage: Structure. Covers: array_syntax, list_syntax, Generic.Arrays.DisallowLongArraySyntax, SlevomatCodingStandard.PHP.ShortList.

dresscode/shortTernaryForRepeatedCondition

Replaces a ternary repeating its condition, $a ? $a : $b, with $a ?: $b.

Stage: Structure. Covers: ternary_to_elvis_operator, SlevomatCodingStandard.ControlStructures.RequireShortTernaryOperator.

dresscode/singleLevelIndentation

Reports indentation that deepens by more than a level or returns to a level nothing opened.

Stage: Finishing.

Option Type Default
singlelineComment bool true A single-line comment must keep the single step too, as a line of code does; a note put beside the code often does not

dresscode/singleMemberPerDeclaration

Splits a declaration of several constants, properties or traits into one per member.

Stage: Structure. Covers: single_class_element_per_statement, single_trait_insert_per_statement, PSR12.Traits.UseDeclaration, SlevomatCodingStandard.Classes.DisallowMultiConstantDefinition, SlevomatCodingStandard.Classes.DisallowMultiPropertyDefinition, SlevomatCodingStandard.Classes.TraitUseDeclaration.

Option Type Default
members list of (constant | property | trait) ["constant","property","trait"] Kinds of members to split; constant also covers a const outside a class

dresscode/singleMemberPerLine

Puts every member of a class on its own line.

Stage: Formatting. Covers: PSR12.Classes.ClosingBrace.

dresscode/singleStatementPerLine

Puts every statement on its own line.

Stage: Formatting. Covers: no_multiple_statements_per_line, Generic.Formatting.DisallowMultipleStatements, PSR12.Classes.ClosingBrace, PSR2.ControlStructures.SwitchDeclaration.

dresscode/spreadForArrayMerge

Writes the arrays merged by array_merge() as an array spreading them.

Stage: Structure. Needs PHP >=8.1. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

dresscode/spreadOperatorSpacing

Removes whitespace between ... and its operand.

Stage: Formatting. Covers: SlevomatCodingStandard.Operators.SpreadOperatorSpacing.

dresscode/staticClosure

Declares a closure that does not use $this as static.

Stage: Structure. Covers: static_lambda, SlevomatCodingStandard.Functions.StaticClosure. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

dresscode/staticForMethodWithoutThis

Marks a private method that does not use $this as static.

Stage: Structure. Covers: static_private_method. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

dresscode/staticSetStateRequired

Declares __set_state() static, which is how PHP calls it.

Stage: Structure.

dresscode/strictCall

Adds the argument $strict = true to calls of in_array(), array_search(), array_keys(), base64_decode() and mb_detect_encoding(), and reports an explicit false.

Stage: Structure. Covers: strict_param, SlevomatCodingStandard.Functions.StrictCall. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

dresscode/strictComparison

Replaces loose comparisons with strict ones.

Stage: Structure. Covers: strict_comparison. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

dresscode/strictTypesRequired

Adds declare(strict_types=1) as the first statement of a file, or sets it to 1.

Stage: Structure. Covers: PhpCsFixerCustomFixers/declare_after_opening_tag, declare_strict_types, Generic.PHP.RequireStrictTypes, SlevomatCodingStandard.TypeHints.DeclareStrictTypes. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

Option Type Default
placement ownLine | openingTagLine "ownLine" ownLine puts the declaration on the line after the opening tag, openingTagLine on the line of the tag, which needs afterOpeningTag of dresscode/blankLines set to keep

dresscode/stringQuotes

Writes a string that gains nothing from double quotes in single ones, or with double the other way round.

Stage: Structure. Covers: single_quote, Squiz.Strings.DoubleQuoteUsage. One decision, so a value written for the rule fills quotes.

Option Type Default
quotes single | double "single" A string with interpolation, an escape sequence only double quotes know or a quote of the wanted kind inside keeps its quotes

dresscode/stringableRequired

Declares a class with a __toString() method as Stringable.

Stage: Structure.

dresscode/switchCaseColon

Ends case and default with a colon.

Stage: Structure. Covers: switch_case_semicolon_to_colon, PSR2.ControlStructures.SwitchDeclaration.

dresscode/switchCaseSpacing

Removes whitespace before the colon of a case.

Stage: Formatting. Covers: switch_case_space, PSR2.ControlStructures.SwitchDeclaration, PSR2.ControlStructures.SwitchDeclaration.SpaceBeforeColonCASE.

dresscode/symbolicLogicalOperators

Replaces and and or with && and ||.

Stage: Structure. Covers: Squiz.Operators.ValidLogicalOperators.

dresscode/ternaryForIf

Replaces an if and else that only return or assign one of two values with the ternary operator.

Stage: Structure. Covers: SlevomatCodingStandard.ControlStructures.RequireTernaryOperator.

dresscode/ternaryOperatorSpacing

Puts whitespace around the ternary operators.

Stage: Formatting. Covers: ternary_operator_spaces, PSR12.Operators.OperatorSpacing.

Option Type Default
spacing atLeastOne | single "atLeastOne" atLeastOne keeps any number of spaces around the operators, single collapses them to one
operatorPosition keep | start "keep" Where ? and : of a ternary at a line break stand: keep leaves them where they are, start moves one ending a line to the start of the next unless a comment follows it

dresscode/throwExpressionForNullGuard

Writes a throw guarding an assigned value against null as ?? throw.

Stage: Structure. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

dresscode/trailingComma

Puts the trailing comma into a multi-line list or removes it, and removes it from a one-line one.

Stage: Structure. Covers: no_trailing_comma_in_singleline, trailing_comma_in_multiline, SlevomatCodingStandard.Arrays.TrailingArrayComma, SlevomatCodingStandard.Functions.RequireTrailingCommaInCall, SlevomatCodingStandard.Functions.RequireTrailingCommaInDeclaration.

Option Type Default
array required | optional | forbidden | keep "required" required puts the comma into a multi-line list whose closing bracket stands on its own line, optional leaves a multi-line list as it is, forbidden removes the comma from it; all three remove it from a list on one line, which keep leaves too
argument required | optional | forbidden | keep "optional" The arguments of a call and the variables of isset() and unset()
parameter required | optional | forbidden | keep "keep"
matchArm required | optional | forbidden | keep "keep"
closureUse required | optional | forbidden | keep "keep"
import required | optional | forbidden | keep "optional" A group use
list optional | keep "optional" list(), removed from one line only; a destructuring written with [...] is array

dresscode/typeHintRequired

Adds native types from annotations and reports declarations without any type.

Stage: Structure. Covers: SlevomatCodingStandard.TypeHints.ParameterTypeHint, SlevomatCodingStandard.TypeHints.PropertyTypeHint, SlevomatCodingStandard.TypeHints.ReturnTypeHint. Modifies comments. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

Option Type Default
parameter bool true
property bool true
return bool true
constant bool false Class constants get the type of their value, which PHP 8.3 lets them declare
traversableTypeHints list of string ["Traversable"] Classes treated like array and iterable, whose annotation says what their items are

dresscode/typeHintSpacing

Removes whitespace inside a type declaration and puts a single space between the type and what it declares.

Stage: Formatting. Covers: compact_nullable_type_declaration, return_type_declaration, PSR12.Functions.NullableTypeDeclaration, PSR12.Functions.ReturnTypeDeclaration, SlevomatCodingStandard.Classes.BackedEnumTypeSpacing, SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing, SlevomatCodingStandard.TypeHints.PropertyTypeHintSpacing, SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing.

Option Type Default
catch none | single "none" Around the bar between the types of a catch: none for catch (A|B $e) as PER Coding Style writes it, single for catch (A | B $e) as PSR-12 did

dresscode/typeNotation

Writes a nullable type as ?T, puts null last in a union type and may sort the rest.

Stage: Structure. Covers: ordered_types, SlevomatCodingStandard.TypeHints.DNFTypeHintFormat, SlevomatCodingStandard.TypeHints.UnionTypeHintFormat.

Option Type Default
shortNullable bool true T|null is written ?T
nullPosition last | first | keep "last" Where null stands in a union of three or more types
order byName | keep "keep" byName sorts the types beside null by name, case-insensitively, an intersection by its first name; keep leaves their order alone

dresscode/unaryOperatorSpacing

Removes whitespace between a unary operator and its operand.

Stage: Formatting. Covers: unary_operator_spaces, Generic.WhiteSpace.IncrementDecrementSpacing, SlevomatCodingStandard.Operators.NegationOperatorSpacing, Squiz.WhiteSpace.OperatorSpacing.Unary.

Option Type Default
allowSpace list of (++ | -- | ! | - | + | ~ | @) [] Operators whose operand may stand apart from them, as written

dresscode/unusedImports

Removes imports that nothing uses.

Stage: Structure. Covers: no_unused_imports, SlevomatCodingStandard.Namespaces.UnusedUses.

Option Type Default
annotations bool true A class name referenced in a doc comment counts as used, the name of an annotation such as @DB\Entity included

dresscode/uselessAlias

Removes an import alias equal to the imported name.

Stage: Structure. Covers: SlevomatCodingStandard.Namespaces.UselessAlias.

dresscode/uselessArguments

Removes the arguments PHP ignores and those that repeat the default of their parameter.

Stage: Structure.

dresscode/uselessBraces

Removes braces around a bare statement group.

Stage: Structure. Covers: no_unneeded_braces, no_unneeded_curly_braces.

dresscode/uselessCatchVariable

Removes the variable of a catch clause that is never used.

Stage: Structure. Covers: SlevomatCodingStandard.Exceptions.RequireNonCapturingCatch.

dresscode/uselessConstantVarAnnotation

Removes a useless @var from a class constant.

Stage: Finishing. Covers: SlevomatCodingStandard.TypeHints.UselessConstantTypeHint. Modifies comments.

dresscode/uselessConstructParentheses

Removes parentheses around the operand of a language construct.

Stage: Structure. Covers: include, no_unneeded_control_parentheses, SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses, Squiz.Strings.EchoedStrings.

dresscode/uselessElse

Removes an else after branches which always leave, and may turn an elseif there into an if.

Stage: Structure. Covers: no_superfluous_elseif, no_useless_else, SlevomatCodingStandard.ControlStructures.EarlyExit.

Option Type Default
elseif bool false An elseif after an if that always leaves becomes an if of its own

dresscode/uselessFunctionPhpdoc

Removes a function doc comment that only repeats the native types.

Stage: Structure. Covers: SlevomatCodingStandard.Commenting.UselessFunctionDocComment. Modifies comments.

Option Type Default
traversableTypeHints list of string ["Traversable"] Classes treated like array and iterable, whose annotation says what their items are

dresscode/uselessInheritdoc

Removes a doc comment consisting of @inheritDoc only.

Stage: Structure. Covers: SlevomatCodingStandard.Commenting.UselessInheritDocComment. Modifies comments.

dresscode/uselessLeadingBackslash

Removes the leading backslash from imported names and from names referenced in the global namespace.

Stage: Structure. Covers: PhpCsFixerCustomFixers/no_leading_slash_in_global_namespace, no_leading_import_slash, PSR12.Files.ImportStatement, SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash.

Option Type Default
globalNamespace bool true The names referenced in the global namespace, not only the imports

dresscode/uselessModifier

Removes a member modifier the class already implies.

Stage: Structure. Covers: no_redundant_readonly_property, no_unneeded_final_method, Generic.CodeAnalysis.UnnecessaryFinalModifier.

dresscode/uselessNoOpCall

Removes calls of curl_close(), imagedestroy(), setAccessible() and the others that have done nothing since PHP 8.0 or 8.1.

Stage: Structure.

dresscode/uselessNullInitialization

Removes the explicit null initialization of untyped properties.

Stage: Structure. Covers: no_null_property_initialization.

dresscode/uselessOverridingMethod

Removes a method that only calls the parent method with the same arguments.

Stage: Structure. Needs the types of the code, so it runs only with types: phpstan. May have risky fixes, made once the rule is named in fixRisky or with --fix-risky.

dresscode/uselessParameterDefault

Removes a default value that a required parameter makes unreachable.

Stage: Structure. Covers: no_unreachable_default_argument_value, PEAR.Functions.ValidDefaultValue, SlevomatCodingStandard.Functions.UselessParameterDefaultValue.

dresscode/uselessParenthesesAroundNew

Removes the parentheses around new when a member of the new object is accessed.

Stage: Structure. Covers: new_expression_parentheses. Needs PHP >=8.4.

dresscode/uselessReturn

Removes a bare return at the end of a function body.

Stage: Structure. Covers: no_useless_return.

dresscode/uselessReturnTypeWillChange

Removes #[\ReturnTypeWillChange] from a method that declares the return type of the method it implements.

Stage: Structure.

dresscode/uselessSameNamespaceImport

Removes imports of names from the current namespace.

Stage: Structure. Covers: SlevomatCodingStandard.Namespaces.UseFromSameNamespace.

dresscode/uselessStringConcat

Joins two string literals concatenated on one line and drops concatenation with an empty string.

Stage: Structure. Covers: PhpCsFixerCustomFixers/no_superfluous_concatenation, Generic.Strings.UnnecessaryStringConcat.

Option Type Default
allowMultiline bool true Literals on different lines may stay concatenated

dresscode/uselessTernaryOperator

Replaces a ternary operator choosing between true and false with the condition.

Stage: Structure. Covers: SlevomatCodingStandard.ControlStructures.UselessTernaryOperator.

dresscode/visibilityRequired

Declares the visibility of every class member, var becoming public, and orders the modifiers.

Stage: Structure. Covers: modifier_keywords, visibility_required, PSR12.Properties.ConstantVisibility, PSR2.Classes.PropertyDeclaration, PSR2.Methods.MethodDeclaration, SlevomatCodingStandard.Classes.ClassConstantVisibility, SlevomatCodingStandard.Classes.PropertyDeclaration, Squiz.Scope.MethodScope.

Option Type Default
interfaceMethod required | forbidden | keep "required" required writes public on a method of an interface, forbidden removes it, keep leaves it as written

dresscode/yoda

Puts the constant of a comparison on its right side, or with required on its left.

Stage: Structure. Covers: SlevomatCodingStandard.ControlStructures.DisallowYodaComparison. One decision, so a value written for the rule fills comparisons.

Option Type Default
comparisons forbidden | required "forbidden" forbidden puts the variable of a comparison on the left, required puts the constant there