Skip to content

Latest commit

 

History

History
1687 lines (939 loc) · 106 KB

File metadata and controls

1687 lines (939 loc) · 106 KB

Rules

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

By category

Arrays (6): arraySpacing, multilineArray, noManualListTests, noNullArrayKeys, shortArraySyntax, trailingComma

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

Comments (3): commentSpacing, noEmptyComments, noHashComments

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

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

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

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

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

Namespaces (13): groupImport, importNotation, multilineImport, nameFallback, nameNotation, nativeClassCasing, noUnlistedNamespacedDeclarations, orderedImports, unusedImports, uselessAlias, uselessBackslashInGlobalNamespace, uselessImportBackslash, uselessSameNamespaceImport

PhpDoc (22): annotationCasing, attributeAfterPhpdoc, deprecatedAttributeForAnnotation, explicitAssertion, forbiddenAnnotations, forbiddenPhpdocLines, noConsecutivePhpdocs, noDuplicateReturnAnnotations, noEmptyPhpdocs, noEmptyVarAnnotations, noUnknownParamAnnotations, phpdocAlignment, phpdocCanonicalTypes, phpdocNullPosition, phpdocTrim, promotedPropertyAnnotationPosition, propertyPhpdocRequired, propertyPhpdocSingleline, propertyVarAnnotation, uselessConstantVarAnnotation, uselessFunctionPhpdoc, uselessInheritdoc

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

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 (7): annotationCasing, keywordCasing, magicConstantCasing, nameCasing, nativeClassCasing, nativeFunctionCasing, trueFalseNullCasing

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

Indentation (2): heredocIndentation, singleLevelIndentation

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

Notation (14): arrayFirstNotation, castCanonicalType, firstClassCallableNotation, getClassNotation, importNotation, nameNotation, noAlternativeSyntax, notEqualsNotation, octalNotation, optimizedCallNotation, phpdocCanonicalTypes, roundingModeNotation, shortArraySyntax, unionTypeNotation

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

Position (4): attributePosition, bracesPosition, phpdocNullPosition, promotedPropertyAnnotationPosition

Redundancy (22): uselessAlias, uselessAttributeParentheses, uselessBackslashInGlobalNamespace, uselessBraces, uselessCatchVariable, uselessConstantVarAnnotation, uselessConstructParentheses, uselessElse, uselessFunctionPhpdoc, uselessImportBackslash, uselessInheritdoc, uselessModifier, uselessNoOpCall, uselessNullInitialization, uselessOverridingMethod, uselessParameterDefault, uselessParenthesesAroundNew, uselessReturn, uselessSameNamespaceImport, uselessSetAccessible, uselessStringConcat, uselessTernaryOperator

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

