Skip to content
On this page

Squiz Sniffs

ArrayBracketSpacing

Ensure that there are no spaces around square brackets.

ArrayDeclaration

Ensures that arrays conform to the array coding standard.

ClassDeclaration

Checks the declaration of the class and its inheritance is correct.

ClassFileName

Tests that the file name and the name of the class contained within the file match.

DuplicateProperty

Ensures JS classes don't contain duplicate property names.

LowercaseClassKeywords

Ensures all class keywords are lowercase.

SelfMemberReference

Tests self member references.

Verifies that :

  • self:: is used instead of Self::
  • self:: is used for local static member reference
  • self:: is used instead of self ::

ValidClassName

Ensures classes are in camel caps, and the first letter is capitalised.

BlockComment

Verifies that block comments are used appropriately.

ClassComment

Parses and verifies the class doc comment.

Verifies that :

  • A class doc comment exists.
  • The comment uses the correct docblock style.
  • There are no blank lines after the class comment.
  • No tags are used in the docblock.

ClosingDeclarationComment

Checks the //end ... comments on classes, interfaces and functions.

DocCommentAlignment

Tests that the stars in a doc comment align correctly.

EmptyCatchComment

Checks for empty catch clause without a comment.

FileComment

Parses and verifies the file doc comment.

FunctionComment

Parses and verifies the doc comments for functions.

FunctionCommentThrowTag

Verifies that a @throws tag exists for each exception type a function throws.

InlineComment

Checks that there is adequate spacing between comments.

LongConditionClosingComment

Ensures long conditions have a comment at the end.

PostStatementComment

Checks to ensure that there are no comments after statements.

VariableComment

Parses and verifies the variable doc comment.

ControlSignature

Verifies that control statements conform to their coding standards.

ElseIfDeclaration

Ensures the use of else if over elseif.

ForEachLoopDeclaration

Verifies that there is a space between each condition of foreach loops.

ForLoopDeclaration

Verifies that there is a space between each condition of for loops.

InlineIfDeclaration

Tests the spacing of shorthand IF statements.

LowercaseDeclaration

Ensures all control structure keywords are lowercase.

SwitchDeclaration

Enforces switch statement formatting.

ClassDefinitionClosingBraceSpace

Ensure there is a single blank line after the closing brace of a class definition.

ClassDefinitionNameSpacing

Ensure there are no blank lines between the names of classes/IDs.

ClassDefinitionOpeningBraceSpace

Ensure a single space before, and a newline after, the class opening brace

ColonSpacing

Ensure there is no space before a colon and one space after it.

ColourDefinition

Ensure colours are defined in upper-case and use shortcuts where possible.

DisallowMultipleStyleDefinitions

Ensure that each style definition is on a line by itself.

DuplicateClassDefinition

Check for duplicate class definitions that can be merged into one.

DuplicateStyleDefinition

Check for duplicate style definitions in the same class.

EmptyClassDefinition

Ensure that class definitions are not empty.

EmptyStyleDefinition

Ensure that style definitions are not empty.

ForbiddenStyles

Bans the use of some styles, such as deprecated or browser-specific styles.

Indentation

Ensures styles are indented 4 spaces.

LowercaseStyleDefinition

Ensure that all style definitions are in lowercase.

MissingColon

Ensure that all style definitions have a colon.

NamedColours

Ensure colour names are not used.

Opacity

Ensure that opacity values start with a 0 if it is not a whole number.

SemicolonSpacing

Ensure each style definition has a semi-colon and it is spaced correctly.

ShorthandSize

Ensure sizes are defined using shorthand notation where possible.

JavaScriptLint

Runs JavaScript Lint on the file.

JSLint

Runs jslint.js on the file.

FileExtension

Tests that classes and interfaces are not declared in .php files.

OperatorBracket

Tests that all arithmetic operations are bracketed.

FunctionDeclarationArgumentSpacing

Checks that arguments in function declarations are spaced correctly.

FunctionDeclaration

Checks the function declaration is correct.

FunctionDuplicateArgument

Checks that duplicate arguments are not used in function declarations.

GlobalFunction

Tests for functions outside of classes.

LowercaseFunctionKeywords

Ensures all function keywords are lowercase.

MultiLineFunctionDeclaration

Ensure single and multi-line function declarations are defined correctly.

ValidFunctionName

Ensures method names are correct.

ValidVariableName

Checks the naming of variables and member variables.

DisallowObjectStringIndex

Ensures that object indexes are written in dot notation.

ObjectInstantiation

Ensures objects are assigned to a variable when instantiated.

ObjectMemberComma

Ensures the last member of an object is not followed by a comma.

ComparisonOperatorUsage

A Sniff to enforce the use of IDENTICAL type operators rather than EQUAL operators.

IncrementDecrementUsage

Ensures that the ++ operators are used when possible.

ValidLogicalOperators

Ensures logical operators 'and' and 'or' are not used.

CommentedOutCode

Warn about commented out code.

DisallowBooleanStatement

Ensures that boolean operators are only used inside control structure conditions.

DisallowComparisonAssignment

Ensures that the value of a comparison is not assigned to a variable.

DisallowInlineIf

Stops inline IF statements from being used.

DisallowMultipleAssignments

Ensures there is only one assignment on a line, and that it is the first thing on the line.

DisallowSizeFunctionsInLoops

Bans the use of size-based functions in loop conditions.

DiscouragedFunctions

Discourages the use of debug functions.

EmbeddedPhp

Checks the indentation of embedded PHP code segments.

Eval

The use of eval() is discouraged.

GlobalKeyword

Stops the usage of the "global" keyword.

Heredoc

Bans the use of heredocs and nowdocs.

InnerFunctions

Ensures that functions within functions are never used.

LowercasePHPFunctions

Ensures all calls to inbuilt PHP functions are lowercase.

NonExecutableCode

Warns about code that can never been executed.

MemberVarScope

Verifies that class members have scope modifiers.

MethodScope

Verifies that class methods have scope modifiers.

StaticThisUsage

Checks for usage of $this in static methods, which will cause runtime errors.

ConcatenationSpacing

Makes sure there are no spaces around the concatenation operator.

DoubleQuoteUsage

Makes sure that any use of double quotes strings are warranted.

EchoedStrings

Makes sure that any strings that are "echoed" are not enclosed in brackets.

CastSpacing

Ensure cast statements don't contain whitespace.

ControlStructureSpacing

Checks that control structures have the correct spacing around brackets.

FunctionClosingBraceSpace

Checks that there is one empty line before the closing brace of a function.

FunctionOpeningBraceSpace

Checks that there is no empty line after the opening brace of a function.

FunctionSpacing

Checks the separation between functions and methods.

LanguageConstructSpacing

Ensures all language constructs contain a single space between themselves and their content.

LogicalOperatorSpacing

Verifies that operators have valid spacing surrounding them.

MemberVarSpacing

Verifies that class members are spaced correctly.

ObjectOperatorSpacing

Ensure there is no whitespace before/after an object operator.

OperatorSpacing

Verifies that operators have valid spacing surrounding them.

PropertyLabelSpacing

Ensures that a property or label colon has a single space after it and no space before it.

ScopeClosingBrace

Checks that the closing braces of scopes are aligned correctly.

ScopeKeywordSpacing

Ensure there is a single space after scope keywords.

SemicolonSpacing

Ensure there is no whitespace before a semicolon.

SuperfluousWhitespace

Checks for unneeded whitespace.

Checks that no whitespace precedes the first content of the file, exists after the last content of the file, resides after content on any line, or are two empty lines in functions.

Released under the MIT License.