Style
All insights about style are regrouped in one Metric:
NunoMaduro\PhpInsights\Domain\Metrics\Style\StyleStyle
Closing tag ^1.0 Style
This sniff checks that the file does not end with a closing tag.
Insight Class: PHP_CodeSniffer\Standards\PSR2\Sniffs\Files\ClosingTagSniff
End file newline ^1.0 Style
This sniff ensures the file ends with a newline character.
Insight Class: PHP_CodeSniffer\Standards\PSR2\Sniffs\Files\EndFileNewlineSniff
Side effects ^1.0 Style
This sniff ensures a file declares new symbols and causes no other side effects, or executes logic with side effects, but not both.
Insight Class: PHP_CodeSniffer\Standards\PSR1\Sniffs\Files\SideEffectsSniff
Git merge conflict ^1.0 Style
This sniff checks for merge conflict artifacts.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\VersionControl\GitMergeConflictSniff
Byte order mark ^1.0 Style
This sniff detects BOMs that may corrupt application work.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\Files\ByteOrderMarkSniff
Line endings ^1.0 Style configurable
This sniff checks that end of line characters are correct.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\Files\LineEndingsSniff
Configuration
\PHP_CodeSniffer\Standards\Generic\Sniffs\Files\LineEndingsSniff::class => [
'eolChar' => '\n',
]
Function closing brace ^1.0 Style
This sniff checks that the closing brace of a function goes directly after the body.
Insight Class: PHP_CodeSniffer\Standards\PSR2\Sniffs\Methods\FunctionClosingBraceSniff
Object operator indent ^1.0 Style configurable
This sniff checks that object operators are indented correctly.
Insight Class: PHP_CodeSniffer\Standards\PEAR\Sniffs\WhiteSpace\ObjectOperatorIndentSniff
Configuration
\PHP_CodeSniffer\Standards\PEAR\Sniffs\WhiteSpace\ObjectOperatorIndentSniff::class => [
'indent' => 4,
]
Scope closing brace ^1.0 Style configurable
This sniff checks that the closing braces of scopes are aligned correctly.
Insight Class: PHP_CodeSniffer\Standards\PEAR\Sniffs\WhiteSpace\ScopeClosingBraceSniff
Configuration
\PHP_CodeSniffer\Standards\PEAR\Sniffs\WhiteSpace\ScopeClosingBraceSniff::class => [
'indent' => 4,
]
Disallow long array syntax ^1.0 Style
This sniff bans the use of the PHP long array syntax (array()).
Use [] instead.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\Arrays\DisallowLongArraySyntaxSniff
Line length ^1.0 Style configurable
This sniff checks the length of all lines in a file.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\Files\LineLengthSniff
Configuration
\PHP_CodeSniffer\Standards\Generic\Sniffs\Files\LineLengthSniff::class => [
'lineLimit' => 80,
'absoluteLineLimit' => 100,
'ignoreComments' => false,
]
Space after cast ^1.0 Style
This sniff ensures there is a single space after cast tokens.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting\SpaceAfterCastSniff
Space after not ^1.0 Style
This sniff ensures there is a single space after a NOT operator.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting\SpaceAfterNotSniff
Function call argument spacing ^1.0 Style
This sniff checks that calls to methods and functions are spaced correctly.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\Functions\FunctionCallArgumentSpacingSniff
Character before PHP opening tag ^1.0 Style
This sniff checks that the opening PHP tag is the first content in a file.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\CharacterBeforePHPOpeningTagSniff
Backtick Operator ^1.0 Style
This sniff disallows the use of the backtick execution operator.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\BacktickOperatorSniff
Disallow alternative PHP tags ^1.0 Style
This sniff verifies that no alternative PHP tags are used.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\DisallowAlternativePHPTagsSniff
Disallow short open tag ^1.0 Style
This sniff makes sure that shorthand PHP open tags are not used.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\DisallowShortOpenTagSniff
Lower case constant ^1.0 Style
This sniff checks that all uses of true, false and null are lowercase.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\LowerCaseConstantSniff
Lower case keyword ^1.0 Style
This sniff checks that all PHP keywords are lowercase.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\LowerCaseKeywordSniff
Lower case type ^1.0 Style
This sniff checks that all PHP types are lowercase.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\LowerCaseTypeSniff
SAPI Usage ^1.0 Style
This sniff ensures the PHP_SAPI constant is used instead of php_sapi_name().
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\SAPIUsageSniff
Syntax ^1.0 Style Deprecated since 2.0
This sniff ensures PHP believes the syntax is clean.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\SyntaxSniff
Note: This sniff is deprecated, use insight below
Syntax Check ^2.0 Style
This Insight process lint on all PHP files via php -l using PHP-Parallel-Lint.
Insight Class: NunoMaduro\PhpInsights\Domain\Insights\SyntaxCheck
Trailing array comma ^1.0 Style
This sniff enforces trailing commas in multi-line arrays and requires short array syntax [].
Commas after the last element in an array make adding a new element easier and result in a cleaner versioning diff.
Insight Class: SlevomatCodingStandard\Sniffs\Arrays\TrailingArrayCommaSniff
Arbitrary parentheses spacing ^1.0 Style
This sniff checks whitespace on the inside of arbitrary parentheses.
Arbitrary parentheses are those which are not owned by a function (call), array or control structure. Spacing on the outside is not checked on purpose as this would too easily conflict with other spacing rules.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\ArbitraryParenthesesSpacingSniff
Disallow tab indent ^1.0 Style
This sniff throws errors if tabs are used for indentation.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\DisallowTabIndentSniff
Increment decrement spacing ^1.0 Style
This sniff verifies spacing between variables and increment/decrement operators.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\IncrementDecrementSpacingSniff
Language construct spacing ^1.0 Style
This sniff ensures all language constructs contain a single space between themselves and their content.
Insight Class: PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\LanguageConstructSpacingSniff
Camel caps method name ^1.0 Style
This sniff ensures method names are defined using camel case.
Insight Class: PHP_CodeSniffer\Standards\PSR1\Sniffs\Methods\CamelCapsMethodNameSniff
Else If declaration ^1.0 Style
This sniff verifies that there are no else if statements (elseif should be used instead).
Insight Class: PHP_CodeSniffer\Standards\PSR2\Sniffs\ControlStructures\ElseIfDeclarationSniff
Switch declaration ^1.0 Style configurable
This sniff ensures all switch statements are defined correctly.
Insight Class: PHP_CodeSniffer\Standards\PSR2\Sniffs\ControlStructures\SwitchDeclarationSniff
Configuration
\PHP_CodeSniffer\Standards\PSR2\Sniffs\ControlStructures\SwitchDeclarationSniff::class => [
'indent' => 4,
]
Upper case constant name ^1.0 Style
This sniff ensures that constant names are all uppercase.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\UpperCaseConstantNameSniff
Alphabetically sorted uses ^1.0 Style
This sniff checks whether uses at the top of a file are alphabetically sorted. Follows natural sorting and takes edge cases with special symbols into consideration.
Insight Class: SlevomatCodingStandard\Sniffs\Namespaces\AlphabeticallySortedUsesSniff
Namespace Spacing ^1.0 Style configurable
This sniff enforces configurable number of lines before and after namespace.
Insight Class: SlevomatCodingStandard\Sniffs\Namespaces\NamespaceSpacingSniff
Configuration
\SlevomatCodingStandard\Sniffs\Namespaces\NamespaceSpacingSniff::class => [
'linesCountBeforeNamespace' => 1,
'linesCountAfterNamespace' => 1,
]
Require one namespace in file ^1.0 Style
This sniff checks there is only one namespace in a file.
Insight Class: SlevomatCodingStandard\Sniffs\Namespaces\RequireOneNamespaceInFileSniff
Unused uses ^1.0 Style configurable
This sniff detects unused use in a file.
Insight Class: SlevomatCodingStandard\Sniffs\Namespaces\UnusedUsesSniff
Configuration
\SlevomatCodingStandard\Sniffs\Namespaces\UnusedUsesSniff::class => [
'searchAnnotations' => false,
'ignoredAnnotationNames' => [], // case sensitive list of annotation names that the sniff should ignore (only the name is ignored, annotation content is still searched). Useful for name collisions like @testCase annotation and TestCase class.
'ignoredAnnotations' => [], // case sensitive list of annotation names that the sniff ignore completely (both name and content are ignored). Useful for name collisions like @group Cache annotation and Cache class
]
Use does not start with Backslash ^1.0 Style
This sniff disallows leading backslash in use statement.
Insight Class: SlevomatCodingStandard\Sniffs\Namespaces\UseDoesNotStartWithBackslashSniff
Use spacing sniff ^1.0 Style configurable
This sniff enforces a configurable number of lines before first use, after last use and between two use statements.
Insight Class: SlevomatCodingStandard\Sniffs\Namespaces\UseSpacingSniff
Configuration
\SlevomatCodingStandard\Sniffs\Namespaces\UseSpacingSniff::class => [
'linesCountBeforeFirstUse' => 1,
'linesCountBetweenUseTypes' => 0,
'linesCountAfterLastUse' => 1,
]
Spread operator spacing ^1.0 Style configurable
This sniff enforces a configurable number of spaces after the ... operator.
Insight Class: SlevomatCodingStandard\Sniffs\Operators\SpreadOperatorSpacingSniff
Configuration
\SlevomatCodingStandard\Sniffs\Operators\SpreadOperatorSpacingSniff::class => [
'spacesCountAfterOperator' => 0,
]
Short list ^1.0 Style
This sniff enforces using short form of list syntax, [...] instead of list(...).
Insight Class: SlevomatCodingStandard\Sniffs\PHP\ShortListSniff
Parameter type hint spacing ^1.0 Style
This sniff
- checks that there's a single space between a type hint and a parameter name:
Foo $foo - checks that there's no whitespace between a nullability symbol and a type hint:
?Foo
Insight Class: SlevomatCodingStandard\Sniffs\TypeHints\ParameterTypeHintSpacingSniff
Return type hint spacing ^1.0 Style configurable
This sniff enforces consistent formatting of return type hints.
Insight Class: SlevomatCodingStandard\Sniffs\TypeHints\ReturnTypeHintSpacingSniff
Configuration
\SlevomatCodingStandard\Sniffs\TypeHints\ReturnTypeHintSpacingSniff::class => [
'spacesCountBeforeColon' => 0,
]
Superfluous Whitespace ^1.0 Style configurable
This sniff checks for unneeded whitespace.
Insight Class: PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\SuperfluousWhitespaceSniff
Configuration
\PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\SuperfluousWhitespaceSniff::class => [
'ignoreBlankLines' => false,
]
Doc comment spacing ^1.0 Style configurable
This sniff enforces a configurable number of lines before first content (description or annotation), after last content (description or annotation), between description and annotations and between two different annotations types (eg. between @param and @return).
Insight Class: SlevomatCodingStandard\Sniffs\Commenting\DocCommentSpacingSniff
Configuration
\SlevomatCodingStandard\Sniffs\Commenting\DocCommentSpacingSniff::class => [
'linesCountBeforeFirstContent' => 0,
'linesCountBetweenDescriptionAndAnnotations' => 1,
'linesCountBetweenDifferentAnnotationsTypes' => 0,
'linesCountBetweenAnnotationsGroups' => 1,
'linesCountAfterLastContent' => 0,
'annotationsGroups' => [],
]
Class instantiation ^1.0 Style
This sniff verifies that classes are instantiated with parentheses.
Insight Class: PHP_CodeSniffer\Standards\PSR12\Sniffs\Classes\ClassInstantiationSniff
No trailing comma in single line array ^1.10 Style
This fixer removes trailing commas in list function calls.
Insight Class: PhpCsFixer\Fixer\ArrayNotation\NoTrailingCommaInSinglelineArrayFixer
No whitespace before comma in array ^1.10 Style configurable
In array declarations, there MUST NOT be a whitespace before each comma.
Insight Class: PhpCsFixer\Fixer\ArrayNotation\NoWhitespaceBeforeCommaInArrayFixer
Configuration
\PhpCsFixer\Fixer\ArrayNotation\NoWhitespaceBeforeCommaInArrayFixer::class => [
'after_heredoc' => false, // Whether the whitespace between heredoc end and comma should be removed.
]
Braces ^1.10 Style configurable
The body of each structure must be enclosed by braces. Braces should be properly placed. Body of braces should be properly indented.
Insight Class: PhpCsFixer\Fixer\Basic\BracesFixer
Configuration
\PhpCsFixer\Fixer\Basic\BracesFixer::class => [
'allow_single_line_closure' => false,
'position_after_anonymous_constructs' => 'same', // possible values ['same', 'next']
'position_after_control_structures' => 'same', // possible values ['same', 'next']
'position_after_functions_and_oop_constructs' => 'same', // possible values ['same', 'next']
]
Encoding ^1.10 Style
PHP code must use only UTF-8 without BOM (remove BOM).
Insight Class: PhpCsFixer\Fixer\Basic\EncodingFixer
Lowercase static reference ^1.10 Style
Class static references self, static and parent must be in lower case.
Insight Class: PhpCsFixer\Fixer\Casing\LowercaseStaticReferenceFixer
Magic constant casing ^1.10 Style
Magic constants should be referred to using the correct casing.
Insight Class: PhpCsFixer\Fixer\Casing\MagicConstantCasingFixer
Magic method casing ^1.10 Style
Magic method definitions and calls must be using the correct casing.
Insight Class: PhpCsFixer\Fixer\Casing\MagicMethodCasingFixer
Native function casing ^1.10 Style
Function defined by PHP should be called using the correct casing.
Insight Class: PhpCsFixer\Fixer\Casing\NativeFunctionCasingFixer
Native function type declaration casing ^1.10 Style
Native type hints for functions should use the correct case.
Insight Class: PhpCsFixer\Fixer\Casing\NativeFunctionTypeDeclarationCasingFixer
Cast spaces ^1.10 Style configurable
A single space or none should be between cast and variable.
Insight Class: PhpCsFixer\Fixer\CastNotation\CastSpacesFixer
Configuration
\PhpCsFixer\Fixer\CastNotation\CastSpacesFixer::class => [
'space' => 'single' // possible values ['single', 'none']
]
Class definition fixer ^1.10 Style configurable
Whitespace around the keywords of a class, trait or interfaces definition should be one space.
Insight Class: PhpCsFixer\Fixer\ClassNotation\ClassDefinitionFixer
Configuration
\PhpCsFixer\Fixer\ClassNotation\ClassDefinitionFixer::class => [
'multi_line_extends_each_single_line' => false,
'single_item_single_line' => false,
'single_line' => false,
]
No blank lines after class opening ^1.10 Style
Ensure there is no code on the same line as the PHP open tag and it is followed by a blank line.
Insight Class: PhpCsFixer\Fixer\ClassNotation\NoBlankLinesAfterClassOpeningFixer
No trailing whitespace in comment ^1.10 Style
There must be no trailing spaces inside comment or PHPDoc.
Insight Class: PhpCsFixer\Fixer\Comment\NoTrailingWhitespaceInCommentFixer
Switch case semicolon to colon ^1.10 Style
A case should be followed by a colon and not a semicolon.
Insight Class: PhpCsFixer\Fixer\ControlStructure\SwitchCaseSemicolonToColonFixer
Switch case space ^1.10 Style
This fixer removes extra spaces between colon and case value.
Insight Class: PhpCsFixer\Fixer\ControlStructure\SwitchCaseSpaceFixer
Function declaration ^1.10 Style configurable
Spaces should be properly placed in a function declaration.
Insight Class: PhpCsFixer\Fixer\FunctionNotation\FunctionDeclarationFixer
Configuration
\PhpCsFixer\Fixer\FunctionNotation\FunctionDeclarationFixer::class => [
'closure_function_spacing' => 'one' // possible values ['one', 'none']
]
Function type hint space ^1.10 Style
This fixer adds missing spaces between function's argument and its type hint.
Insight Class: PhpCsFixer\Fixer\FunctionNotation\FunctionTypehintSpaceFixer
Binary operator space ^1.10 Style configurable
Binary operators should be surrounded by spaces as configured.
Insight Class: PhpCsFixer\Fixer\Operator\BinaryOperatorSpacesFixer
Configuration
\PhpCsFixer\Fixer\Operator\BinaryOperatorSpacesFixer::class => [
'align_double_arrow' => false, // Whether to apply, remove or ignore double arrows alignment: possibles values [true, false, null]
'align_equals' => false, // Whether to apply, remove or ignore equals alignment: possibles values [true, false, null]
'default' => 'single_space', // default fix strategy: possibles values ['align', 'align_single_space', 'align_single_space_minimal', 'single_space', 'no_space', null]
]
Standardize not equals ^1.10 Style
This fixer replaces all <> with !=.
Insight Class: PhpCsFixer\Fixer\Operator\StandardizeNotEqualsFixer
Align multiline comment ^1.10 Style configurable
Each line of multi-line DocComments must have an asterisk and must be aligned with the first one.
Insight Class: PhpCsFixer\Fixer\Phpdoc\AlignMultilineCommentFixer
Configuration
\PhpCsFixer\Fixer\Phpdoc\AlignMultilineCommentFixer::class => [
'comment_type' => 'phpdocs_only' // possible values ['phpdocs_only', 'phpdocs_like', 'all_multiline']
]
Full opening tag ^1.10 Style
PHP code must use the long <?php tags or short-echo <?= tags and not other tag variations.
Insight Class: PhpCsFixer\Fixer\PhpTag\FullOpeningTagFixer
No single line whitespace before semicolons ^1.10 Style
Single-line whitespace before closing semicolon are prohibited.
Insight Class: PhpCsFixer\Fixer\Semicolon\NoSinglelineWhitespaceBeforeSemicolonsFixer
Single quote ^1.10 Style configurable
This fixer converts double quotes to single quotes for simple strings.
Insight Class: PhpCsFixer\Fixer\StringNotation\SingleQuoteFixer
Configuration
\PhpCsFixer\Fixer\StringNotation\SingleQuoteFixer::class => [
'strings_containing_single_quote_chars' => false,
]
Method chaining indentation ^1.10 Style
Method chaining must be properly indented. Method chaining with different levels of indentation is not supported.
Insight Class: PhpCsFixer\Fixer\Whitespace\MethodChainingIndentationFixer
No extra blank lines ^1.10 Style configurable
This fixer removes extra blank lines and/or blank lines following configuration.
Insight Class: PhpCsFixer\Fixer\Whitespace\NoExtraBlankLinesFixer
Configuration
\PhpCsFixer\Fixer\Whitespace\NoExtraBlankLinesFixer::class => [
'tokens' => ['extra'], // possibles values ['break', 'case', 'continue', 'curly_brace_block', 'default', 'extra', 'parenthesis_brace_block', 'return', 'square_brace_block', 'switch', 'throw', 'use', 'use_trait']
]
No spaces around offset ^1.10 Style configurable
There must not be spaces around offset braces.
Insight Class: PhpCsFixer\Fixer\Whitespace\NoSpacesAroundOffsetFixer
Configuration
\PhpCsFixer\Fixer\Whitespace\NoSpacesAroundOffsetFixer::class => [
'positions' => ['inside', 'outside'],
]
No spaces inside parenthesis ^1.10 Style
There must not be a space after the opening parenthesis. There must not be a space before the closing parenthesis.
Insight Class: PhpCsFixer\Fixer\Whitespace\NoSpacesInsideParenthesisFixer
No trailing whitespace ^1.10 Style
This fixer removes trailing whitespace at the end of non-blank lines.
Insight Class: PhpCsFixer\Fixer\Whitespace\NoTrailingWhitespaceFixer
No whitespace in blank line ^1.10 Style
This fixer removes trailing whitespace at the end of blank lines.
Insight Class: PhpCsFixer\Fixer\Whitespace\NoWhitespaceInBlankLineFixer
Single blank line at eof ^1.10 Style
A PHP file without end tag must always end with a single empty line feed.
Insight Class: PhpCsFixer\Fixer\Whitespace\SingleBlankLineAtEofFixer
Ordered class elements ^1.10 Style configurable
This sniff orders the elements of classes/interfaces/traits.
Insight Class: PhpCsFixer\Fixer\ClassNotation\OrderedClassElementsFixer
Configuration
\PhpCsFixer\Fixer\ClassNotation\OrderedClassElementsFixer::class => [
'order' => [ // List of strings defining order of elements.
'use_trait',
'constant_public',
'constant_protected',
'constant_private',
'property_public',
'property_protected',
'property_private',
'construct',
'destruct',
'magic',
'phpunit',
'method_public',
'method_protected',
'method_private',
],
'sort_algorithm' => 'none' // possible values ['none', 'alpha']
]
Single class element per statement ^1.10 Style configurable
There must not be more than one property or constant declared per statement.
Insight Class: PhpCsFixer\Fixer\ClassNotation\SingleClassElementPerStatementFixer
Configuration
\PhpCsFixer\Fixer\ClassNotation\SingleClassElementPerStatementFixer::class => [
'elements' => [
'const',
'property',
],
]
Ordered imports ^1.10 Style configurable
This sniff orders use statements (import of classes).
Insight Class: PhpCsFixer\Fixer\Import\OrderedImportsFixer
Configuration
\PhpCsFixer\Fixer\Import\OrderedImportsFixer::class => [
'imports_order' => ['class', 'const', 'function'],
'sort_algorithm' => 'alpha', // possible values ['alpha', 'length', 'none']
]
Single import pert statement ^1.10 Style
There must be one use keyword per declaration.
Insight Class: PhpCsFixer\Fixer\Import\SingleImportPerStatementFixer
Phpdoc trim ^1.10 Style
PHPDoc should start and end with content, excluding the very first and last line of the DocBlocks.
Insight Class: PhpCsFixer\Fixer\Phpdoc\PhpdocTrimFixer
Phpdoc var annotation correct order ^1.10 Style
@var and @type annotations must have type and name in the correct order.
Insight Class: PhpCsFixer\Fixer\Phpdoc\PhpdocVarAnnotationCorrectOrderFixer
Phpdoc indent ^1.10 Style
DocBlocks should have the same indentation as the documented subject.
Insight Class: PhpCsFixer\Fixer\Phpdoc\PhpdocIndentFixer
Phpdoc inline tag ^1.10 Style
This fixer fixes PHPDoc inline tags, make @inheritdoc always inline.
Insight Class: PhpCsFixer\Fixer\Phpdoc\PhpdocInlineTagFixer