PHP 8.6 vychází 19. listopadu. DressCode pro něj kód přepisuje už teď. 16 dní Přechod na novější PHP →

Sniffy PHP_CodeSnifferu v DressCode

Sniff ze svého phpcs.xml nebo z komentáře phpcs:ignore, třeba PSR12.Files.FileHeader, najdete v tabulce podle jména. Vedle něj stojí rozhodnutí DressCode, která kontrolují totéž, a odkazy vás dovedou k jejich hodnotám a příkladům.

Zatímco sniff kontroluje jednu konstrukci, třeba záhlaví souboru, rozhodnutí DressCode říká, jak v kódu vypadá jedna věc. Z jednoho sniffu proto bývá víc rozhodnutí: samotnému PSR12.Files.FileHeader odpovídá osm rozhodnutí o prázdných řádcích, od blankLines.afterOpeningTag po řádek před třídou. Komentáře phpcs:ignore se starými jmény fungují dál a celou konfiguraci převede dresscode migrate config phpcs.xml (viz Z PHP_CodeSnifferu a Slevomatu na DressCode).

Sniffy Slevomatu mají vlastní stránku. Sniff, který v tabulce chybí, zatím v DressCode protějšek nemá.

PHP_CodeSniffer DressCode
Generic.Arrays.DisallowLongArraySyntax literals.arraySyntax.array
Generic.Arrays.DisallowShortArraySyntax literals.arraySyntax.array
Generic.CodeAnalysis.RequireExplicitBooleanOperatorPrecedence expressions.explicitPrecedence
Generic.CodeAnalysis.UnnecessaryFinalModifier classes.modifiers.implied
Generic.ControlStructures.InlineControlStructure braces.bracelessBody
Generic.Files.ByteOrderMark file.bom
Generic.Files.LineEndings file.lineEnding
Generic.Files.LineLength file.lineLength, file.lineLengthExcept, file.longLines
Generic.Formatting.DisallowMultipleStatements file.statementsPerLine
Generic.Functions.FunctionCallArgumentSpacing spacing.comma, spacing.alignment.comma
Generic.Functions.FunctionCallArgumentSpacing.SpaceBeforeOpenBracket spacing.call
Generic.NamingConventions.CamelCapsFunctionName naming.method, naming.function
Generic.NamingConventions.UpperCaseConstantName naming.constant
Generic.NamingConventions.UpperCaseConstantName.ClassConstantNotUpperCase naming.constant
Generic.PHP.DeprecatedFunctions upgrading.php.deprecatedApi
Generic.PHP.DisallowShortOpenTag file.openingTag
Generic.PHP.ForbiddenFunctions upgrading.api.replacedFunctions, upgrading.api.forbiddenFunctions
Generic.PHP.LowerCaseConstant casing.trueFalseNull
Generic.PHP.LowerCaseKeyword casing.keyword
Generic.PHP.LowerCaseType expressions.cast, casing.keyword, casing.type
Generic.PHP.RequireStrictTypes file.strictTypes.declaration, file.strictTypes.position
Generic.PHP.SAPIUsage upgrading.api.forbiddenFunctions
Generic.Strings.UnnecessaryStringConcat literals.concatenatedLiterals, literals.concatenatedLiteralsOverLines, literals.emptyStringConcatenation
Generic.WhiteSpace.DisallowSpaceIndent indentation.unit
Generic.WhiteSpace.DisallowTabIndent indentation.unit
Generic.WhiteSpace.IncrementDecrementSpacing spacing.unaryOperator
Generic.WhiteSpace.LanguageConstructSpacing spacing.keyword
Generic.WhiteSpace.ScopeIndent indentation.unit
PEAR.Commenting.InlineComment comments.singleline
PEAR.Functions.ValidDefaultValue functions.unreachableParameterDefault
PEAR.WhiteSpace.ObjectOperatorIndent indentation.chain
PSR1.Methods.CamelCapsMethodName naming.method
PSR1.Methods.CamelCapsMethodName.NotCamelCaps naming.method
PSR2.Classes.ClassDeclaration spacing.keyword, multiline.items.implements, multiline.edges.implements, braces.position.class
PSR2.Classes.ClassDeclaration.SpaceBeforeKeyword spacing.keyword
PSR2.Classes.PropertyDeclaration classes.modifiers.order, classes.visibility.constant, classes.visibility.property, classes.visibility.method
PSR2.ControlStructures.ControlStructureSpacing spacing.padding.argument, spacing.padding.parameter, spacing.padding.closureUse, spacing.padding.controlStructure, spacing.padding.grouping
PSR2.ControlStructures.ElseIfDeclaration controlFlow.elseif
PSR2.ControlStructures.SwitchDeclaration spacing.keyword, controlFlow.switch.fallThroughComment, upgrading.php.caseSemicolon, spacing.switchCase, casing.keyword, indentation.switchCase, file.statementsPerLine
PSR2.ControlStructures.SwitchDeclaration.SpaceBeforeColonCASE spacing.switchCase
PSR2.Files.ClosingTag file.closingTagAtEnd
PSR2.Files.EndFileNewline file.finalLineEndings
PSR2.Methods.FunctionCallSignature spacing.call, multiline.items.argument, multiline.edges.argument, spacing.padding.argument, spacing.padding.parameter, spacing.padding.closureUse, spacing.padding.controlStructure, spacing.padding.grouping
PSR2.Methods.FunctionClosingBrace blankLines.bodyEnd.function, blankLines.bodyEnd.closure
PSR2.Methods.MethodDeclaration classes.modifiers.order
PSR2.Namespaces.NamespaceDeclaration blankLines.afterNamespace, blankLines.beforeDeclaration
PSR2.Namespaces.UseDeclaration imports.grouping.class, imports.grouping.function, imports.grouping.constant, blankLines.afterImports, blankLines.beforeDeclaration
PSR12.Classes.AnonClassDeclaration spacing.keyword, spacing.anonymousClass, multiline.items.implements, multiline.edges.implements, braces.position.anonymousClass, spacing.padding.argument, spacing.padding.parameter, spacing.padding.closureUse, spacing.padding.controlStructure, spacing.padding.grouping
PSR12.Classes.ClassInstantiation classes.emptyParentheses.instantiation
PSR12.Classes.ClosingBrace file.statementsPerLine
PSR12.Classes.OpeningBraceSpace blankLines.bodyStart.class, blankLines.bodyStart.anonymousClass
PSR12.ControlStructures.BooleanOperatorPlacement multiline.operatorPosition.condition
PSR12.ControlStructures.ControlStructureSpacing multiline.items.condition, multiline.edges.condition, spacing.padding.argument, spacing.padding.parameter, spacing.padding.closureUse, spacing.padding.controlStructure, spacing.padding.grouping
PSR12.Files.DeclareStatement spacing.declare, braces.position.controlStructure
PSR12.Files.FileHeader blankLines.afterOpeningTag, blankLines.afterDeclare, blankLines.beforeNamespace, blankLines.afterNamespace, blankLines.afterImports, blankLines.betweenImports, blankLines.betweenImportKinds, blankLines.beforeDeclaration
PSR12.Files.ImportStatement imports.leadingBackslash
PSR12.Files.OpenTag blankLines.afterOpeningTag
PSR12.Functions.NullableTypeDeclaration spacing.typeDeclaration
PSR12.Functions.ReturnTypeDeclaration spacing.typeDeclaration
PSR12.Keywords.ShortFormTypeKeywords expressions.cast
PSR12.Operators.OperatorSpacing spacing.binaryOperator, spacing.concatenation, spacing.alignment.binaryOperator, spacing.ternary, spacing.alignment.ternary
PSR12.Properties.ConstantVisibility classes.visibility.constant, classes.visibility.property, classes.visibility.method
PSR12.Traits.UseDeclaration spacing.keyword, classes.members.order, classes.members.grouping.traitUse, blankLines.bodyStart.class, blankLines.bodyEnd.class, blankLines.betweenTraitUses, blankLines.afterTraitUses, spacing.semicolon.before
Squiz.Arrays.ArrayBracketSpacing spacing.padding.offset
Squiz.Classes.SelfMemberReference qualification.currentClass
Squiz.Classes.ValidClassName naming.class
Squiz.Commenting.DocCommentAlignment phpdoc.stars
Squiz.Commenting.FunctionComment.DuplicateReturn phpdoc.annotation.duplicateReturn
Squiz.Commenting.FunctionComment.ExtraParamComment phpdoc.annotation.extraParam
Squiz.Commenting.VariableComment phpdoc.annotation.duplicateVar, phpdoc.annotation.empty, phpdoc.property.plainComment
Squiz.ControlStructures.ControlSignature spacing.keyword, braces.position.controlStructure, braces.position.continuingKeyword, spacing.openBrace
Squiz.ControlStructures.ForEachLoopDeclaration spacing.keyword, casing.keyword, spacing.padding.argument, spacing.padding.parameter, spacing.padding.closureUse, spacing.padding.controlStructure, spacing.padding.grouping
Squiz.ControlStructures.ForLoopDeclaration spacing.padding.argument, spacing.padding.parameter, spacing.padding.closureUse, spacing.padding.controlStructure, spacing.padding.grouping, spacing.semicolon.before, spacing.semicolon.after
Squiz.ControlStructures.LowercaseDeclaration casing.keyword
Squiz.Functions.FunctionDeclaration spacing.keyword, spacing.call
Squiz.Functions.FunctionDeclarationArgumentSpacing spacing.comma, spacing.alignment.comma
Squiz.Functions.LowercaseFunctionKeywords casing.keyword
Squiz.Functions.MultiLineFunctionDeclaration multiline.items.parameter, multiline.edges.parameter, braces.position.function, braces.position.multilineSignature, braces.position.closure, spacing.anonymousFunction
Squiz.NamingConventions.ValidFunctionName naming.method, naming.function
Squiz.NamingConventions.ValidVariableName naming.property, naming.variable
Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps naming.property
Squiz.NamingConventions.ValidVariableName.NotCamelCaps naming.variable
Squiz.NamingConventions.ValidVariableName.StringNotCamelCaps naming.variable
Squiz.Operators.ValidLogicalOperators expressions.wordLogicalOperator
Squiz.PHP.DiscouragedFunctions mistakes.debugOutput, upgrading.api.forbiddenFunctions
Squiz.PHP.GlobalKeyword mistakes.globalStatement
Squiz.PHP.InnerFunctions functions.innerFunction
Squiz.PHP.LowercasePHPFunctions casing.function
Squiz.Scope.MethodScope classes.visibility.constant, classes.visibility.property, classes.visibility.method, classes.visibility.interfaceMethod
Squiz.Scope.StaticThisUsage mistakes.thisOutsideObject
Squiz.Strings.ConcatenationSpacing spacing.concatenation
Squiz.Strings.DoubleQuoteUsage literals.quotes
Squiz.Strings.EchoedStrings expressions.parenthesesAfterConstruct
Squiz.WhiteSpace.CastSpacing expressions.cast
Squiz.WhiteSpace.ControlStructureSpacing blankLines.bodyStart.controlStructure, blankLines.bodyEnd.controlStructure, spacing.padding.controlStructure, blankLines.afterStatement
Squiz.WhiteSpace.FunctionOpeningBraceSpace blankLines.bodyStart.function, blankLines.bodyStart.closure
Squiz.WhiteSpace.FunctionSpacing blankLines.aroundMethods, blankLines.aroundInterfaceMethods, blankLines.bodyStart.class, blankLines.bodyEnd.class, blankLines.aroundDeclarations
Squiz.WhiteSpace.LogicalOperatorSpacing spacing.binaryOperator, spacing.alignment.binaryOperator
Squiz.WhiteSpace.ObjectOperatorSpacing spacing.objectOperator
Squiz.WhiteSpace.OperatorSpacing spacing.binaryOperator, spacing.alignment.binaryOperator
Squiz.WhiteSpace.OperatorSpacing.Unary spacing.unaryOperator, spacing.logicalNot
Squiz.WhiteSpace.ScopeKeywordSpacing spacing.doubleColon
Squiz.WhiteSpace.SemicolonSpacing spacing.semicolon.before, multiline.semicolon
Squiz.WhiteSpace.SuperfluousWhitespace file.trailingWhitespace

Zobrazit na GitHubu · Nahlásit problém se stránkou na GitHubu · 2. 11. 2026