Documentation

PHPCSExtra

Table of Contents

Classes

DirnameSniff
Detect `dirname(__FILE__)` and nested uses of `dirname()`.
ArrayBraceSpacingSniff
Enforce consistent spacing for the open/close braces of arrays.
CommaAfterLastSniff
Enforce/forbid a comma after the last item in an array declaration.
DummyTokenizer
Dummy tokenizer class to allow for accessing the replaceTabsInToken() method.
DisallowShortArraySyntaxSniff
Disallow the use of the short array syntax.
DuplicateArrayKeySniff
Detect duplicate array keys in array declarations.
MixedArrayKeyTypesSniff
Forbid arrays which contain both array items with numeric keys as well as array items with string keys.
MixedKeyedUnkeyedArraySniff
Forbid arrays which contain both array items with an explicit key and array items without a key set.
DisallowAnonClassParenthesesSniff
Forbid for an anonymous class declaration/instantiation to have parentheses, except when parameters are being passed.
DisallowFinalClassSniff
Forbids classes from being declared as "final".
ModifierKeywordOrderSniff
Standardize the modifier keyword order for class declarations.
RequireAnonClassParenthesesSniff
Require that an anonymous class declaration/instantiation has parentheses, i.e. `new class().
RequireFinalClassSniff
Require classes being declared as "final".
ConstructorDestructorReturnSniff
Verify that a class constructor/destructor does not return anything, nor has a return type declaration (fatal error).
ForeachUniqueAssignmentSniff
Detects using the same variable for both the key as well as the value in a foreach assignment.
NoDoubleNegativeSniff
Detects double negation in code, which is effectively the same as a boolean cast, but with a much higher cognitive load.
NoEchoSprintfSniff
Detects use of `echo [v]sprintf();.
StaticInFinalClassSniff
Forbid the use of the `static` keyword for late static binding in OO constructs which are final.
LowercaseClassResolutionKeywordSniff
Verifies that the "::class" keyword when used for class name resolution is in lowercase.
ModifierKeywordOrderSniff
Standardize the modifier keyword order for OO constant declarations.
UppercaseMagicConstantsSniff
Verifies that PHP native `__...__` magic constants are in uppercase when used.
DisallowAlternativeSyntaxSniff
Forbid the use of the alternative syntax for control structures.
DisallowLonelyIfSniff
Disallow `if` statements as the only statement in an `else` block.
IfElseDeclarationSniff
Verifies that `else(if)` statements with braces are on a new line.
SeparateFunctionsFromOOSniff
A file should either declare (global/namespaced) functions or declare OO structures, but not both.
NoLongClosuresSniff
Forbids long closures.
RequireFinalMethodsInTraitsSniff
Require non-abstract, non-private methods in traits to be declared as "final".
DisallowLongListSyntaxSniff
Bans the use of the PHP long list syntax.
DisallowShortListSyntaxSniff
Bans the use of the PHP short list syntax.
DisallowCurlyBraceSyntaxSniff
Disallow the use of namespace declarations using the curly brace syntax.
DisallowDeclarationWithoutNameSniff
Forbids the use of namespace declarations without a namespace name.
EnforceCurlyBraceSyntaxSniff
Enforce the use of namespace declarations using the curly brace syntax.
OneDeclarationPerFileSniff
Disallow having more than one namespace declaration in a file.
NoReservedKeywordParameterNamesSniff
Verifies that parameters in function declarations do not use PHP reserved keywords as this can lead to confusing code when using PHP 8.0+ named parameters in function calls.
AlphabeticExtendsImplementsSniff
Verifies that the interface names used in a class/enum "implements" statement or an interface "extends" statement, are listed in alphabetic order.
ConcatPositionSniff
Enforces that the concatenation operator in multi-line concatenations is in a preferred position, either always at the start of the next line or always at the end of the previous line.
DisallowLogicalAndOrSniff
Enforce the use of the boolean `&&` and `||` operators instead of the logical `and`/`or` operators.
DisallowShortTernarySniff
Disallow the use of short ternaries.
DisallowStandalonePostIncrementDecrementSniff
Disallow the use of post-in/decrements in stand-alone statements and discourage the use of multiple increment/decrement operators in a stand-alone statement.
StrictComparisonsSniff
Enforce the use of strict comparisons.
TypeSeparatorSpacingSniff
Enforce no space around union type and intersection type separators.
LowercasePHPTagSniff
Enforce that the "PHP" in a PHP open tag is lowercase.
OneStatementInShortEchoTagSniff
Disallows multiple statements when PHP is opened with a short open echo tag.
DisallowMixedGroupUseSniff
Disallow group use statements which combine imports for namespace/OO, functions and/or constants in one statement.
DisallowUseClassSniff
Disallow class/trait/interface/enum import `use` statements.
DisallowUseConstSniff
Disallow constant import `use` statements.
DisallowUseFunctionSniff
Disallow function import `use` statements.
KeywordSpacingSniff
Enforce a single space after the keywords in import `use` statements.
LowercaseFunctionConstSniff
Verify that the `function` and `const` keyword in import `use` statements are lowercase.
NoLeadingBackslashSniff
Verifies that names being imported in import use statements do not start with a leading backslash.
NoUselessAliasesSniff
Detects useless aliases for import use statements.
AnonClassKeywordSpacingSniff
Checks the spacing between the "class" keyword and the open parenthesis for anonymous classes with parentheses.
CommaSpacingSniff
Check spacing around commas.
DisallowInlineTabsSniff
Enforces using spaces for mid-line alignment.
PrecisionAlignmentSniff
Detects when the indentation is not a multiple of a tab-width, i.e. when precision alignment is used.

        
On this page

Search results