Required (9): csvEscapeArgumentRequired, overrideAttributeRequired, propertyPhpdocRequired, sensitiveParameterRequired, 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 (groups: [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 (111): annotationCasing, arraySpacing, attributeAfterPhpdoc, attributeForAnnotation, attributeForMember, attributePosition, attributeSpacing, binaryOperatorSpacing, blankLines, bracesPosition, castSpacing, classDefinitionSpacing, commaSpacing, commentSpacing, concatSpacing, constructSpacing, controlStructureBraces, declareSpacing, doubleColonSpacing, earlyExit, elseifKeyword, eofLineEnding, explicitAssertion, explicitOperatorPrecedence, fallThroughComment, finalInternalClass, forbiddenAnnotations, forbiddenClasses, forbiddenFunctions, forbiddenMembers, forbiddenPhpdocLines, fullOpeningTag, functionNameSpacing, groupImport, heredocIndentation, importNotation, incrementForAddOne, indentation, keywordCasing, kindInClassName, lineEnding, lineLength, magicConstantCasing, multilineArray, multilineCall, multilineChain, multilineCondition, multilineImport, multilineSignature, multilineTernary, nameCasing, nameFallback, nameNotation, namedArgumentSpacing, nativeClassCasing, nativeFunctionCasing, newArgumentParentheses, noAlternativeSyntax, noBom, noClosingTag, noGlobalStatements, noHashComments, noImplicitBackslashes, noInnerFunctions, noShortBoolCasts, noTrailingWhitespace, noUnlistedNamespacedDeclarations, notEqualsNotation, nowdocWithoutInterpolation, numericLiteralSeparator, objectOperatorSpacing, offsetBracketSpacing, orderedImports, orderedMembers, parenthesesSpacing, phpdocAlignment, phpdocNullPosition, 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, trueFalseNullCasing, typeHintSpacing, unaryOperatorSpacing, visibilityRequired, yoda

modernization (27): arrayFirstNotation, arrayFunctionForForeach, arrowFunction, clampForMinMax, classConstantForConstantCall, combinedAssignmentForRepeatedTarget, combinedIssets, combinedUnsets, deprecatedAttributeForAnnotation, firstClassCallableNotation, getClassNotation, getDebugTypeForTernary, jsonValidateForDecode, matchForSwitch, noManualListTests, noManualSubstringTests, nullCoalescingForNullTernary, nullsafeForGuardedAccess, octalNotation, overrideAttributeRequired, pipeOperator, promotedPropertyForAssignment, roundingModeNotation, shortArraySyntax, shortTernaryForRepeatedCondition, stringableRequired, ternaryForIf

deprecations (16): castCanonicalType, complexStringVariable, csvEscapeArgumentRequired, mbConvertEncodingForUtf8, noBacktickOperators, noDeprecatedArguments, noDeprecatedClasses, noDeprecatedFunctions, noDeprecatedMembers, noFinalParents, noNullArrayKeys, noSleepAndWakeup, noUnimplementedAbstractMethods, nullableTypeForDefaultNull, overrideSignature, switchCaseColon

cleanup (33): classNameReferenceForString, commentedOutFunction, noAliasFunctions, noCallUserFunc, noDirectInvokeCalls, noEmptyComments, noEmptyPhpdocs, noEmptyStatements, noManualEmptyStringTests, returnForBooleanIf, unusedImports, uselessAlias, uselessAttributeParentheses, uselessBackslashInGlobalNamespace, uselessBraces, uselessCatchVariable, uselessConstantVarAnnotation, uselessConstructParentheses, uselessElse, uselessFunctionPhpdoc, uselessImportBackslash, uselessInheritdoc, uselessModifier, uselessNoOpCall, uselessNullInitialization, uselessOverridingMethod, uselessParameterDefault, uselessParenthesesAroundNew, uselessReturn, uselessSameNamespaceImport, uselessSetAccessible, uselessStringConcat, uselessTernaryOperator

types (5): neverForThrowingFunction, phpdocCanonicalTypes, propertyVarAnnotation, typeHintRequired, unionTypeNotation

correctness (14): noConsecutivePhpdocs, noContinueInSwitch, noDuplicateAssignments, noDuplicateReturnAnnotations, noEmptyVarAnnotations, noInvisibleCharacters, noNullDebugInfo, noStaticThis, noTrailingWhitespaceInString, noUnknownParamAnnotations, 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 (7): firstClassCallableNotation, neverForThrowingFunction, noManualListTests, octalNotation, readonlyForAnnotation, readonlyForUnwrittenProperty, uselessSetAccessible

PHP 8.2 (2): readonlyClassForReadonlyMembers, sensitiveParameterRequired

PHP 8.3 (3): classConstantForConstantCall, jsonValidateForDecode, overrideAttributeRequired

PHP 8.4 (4): arrayFunctionForForeach, deprecatedAttributeForAnnotation, roundingModeNotation, uselessParenthesesAroundNew

PHP 8.5 (2): arrayFirstNotation, 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

Reads 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/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::$name = literal', Class::method() or an interface → the attribute written instead, $value standing for the value of the member.

dresscode/attributePosition

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

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

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

Puts blank lines where the standard asks for them, in the header, the class, the block and between statements.

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
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
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 member following the trait uses, a method among them
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" Brace of a function whose parameters span several lines; nextLineAfterReturnType puts it on the next line only when there is 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" An empty anonymous class as {} on the line of new, whatever it holds inside
emptyBody sameLine | ownLine "ownLine" An empty body of a class, function, method or closure as {} on the line of its head; a comment inside makes it 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/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" Between the cast and its operand

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

Fetches a class constant by its name instead of asking constant() for it.

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 hugs them

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/combinedAssignmentForRepeatedTarget

Uses += and friends where an assignment repeats its target.

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

Asks about several variables in one isset() instead of a chain joined by &&.

Stage: Structure. Covers: combine_consecutive_issets.

dresscode/combinedUnsets

Drops several variables in one unset instead of consecutive statements.

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 around language constructs.

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 "none" Between fn and its parenthesis: none for fn(), as PER writes it, single for fn ()
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/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

Requires a comment on an intentional case 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

Makes classes annotated as internal 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/firstClassCallableNotation

Writes a callable in the first-class callable notation.

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

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

Requires the <?php opening tag.

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

Uses ::class instead of get_class() and __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/groupImport

Writes the imports of one namespace as a single group use declaration, and a group of too few of them as imports of their own.

Stage: Structure. Covers: group_import.

Option Type Default
minImports int 3 The imports of one namespace stand in a group use once there are at least this many of them, and in imports of their own while there are fewer

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 statement or all in one, and expands group use declarations.

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 its own import, combined puts all classes of the namespace into one; keep leaves them alone
function single | combined | keep "single"
constant single | combined | keep "single"
group expand | keep "expand" expand turns a group use of a checked kind into the shape of that kind, keep leaves it as it is

dresscode/incrementForAddOne

Uses ++ and -- instead of += 1 and -= 1.

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 binary operator opening a line steps in by when its expression has a line of its own that is not the line of the 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
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.

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

dresscode/kindInClassName

Decides whether the name of a class, interface or trait repeats its kind.

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

Unifies line endings.

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/magicConstantCasing

Writes magic constants in uppercase.

Stage: Structure. Covers: magic_constant_casing.

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

Spreads a multi-line or too wide array over lines, an item on each or several filling a line, the opening bracket on the line before.

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 on one line wider than this, from its opening bracket to its closing one, is spread over lines, more than five items filling each line up to the line length with keep; null leaves the width to the author

dresscode/multilineCall

Puts every argument of a multi-line call on its own line.

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

dresscode/multilineChain

Puts every link of a multi-line chain of calls on its own line, the first one included.

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 null A constant PHP declares where the compiler computes with it, in a constant expression or condition: qualified 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 decides 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

Normalizes whitespace around the colon of a named argument.

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

dresscode/nativeClassCasing

Writes the names of internal classes, interfaces and enums in their declared case.

Stage: Structure. Covers: class_reference_name_casing.

dresscode/nativeFunctionCasing

Calls native functions in lowercase.

Stage: Structure. Covers: native_function_casing, Squiz.PHP.LowercasePHPFunctions.

dresscode/neverForThrowingFunction

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

Stage: Structure. Needs PHP >=8.1.

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

dresscode/newArgumentParentheses

Requires or forbids the empty parentheses of an instantiation.

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

Option Type Default
namedClass required | forbidden | keep "required"
anonymousClass required | forbidden | keep "required"

dresscode/noAliasFunctions

Calls a function by its canonical name instead of an alias.

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

Runs a command through shell_exec() instead of backticks.

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

Calls a callable directly instead of through call_user_func().

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/noContinueInSwitch

Leaves a switch with break, never with continue.

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

dresscode/noConversionFunctions

Uses a cast instead of intval() and friends.

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

dresscode/noDeprecatedArguments

Removes the arguments the targeted version of PHP deprecated because nothing reads them.

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 deprecated in the targeted version of PHP.

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

Calls an invokable object directly instead of its __invoke() method.

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/noDuplicateReturnAnnotations

Reports more than one @return in a function doc comment.

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

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/noEmptyVarAnnotations

Reports a @var or @see without content in a property doc comment.

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/noGlobalStatements

Forbids 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

Tests whether a string is empty by comparing it with the empty string.

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/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.

dresscode/noSettype

Assigns a cast instead of calling settype().

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 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 trailing whitespace from string lines.

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/noUnknownParamAnnotations

Reports a @param of a parameter the function does not declare.

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

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

Uses nowdoc where a heredoc interpolates nothing.

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 use statements alphabetically, classes before functions before constants.

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

Option Type Default
caseSensitive bool false
order byName | byKind "byName" 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 | case | 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 method 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 Whether a parameter takes 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/phpdocCanonicalTypes

Writes the types in doc comments in their canonical form: short lowercase built-ins, one array notation, no repeated type in a union.

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, SlevomatCodingStandard.TypeHints.DisallowArrayTypeHintSyntax, SlevomatCodingStandard.TypeHints.LongTypeHints. Modifies comments.

Option Type Default
arrayNotation generic | brackets | keep "generic" generic writes int[] as array&lt;int>, brackets writes array&lt;int> as int[]; keep leaves both alone

dresscode/phpdocNullPosition

Moves null to the chosen end of union types in doc comments.

Stage: Structure. Covers: SlevomatCodingStandard.TypeHints.NullTypeHintOnLastPosition. Modifies comments.

Option Type Default
position last | first "last" Where null stands in a union type

dresscode/phpdocTrim

Removes extra blank lines in a doc comment.

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

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 How many calls the nest must hold before the pipe is asked for

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/propertyVarAnnotation

Reports a repeated or misplaced @var in a property doc comment.

Stage: Structure.

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 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

Calls the function a project or its libraries write 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, by its name in the same class, as Class::name in another, or the \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/shortArraySyntax

Writes arrays and destructuring with the short syntax.

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

dresscode/shortTernaryForRepeatedCondition

Uses ?: where the ternary repeats its condition.

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 comment that fits on one line follows the step as well; 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/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

Calls in_array(), array_search(), array_keys(), base64_decode() and mb_detect_encoding() with $strict = true.

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

Requires declare(strict_types=1) as the first statement of a file.

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

Decides which quotes a string that needs neither kind is written with.

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" The quotes a plain string is written with

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

Uses && and || instead of and and or.

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

dresscode/ternaryForIf

Uses the ternary operator where an if-else only picks one of two values.

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/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"
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/trueFalseNullCasing

Lowercases true, false and null.

Stage: Structure. Covers: constant_case, Generic.PHP.LowerCaseConstant.

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: their annotation must say what the items are

dresscode/typeHintSpacing

Normalizes whitespace in type declarations.

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 writes it, single for catch (A | B $e) as PSR-12 did

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.

dresscode/unionTypeNotation

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 "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; keep leaves their order alone

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/uselessAttributeParentheses

Removes the empty parentheses after the name of an attribute.

Stage: Structure. Covers: attribute_empty_parentheses.

dresscode/uselessBackslashInGlobalNamespace

Removes the leading backslash of names referenced in the global namespace.

Stage: Structure. Covers: PhpCsFixerCustomFixers/no_leading_slash_in_global_namespace.

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 whose annotation may say more than the native type, like array and iterable

dresscode/uselessImportBackslash

Removes the leading backslash from imported names.

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

dresscode/uselessInheritdoc

Removes a doc comment consisting of @inheritDoc only.

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

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 the functions that have freed nothing since PHP 8.0.

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/uselessSameNamespaceImport

Removes imports of names from the current namespace.

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

dresscode/uselessSetAccessible

Removes setAccessible() calls, which do nothing since PHP 8.1.

Stage: Structure. Needs PHP >=8.1.

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

Requires visibility on class members and orders their 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.

dresscode/yoda

Decides which side of a comparison the constant stands on.

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