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.
The following insights are organised in different metrics :
NunoMaduro\PhpInsights\Domain\Metrics\Code\Classes <Badge text="Code\Classes" type="warn" vertical="middle"/>NunoMaduro\PhpInsights\Domain\Metrics\Code\Code <Badge text="Code\Code" type="warn" vertical="middle"/>NunoMaduro\PhpInsights\Domain\Metrics\Code\Comments <Badge text="Code\Comments" type="warn" vertical="middle"/>NunoMaduro\PhpInsights\Domain\Metrics\Code\Functions <Badge text="Code\Functions" type="warn" vertical="middle"/>NunoMaduro\PhpInsights\Domain\Metrics\Code\Globally <Badge text="Code\Globally" type="warn" vertical="middle"/>This sniff disallows public properties.
Insight Class v1.0: ObjectCalisthenics\Sniffs\Classes\ForbiddenPublicPropertySniff
Insight Class v2.0: SlevomatCodingStandard\Sniffs\Classes\ForbiddenPublicPropertySniff
This sniff detects unused private elements
Insight Class: SlevomatCodingStandard\Sniffs\Classes\UnusedPrivateElementsSniff
This sniff disallows setter methods.
Insight Class: NunoMaduro\PhpInsights\Domain\Sniffs\ForbiddenSetterSniff
This sniff detects unnecessary final modifiers inside of final classes.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\UnnecessaryFinalModifierSniff
This sniff verifies that properties are declared correctly.
Insight Class: PHP_CodeSniffer\Standards\PSR2\Sniffs\Classes\PropertyDeclarationSniff
This sniff requires declaring visibility for all class constants.
Insight Class: SlevomatCodingStandard\Sniffs\Classes\ClassConstantVisibilitySniff
This sniff disallows late static binding for constants.
Insight Class: SlevomatCodingStandard\Sniffs\Classes\DisallowLateStaticBindingForConstantsSniff
This sniff reports use of __CLASS__, get_parent_class(), get_called_class(), get_class() and get_class($this). Class names should be referenced via ::class constant when possible.
Insight Class: SlevomatCodingStandard\Sniffs\Classes\ModernClassNameReferenceSniff
This sniff reports useless late static binding.
Insight Class: SlevomatCodingStandard\Sniffs\Classes\UselessLateStaticBindingSniff
This fixer converts protected variables and methods to private where possible.
Insight Class: PhpCsFixer\Fixer\ClassNotation\ProtectedToPrivateFixer
This sniff detects unused variables.
Insight Class: SlevomatCodingStandard\Sniffs\Variables\UnusedVariableSniff
This sniff runs the Zend Code Analyzer (from Zend Studio) on files.
Insight Class: PHP_CodeSniffer\Standards\Zend\Sniffs\Debug\CodeAnalyzerSniff
This sniff ensures all switch statements are defined correctly.
Insight Class: PHP_CodeSniffer\Standards\PSR2\Sniffs\ControlStructures\SwitchDeclarationSniff
This sniff ensures all language constructs contain a single space between themselves and their content
Insight Class: PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\LanguageConstructSpacingSniff
Insight Class: ObjectCalisthenics\Sniffs\NamingConventions\ElementNameMinimalLengthSniff
\ObjectCalisthenics\Sniffs\NamingConventions\ElementNameMinimalLengthSniff::class => [
'minLength' => 3,
'allowedShortNames' => ['i', 'id', 'to', 'up'],
]
Insight Class: ObjectCalisthenics\Sniffs\Metrics\MaxNestingLevelSniff
\ObjectCalisthenics\Sniffs\Metrics\MaxNestingLevelSniff::class => [
'maxNestingLevel' => 2,
]
Insight Class: SlevomatCodingStandard\Sniffs\Variables\UselessVariableSniff
This sniff detects usage of the eval() function.
Insight Class: PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\EvalSniff
This sniff ensures arrays are correctly indented
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\Arrays\ArrayIndentSniff
\PHP_CodeSniffer\Standards\Generic\Sniffs\Arrays\ArrayIndentSniff::class => [
'indent' => 4,
]
Checks against empty PHP statements.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\EmptyPHPStatementSniff
This sniff detects empty statement.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\EmptyStatementSniff
This sniff detects for-loops that can be simplified to a while-loop
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\ForLoopShouldBeWhileLoopSniff
This sniff detects for-loops that use a function call in the test expression.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\ForLoopWithTestFunctionCallSniff
This sniff detects the usage of one and the same incrementer into an outer and an inner loop. Even it is intended this is confusing code.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\JumbledIncrementerSniff
This sniff detects statement conditions that are only set to one of the constant values true or false
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\UnconditionalIfStatementSniff
This sniff detects the use of methods that only call their parent class's method with the same name and arguments. These methods are not required.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\UselessOverridingMethodSniff
This sniff verifies that inline control statements are not present.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\ControlStructures\InlineControlStructureSniff
This sniff ensures each statement is on a line by itself.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting\DisallowMultipleStatementsSniff
This sniff disallows the use of the backtick execution operator.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\BacktickOperatorSniff
This sniff discourages the use of the PHP goto language construct.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\DiscourageGotoSniff
This sniff detects when any code prefixed with an ampersand is encountered.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\NoSilencedErrorsSniff
This sniff checks that two strings are not concatenated together; suggests using one string instead.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\Strings\UnnecessaryStringConcatSniff
This sniff verifies that the short form of type keywords is used (e.g., int, bool).
Insight Class: PHP_CodeSniffer\Standards\PSR12\Sniffs\Keywords\ShortFormTypeKeywordsSniff
This sniff disallows implicit array creation.
Insight Class: SlevomatCodingStandard\Sniffs\Arrays\DisallowImplicitArrayCreationSniff
This sniff disallows assignments in conditions.
Insight Class: SlevomatCodingStandard\Sniffs\ControlStructures\AssignmentInConditionSniff
This sniff disallows the use of continue without an integer operand in a switch because it emits a warning in PHP 7.3 and higher.
Insight Class: SlevomatCodingStandard\Sniffs\ControlStructures\DisallowContinueWithoutIntegerOperandInSwitchSniff
This sniff disallows use of empty().
Insight Class: SlevomatCodingStandard\Sniffs\ControlStructures\DisallowEmptySniff
This sniff disallows the short ternary operator ?:.
Insight Class: SlevomatCodingStandard\Sniffs\ControlStructures\DisallowShortTernaryOperatorSniff
Yoda conditions decrease code comprehensibility and readability by switching operands around comparison operators forcing the reader to read the code in an unnatural way.
Insight Class: SlevomatCodingStandard\Sniffs\ControlStructures\DisallowYodaComparisonSniff
This sniff enforces yoda comparison usage.
Insight Class: SlevomatCodingStandard\Sniffs\ControlStructures\RequireYodaComparisonSniff
Insight Class: SlevomatCodingStandard\Sniffs\ControlStructures\LanguageConstructWithParenthesesSniff
This sniff finds unreachable catch blocks.
Insight Class: SlevomatCodingStandard\Sniffs\Exceptions\DeadCatchSniff
try {
doStuff();
} catch (\Throwable $e) {
log($e);
} catch (\InvalidArgumentException $e) {
// unreachable!
}
This sniff looks for unused inherited variables passed to closures via use.
Insight Class: SlevomatCodingStandard\Sniffs\Functions\UnusedInheritedVariablePassedToClosureSniff
This sniff looks for useless parameter default value.
Insight Class: SlevomatCodingStandard\Sniffs\Functions\UselessParameterDefaultValueSniff
This sniff prohibits uses from the same namespace.
Insight Class: SlevomatCodingStandard\Sniffs\Namespaces\UseFromSameNamespaceSniff
This sniff looks for use alias that is the same as the unqualified name.
Insight Class: SlevomatCodingStandard\Sniffs\Namespaces\UselessAliasSniff
This sniff disallows using loose == and != comparison operators.
Use === and !== instead, they are much more secure and predictable.
Insight Class: SlevomatCodingStandard\Sniffs\Operators\DisallowEqualOperatorsSniff
This sniff requires using combined assignment operators, eg +=, .= etc.
Insight Class: SlevomatCodingStandard\Sniffs\Operators\RequireCombinedAssignmentOperatorSniff
This sniff reports ++ and -- operators not used standalone.
Insight Class: SlevomatCodingStandard\Sniffs\Operators\RequireOnlyStandaloneIncrementAndDecrementOperatorsSniff
PHP optimizes some internal functions into special opcodes on VM level. Such optimization results in much faster execution compared to calling standard function. This only works when these functions are not invoked with argument unpacking (...).
The list of these functions varies across PHP versions, but is the same as functions that must be referenced by their global name (either by \ prefix or using use function), not a fallback name inside namespaced code.
Insight Class: SlevomatCodingStandard\Sniffs\PHP\OptimizedFunctionsWithoutUnpackingSniff
This sniff enforces using shorthand cast operators, forbids use of unset and binary cast operators.
Insight Class: SlevomatCodingStandard\Sniffs\PHP\TypeCastSniff
This sniff looks for useless parentheses.
Insight Class: SlevomatCodingStandard\Sniffs\PHP\UselessParenthesesSniff
This sniff looks for useless semicolons.
Insight Class: SlevomatCodingStandard\Sniffs\PHP\UselessSemicolonSniff
This sniff enforces having declare(strict_types = 1) at the top of each PHP file.
Insight Class: SlevomatCodingStandard\Sniffs\TypeHints\DeclareStrictTypesSniff
This sniff looks for duplicate assignments to a variable.
Insight Class: SlevomatCodingStandard\Sniffs\Variables\DuplicateAssignmentToVariableSniff
This sniff checks whether the nullability ? symbol is present before each nullable and optional parameter (which are marked as = null)
Insight Class: SlevomatCodingStandard\Sniffs\TypeHints\NullableTypeForNullDefaultValueSniff
function foo(
int $foo = null, // ? missing
?int $bar = null // correct
) {
// ...
}
This fixer adds a void return type to functions with missing or empty return statements, but priority is given to [@return](https://github.com/return) annotations.
Insight Class: PhpCsFixer\Fixer\FunctionNotation\VoidReturnFixer
This sniff warns about FIXME comments.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\Commenting\FixmeSniff
This sniff warns about TODO comments.
Insight Class: PHP_CodeSniffer\Standards\Generic\Sniffs\Commenting\TodoSniff
This sniff reports forbidden comments in descriptions. Nothing is forbidden by default, the configuration is completely up to the user. It's recommended to forbid generated or inappropriate messages like:
Constructor.Created by PhpStorm.Insight Class: SlevomatCodingStandard\Sniffs\Commenting\ForbiddenCommentsSniff
SlevomatCodingStandard\Sniffs\Commenting\ForbiddenCommentsSniff::class => [
'forbiddenCommentPatterns' => []
]
This sniff reports invalid inline phpDocs with [@var](https://github.com/var).
Insight Class: SlevomatCodingStandard\Sniffs\Commenting\InlineDocCommentDeclarationSniff
This sniff disallows useless doc comments. If the native method declaration contains everything and the phpDoc does not add anything useful, it's reported as useless.
Some type hints can be enforced to be specified with a contained type, with traversableTypeHints. See the official explanation
Insight Class: SlevomatCodingStandard\Sniffs\Commenting\UselessFunctionDocCommentSniff
SlevomatCodingStandard\Sniffs\Commenting\UselessFunctionDocCommentSniff::class => [
'traversableTypeHints' => []
]
This sniff disallows usage of array type hint syntax (eg. int[], bool[][]) in phpDocs in favour of generic type hint syntax (eg. array<int>, array<array<bool>>).
Insight Class: SlevomatCodingStandard\Sniffs\TypeHints\DisallowArrayTypeHintSyntaxSniff
This sniff disallows usage of the "mixed" type hint in phpDocs.
Insight Class: SlevomatCodingStandard\Sniffs\TypeHints\DisallowMixedTypeHintSniff
This sniff enforces using shorthand scalar type hint variants in phpDocs: int instead of integer and bool instead of boolean.
This is for consistency with native scalar type hints which also allow shorthand variants only.
Insight Class: SlevomatCodingStandard\Sniffs\TypeHints\LongTypeHintsSniff
This sniff enforces null type hint on last position in annotations.
Insight Class: SlevomatCodingStandard\Sniffs\TypeHints\NullTypeHintOnLastPositionSniff
See the official explanation
Insight Class: SlevomatCodingStandard\Sniffs\TypeHints\TypeHintDeclarationSniff
See the official explanation
Insight Class: SlevomatCodingStandard\Sniffs\TypeHints\ParameterTypeHintSniff
See the official explanation
Insight Class: SlevomatCodingStandard\Sniffs\TypeHints\PropertyTypeHintSniff
See the official explanation
Insight Class: SlevomatCodingStandard\Sniffs\TypeHints\ReturnTypeHintSniff
This sniff reports useless [@var](https://github.com/var) annotation (or whole documentation comment) for constants because the type of the constant is always clear.
Insight Class: SlevomatCodingStandard\Sniffs\TypeHints\UselessConstantTypeHintSniff
This sniff reports documenta...
How can I help you explore Laravel packages today?