nunomaduro/phpinsights
PHP Insights is a terminal tool to analyze PHP code quality, style, architecture, and complexity. Works out of the box with Laravel (artisan insights), Symfony, Yii, Magento, and more, with built-in checks for reliability and loose coupling.
All insights about style are regrouped in one Metric:
NunoMaduro\PhpInsights\Domain\Metrics\Style\Style <Badge text="Style" type="warn" vertical="middle"/>This sniff checks that the file does not end with a closing tag.
Insight Class: PHP_CodeSniffer\Standards\PSR2\Sniffs\Files\ClosingTagSniff
This sniff ensures the file ends with a newline character.
Insight Class: PHP_CodeSniffer\Standards\PSR2\Sniffs\Files\EndFileNewlineSniff
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
This sniff checks for merge conflict artifacts.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\VersionControl\GitMergeConflictSniff
This sniff detects BOMs that may corrupt application work.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\Files\ByteOrderMarkSniff
This sniff checks that end of line characters are correct.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\Files\LineEndingsSniff
\PHP_CodeSniffer\Standards\Generic\Sniffs\Files\LineEndingsSniff::class => [
'eolChar' => '\n',
]
This sniff checks that the closing brace of a function goes directly after the body.
Insight Class: PHP_CodeSniffer\Standards\PSR2\Sniffs\Methods\FunctionClosingBraceSniff
This sniff checks that object operators are indented correctly.
Insight Class: PHP_CodeSniffer\Standards\PEAR\Sniffs\WhiteSpace\ObjectOperatorIndentSniff
\PHP_CodeSniffer\Standards\PEAR\Sniffs\WhiteSpace\ObjectOperatorIndentSniff::class => [
'indent' => 4,
]
This sniff checks that the closing braces of scopes are aligned correctly.
Insight Class: PHP_CodeSniffer\Standards\PEAR\Sniffs\WhiteSpace\ScopeClosingBraceSniff
\PHP_CodeSniffer\Standards\PEAR\Sniffs\WhiteSpace\ScopeClosingBraceSniff::class => [
'indent' => 4,
]
This sniff bans the use of the PHP long array syntax (array()).
Use [] instead.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\Arrays\DisallowLongArraySyntaxSniff
This sniff checks the length of all lines in a file.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\Files\LineLengthSniff
\PHP_CodeSniffer\Standards\Generic\Sniffs\Files\LineLengthSniff::class => [
'lineLimit' => 80,
'absoluteLineLimit' => 100,
'ignoreComments' => false,
]
This sniff ensures there is a single space after cast tokens.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting\SpaceAfterCastSniff
This sniff ensures there is a single space after a NOT operator.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting\SpaceAfterNotSniff
This sniff checks that calls to methods and functions are spaced correctly.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\Functions\FunctionCallArgumentSpacingSniff
This sniff checks that the opening PHP tag is the first content in a file.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\CharacterBeforePHPOpeningTagSniff
This sniff disallows the use of the backtick execution operator.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\BacktickOperatorSniff
This sniff verifies that no alternative PHP tags are used.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\DisallowAlternativePHPTagsSniff
This sniff makes sure that shorthand PHP open tags are not used.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\DisallowShortOpenTagSniff
This sniff checks that all uses of true, false and null are lowercase.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\LowerCaseConstantSniff
This sniff checks that all PHP keywords are lowercase.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\LowerCaseKeywordSniff
This sniff checks that all PHP types are lowercase.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\LowerCaseTypeSniff
This sniff ensures the PHP_SAPI constant is used instead of php_sapi_name().
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\SAPIUsageSniff
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
This Insight process lint on all PHP files via php -l using PHP-Parallel-Lint.
Insight Class: NunoMaduro\PhpInsights\Domain\Insights\SyntaxCheck
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
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
This sniff throws errors if tabs are used for indentation.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\DisallowTabIndentSniff
This sniff verifies spacing between variables and increment/decrement operators.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\IncrementDecrementSpacingSniff
This sniff ensures all language constructs contain a single space between themselves and their content.
Insight Class: PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\LanguageConstructSpacingSniff
This sniff ensures method names are defined using camel case.
Insight Class: PHP_CodeSniffer\Standards\PSR1\Sniffs\Methods\CamelCapsMethodNameSniff
This sniff verifies that there are no else if statements (elseif should be used instead).
Insight Class: PHP_CodeSniffer\Standards\PSR2\Sniffs\ControlStructures\ElseIfDeclarationSniff
This sniff ensures all switch statements are defined correctly.
Insight Class: PHP_CodeSniffer\Standards\PSR2\Sniffs\ControlStructures\SwitchDeclarationSniff
\PHP_CodeSniffer\Standards\PSR2\Sniffs\ControlStructures\SwitchDeclarationSniff::class => [
'indent' => 4,
]
This sniff ensures that constant names are all uppercase.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\UpperCaseConstantNameSniff
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
This sniff enforces configurable number of lines before and after namespace.
Insight Class: SlevomatCodingStandard\Sniffs\Namespaces\NamespaceSpacingSniff
\SlevomatCodingStandard\Sniffs\Namespaces\NamespaceSpacingSniff::class => [
'linesCountBeforeNamespace' => 1,
'linesCountAfterNamespace' => 1,
]
This sniff checks there is only one namespace in a file.
Insight Class: SlevomatCodingStandard\Sniffs\Namespaces\RequireOneNamespaceInFileSniff
This sniff detects unused use in a file.
Insight Class: SlevomatCodingStandard\Sniffs\Namespaces\UnusedUsesSniff
\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](https://github.com/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](https://github.com/group) Cache annotation and Cache class
]
This sniff disallows leading backslash in use statement.
Insight Class: SlevomatCodingStandard\Sniffs\Namespaces\UseDoesNotStartWithBackslashSniff
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
\SlevomatCodingStandard\Sniffs\Namespaces\UseSpacingSniff::class => [
'linesCountBeforeFirstUse' => 1,
'linesCountBetweenUseTypes' => 0,
'linesCountAfterLastUse' => 1,
]
This sniff enforces a configurable number of spaces after the ... operator.
Insight Class: SlevomatCodingStandard\Sniffs\Operators\SpreadOperatorSpacingSniff
\SlevomatCodingStandard\Sniffs\Operators\SpreadOperatorSpacingSniff::class => [
'spacesCountAfterOperator' => 0,
]
This sniff enforces using short form of list syntax, [...] instead of list(...).
Insight Class: SlevomatCodingStandard\Sniffs\PHP\ShortListSniff
This sniff
Foo $foo?FooInsight Class: SlevomatCodingStandard\Sniffs\TypeHints\ParameterTypeHintSpacingSniff
This sniff enforces consistent formatting of return type hints.
Insight Class: SlevomatCodingStandard\Sniffs\TypeHints\ReturnTypeHintSpacingSniff
\SlevomatCodingStandard\Sniffs\TypeHints\ReturnTypeHintSpacingSniff::class => [
'spacesCountBeforeColon' => 0,
]
This sniff checks for unneeded whitespace.
Insight Class: PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\SuperfluousWhitespaceSniff
\PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\SuperfluousWhitespaceSniff::class => [
'ignoreBlankLines' => false,
]
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](https://github.com/param) and [@return](https://github.com/return)).
Insight Class: SlevomatCodingStandard\Sniffs\Commenting\DocCommentSpacingSniff
\SlevomatCodingStandard\Sniffs\Commenting\DocCommentSpacingSniff::class => [
'linesCountBeforeFirstContent' => 0,
'linesCountBetweenDescriptionAndAnnotations' => 1,
'linesCountBetweenDifferentAnnotationsTypes' => 0,
'linesCountBetweenAnnotationsGroups' => 1,
'linesCountAfterLastContent' => 0,
'annotationsGroups' => [],
]
This sniff verifies that classes are instantiated with parentheses.
Insight Class: PHP_CodeSniffer\Standards\PSR12\Sniffs\Classes\ClassInstantiationSniff
This fixer removes trailing commas in list function calls.
Insight Class: PhpCsFixer\Fixer\ArrayNotation\NoTrailingCommaInSinglelineArrayFixer
In array declarations, there MUST NOT be a whitespace before each comma.
Insight Class: PhpCsFixer\Fixer\ArrayNotation\NoWhitespaceBeforeCommaInArrayFixer
\PhpCsFixer\Fixer\ArrayNotation\NoWhitespaceBeforeCommaInArrayFixer::class => [
'after_heredoc' => false, // Whether the whitespace between heredoc end and comma should be removed.
]
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
\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']
]
PHP code must use only UTF-8 without BOM (remove BOM).
Insight Class: PhpCsFixer\Fixer\Basic\EncodingFixer
Class static references self, static and parent must be in lower case.
Insight Class: PhpCsFixer\Fixer\Casing\LowercaseStaticReferenceFixer
Magic constants should be referred to using the correct casing.
Insight Class: PhpCsFixer\Fixer\Casing\MagicConstantCasingFixer
Magic method definitions and calls must be using the correct casing.
Insight Class: PhpCsFixer\Fixer\Casing\MagicMethodCasingFixer
Function defined by PHP should be called using the correct casing.
Insight Class: PhpCsFixer\Fixer\Casing\NativeFunctionCasingFixer
Native type hints for functions should use the correct case.
Insight Class: PhpCsFixer\Fixer\Casing\NativeFunctionTypeDeclarationCasingFixer
A single space or none should be between cast and variable.
Insight Class: PhpCsFixer\Fixer\CastNotation\CastSpacesFixer
\PhpCsFixer\Fixer\CastNotation\CastSpacesFixer::class => [
'space' => 'single' // possible values ['single', 'none']
]
Whitespace around the keywords of a class, trait or interfaces definition should be one space.
Insight Class: PhpCsFixer\Fixer\ClassNotation\ClassDefinitionFixer
\PhpCsFixer\Fixer\ClassNotation\ClassDefinitionFixer::class => [
'multi_line_extends_each_single_line' => false,
'single_item_single_line' => false,
'single_line' => false,
]
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
There must be no trailing spaces inside comment or PHPDoc.
Insight Class: PhpCsFixer\Fixer\Comment\NoTrailingWhitespaceInCommentFixer
A case should be followed by a colon and not a semicolon.
Insight Class: PhpCsFixer\Fixer\ControlStructure\SwitchCaseSemicolonToColonFixer
This fixer removes extra spaces between colon and case value.
Insight Class: PhpCsFixer\Fixer\ControlStructure\SwitchCaseSpaceFixer
Spaces should be properly placed in a function declaration.
Insight Class: PhpCsFixer\Fixer\FunctionNotation\FunctionDeclarationFixer
\PhpCsFixer\Fixer\FunctionNotation\FunctionDeclarationFixer::class => [
'closure_function_spacing' => 'one' // possible values ['one', 'none']
]
This fixer adds missing spaces between function's argument and its type hint.
Insight Class: PhpCsFixer\Fixer\FunctionNotation\FunctionTypehintSpaceFixer
Binary operators should be surrounded by spaces as configured.
Insight Class: PhpCsFixer\Fixer\Operator\BinaryOperatorSpacesFixer
\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]
]
How can I help you explore Laravel packages today?