Code Inspections in PHP
This topic lists all PhpStorm code inspections available in PHP.
You can toggle specific inspections or change their severity level on the Editor | Inspections page of the IDE settings Ctrl+Alt+S.
Control flow
Inspection | Description | Default Severity |
---|---|---|
Reports the keys and values in | | |
Reports the | | |
Reports the functions with the | | |
Reports the 'switch' statements with duplicated common parts. | | |
Reports the array write access expressions that are not used in code afterwards. The most common source of such problems is modifying an array passed via a parameter: if an array is passed by value, the change will not be visible outside the function. | | |
Reports the conditions that are already covered by earlier conditions and thus have no effect as well as the variables that are always true (or always false) when reached. | | |
Condition inside logical expression checked by subsequent condition | Reports the conditions inside logical binary expressions that are are covered by subsequent conditions and are therefore redundant. | |
Reports the variables in | | |
Reports the loop statements whose bodies will execute at most once. The inspection does not reportforeach loops with a key or value used inside the loop body. Commonly, such loops are intended to perform an action only on their first iteration (for example, get the first element of an array). | | |
Reports the | | |
Reports the attempts to read from an uninitialized typed property. Such attempts will result in
| | |
Reports the | | |
Reports the statements that cannot be reached. | | |
Reports the write access expressions on variables that are still referencing the array value previously used in a unset . See foreach (php.net) and unset (php.net) for details. | |
Composer
Inspection | Description | Default Severity |
---|---|---|
Reports duplicate package entries in the | | |
Reports the usages of classes, functions, and constants from the PHP extensions not specified in composer.json. If an extension is listed in the | | |
Reports the Composer packages that are required in composer.json but are not installed. | | |
Highlights the quality tools' entries in composer.json in case the corresponding code inspections are disabled. | | |
Reports unresolved file references in composer.json. | |
Replaceable assignments
Inspection | Description | Default Severity |
---|---|---|
Reports the assignments that can be replaced with incrementing ( | | |
Reports the assignments that can be replaced with combined operator assignments (for example, | |
Psalm
Inspection | Description | Default Severity |
---|---|---|
Reports the parameters in function calls whose types are not compatible with the ones defined via | |
PHPUnit
Inspection | Description | Default Severity |
---|---|---|
Reports the PHPUnit | | |
Reports the | | |
Reports the | | |
Reports the references to functions/methods in the | | |
Reports deprecated usages of the $needle and optional boolean $ignoreCase parameters of the assertContains and assertNotContains functions are deprecated and will be removed in PHPUnit 9. See Usage of the assertEquals function (phpunit.readthedocs.io) for details. | | |
Reports deprecated usages of the $delta , $maxDepth , $canonicalize , and $ignoreCase parameters of the assertEquals and assertNotEquals functions are deprecated and will be removed in PHPUnit 9. See Usage of the assertEquals function (phpunit.readthedocs.io) for details. | | |
Reports the deprecated usages of the $canonicalize and $ignoreCase parameters of the assertFileEquals and assertFileNotEquals functions are deprecated and will be removed in PHPUnit 9. See Usage of the assertFileEquals function (phpunit.readthedocs.io) or Usage of the assertFileEquals function (phpunit.readthedocs.io) for details. | | |
Reports the | | |
Reports the usages of the following deprecated PHPUnit doc tags:
| | |
Reports deprecated usages of expectException() method with \PHPUnit\Framework\Error\Deprecated , \PHPUnit\Framework\Error\Error , \PHPUnit\Framework\Error\Notice , and \PHPUnit\Framework\Error\Warning is deprecated and will be removed in PHPUnit 10. Instead, the expectDeprecation() , expectError() , expectNotice() , and expectWarning() methods should be used. See Testing PHP Errors, Warnings, and Notices (phpunit.readthedocs.io) for details. | | |
Method 'assertArrayHasKey/assertArrayNotHasKey' can be used instead | Reports the | |
Reports the calls to the PHPUnit assertion methods that are removed in PHPUnit 10. | | |
Reports the calls to PHPUnit equality assertion methods (such as | | |
Reports the test classes and methods, for which no corresponding production classes or methods were found. | | |
Reports the references to functions/methods in the dataProvider , PHPUnit doesn't take use statements into account. | | |
Usage 'assertCount/assertSameSize' methods instead of assertEquals | Reports alternative usage of the | |
PSR-12
Inspection | Description | Default Severity |
---|---|---|
Reports the usages of compound namespaces whose depth exceeds two levels. According to PSR-12, compound namespaces with a depth of more than two MUST NOT be used. See PSR-12: Extended Coding Style (php-fig.org) for details. | ||
Reports the usages of the elseif SHOULD be used instead of else if so that all control keywords look like single words. See PSR-12: Extended Coding Style (php-fig.org) for details. | ||
Reports missing parameter lists in a classes' instantiations. According to the PSR-12 specification, when instantiating a new class, parentheses MUST always be present even when there are no arguments passed to the constructor. See PSR-12: Extended Coding Style (php-fig.org) for details. | ||
Reports the properties, constants, and methods that are declared without visibility definition. According to PSR-12, visibility MUST be defined on:
| ||
Reports the cases of several traits being imported via a single use import statement. See PSR-12: Extended Coding Style (php-fig.org) for details. | ||
Reports visibility modifiers that are specified in the incorrect order. According to PSR-12, the correct order is as follows:
| ||
Reports usages of long form type keywords. According to PSR-12, short form of type keywords MUST be used, that isbool instead of boolean , int instead of integer , and so on. See Keywords and Types (php-fig.org) for details. | ||
Reports the usages of the var keyword MUST NOT be used to declare a property. See PSR-12: Extended Coding Style (php-fig.org) for details. |
Attributes
Inspection | Description | Default Severity |
---|---|---|
Reports the methods and functions that are returning arrays with known non-trivial keys. Suggests specifying the shape of the returned array via the | | |
Reports the functions that are non-trivially pure. Such functions have other functions calls in their body, but all such calls do not produce any side effects. | | |
Reports the array keys that do not match the keys specified via the | | |
Reports the methods' and parameters' attributes that can be propagated to overriding methods/parameters. See Attributes (php.net) for details. | | |
Reports the attributes that are resolved to a class not annotated with | | |
Reports line comments starting with | | |
Reports the values in assignment and comparison expressions that should be replaced with one of the expected values (that is, the values specified via the | | |
Highlights write access references to properties, for which the write access scope declared via | | |
Reports function without | | |
Reports the attributes that do not have the appropriate | | |
Reports repeated attributes without the | | |
Reports the | | |
Reports empty arguments lists in attributes. See Attributes (php.net) for details. | |
Code smell
Inspection | Description | Default Severity |
---|---|---|
Reports the usages of | | |
Reports the | | |
Reports the | | |
Reports the
| | |
Reports the | | |
Reports the | | |
Reports the | | |
'match' expression has only default arm and should be simplified | Reports the | |
Reports the | | |
Reports the | | |
Reports the static member access expressions used on traits. Such direct access is deprecated starting from PHP 8.1. Instead, static members should be accessed on the class that uses the trait. See Deprecations for PHP 8.1: Accessing static members on traits (php.net) for details. | | |
Reports arguments of 'instanceof' that are not objects or strings | | |
Reports the array access expressions inside | | |
Reports the | | |
Reports the iterated/accessed arrays that are known to be empty at the point of access. | | |
Reports array to string conversions, that is, the arrays that are provided in the contexts where a string is expected. Prior to PHP 8.0, this would lead to aE_NOTICE level error. In PHP 8.0, an E-WARNING is emitted. | | |
Reports local arrays that are only updated, but never queried. | | |
Reports the boolean expressions that contain the | | |
Reports the class constant references that target the constant from the parent class of the referenced class. | | |
Reports the | | |
Reports the conditions that perform manual min/max calculation instead of calling | | |
Reports the | | |
Reports | | |
Reports the | | |
Reports the | | |
Reports the | | |
Reports the binary expression operands that do not change the expression result (such as | | |
Reports inconsistencies in function/method exit points. The following types of inconsistencies are reported:
| | |
Reports the expressions that use the same operands, but should rather use different operands (for example, | | |
Reports the | | |
Reports the | | |
Checks that the methods don't override visibility. Overriding aprotected method with a public method in a child class makes this method accessible from everywhere. This violates the encapsulation principle and is considered bad practice. See Method Visibility (php.net) for details. | ||
Reports the private methods returning the values that are not used. | | |
Reports the modulo expressions | | |
Nested 'dirname()' call can be replaced with 'levels' parameter usage | Reports the nested | |
Reports nested | | |
Reports the parameters in private methods that have the same value across all method calls. | | |
Reports the function/method calls that take more parameters than specified in their declaration. | | |
Reports the private properties that are used only in a single method. Such properties can be replaced with local variables. | | |
Reports the private properties that are:
| | |
Redundant 'array_values' call on a value iterated in 'foreach' | Reports the | |
Reports the redundant | | |
Reports | | |
Reports redundant assignments to class properties that duplicate automatic assignments performed through promoted constructor parameters. See Constructor Property Promotion (php.net) for details. | | |
Reports the | | |
Reports the | | |
Reports the overriding methods that only consist of a single call to the parent method. | | |
Reports redundant arguments that match the corresponding default values for optional parameters. | | |
Reports the ternary expressions specified as | | |
Reports the | | |
Reports the function/method declarations with the number of parameters exceeding the specified limit. | ||
Reports unnecessary | | |
Reports the local variables that are used in exit statements, such as | | |
Reports the variables that are passed by reference to a function/method but are not modified in the function/method body. In such cases, the | | |
Reports unnecessary semicolons. | | |
Reports the usages of the spread operator ( | | |
Reports the usages of the silence operator ( | ||
Reports the trailing commas in parameters lists and closures'
| |
PHP strict standards
Inspection | Description | Default Severity |
---|---|---|
Declaration of overridden method should be compatible with parent class | Reports the overridden methods declarations that are not compatible with the parent class. The inspection is enabled only for the PHP language level lower than 8.0. | |
Reports the static methods that are declared as abstract. | |
Code style
Inspection | Description | Default Severity |
---|---|---|
'Closure::fromCallable()' can be converted to the first-class callable syntax | Reports the | |
Reports the | | |
Reports the | | |
Reports the | | |
Reports the | | |
Reports the conditions using | | |
Reports the match expressions use strict type comparison, while switch statements rely on loose comparison. As a result, the expression semantics may change after replacement. See match (php.net) and switch (php.net) for details. | | |
Reports the | | |
Reports 'mixed' return types that can be narrowed down to more concrete types. | | |
Reports the | | |
Reports the | | |
Reports 'switch' statements that could be replaced with 'match' expression | | |
Reports automatic conversions of | | |
Reports the usages of functions, methods, classes, and namespaces that do not match the case used in their declarations. | ||
Reports the classes with the filepath not following the PSR-0/PSR-4 project structure. You can configure the project vendor roots under Settings/Preferences | Directories. See PSR-0/PSR-4 standards (php-fig.org) for details. | | |
Reports the anonymous functions that can be transformed to short arrow functions. Support for short arrow functions is available since PHP 7.4. See PHP RFC: Arrow Functions 2.0 (php.net) for details. | | |
Reports the inline comments before arguments in function calls that only contain the name of the parameter and thus serve as hints. In PHP 8.0 and later, named arguments can be used instead. See Named arguments (php.net) for details. | | |
Reports the control structures (such as loops or conditionals) whose bodies are not enclosed in braces. See Control structures (php.net) for details. | | |
Reports dangerous array initializations (such as $arr already contains some value (for example, a string from a request variable), then this value will stay in place and [] may actually stand for string access operator. It is always preferable to initialize a variable by direct assignment. See Creating/modifying with square bracket syntax (php.net) for details. | | |
Reports the | | |
Reports the elements without a PHPDoc comment or with a PHPDoc comment only containing the | ||
Reports potentially ambiguous expressions and proposes enclosing them in clarifying parentheses. | | |
Reports the fully qualified class names that can be shortened by adding the | | |
Reports the implicit octal literals such as 0o/0O prefix are supported in PHP 8.1 and later. See Explicit octal integer literal notation (php.net) for details. | | |
Reports the | | |
Reports the | | |
Reports the | | |
Reports the methods that don't use any instance references and thus may be converted to static methods. | | |
Checks that the PHPDoc block contains the | | |
Reports non-fully typed elements without a PHPDoc comment or with a PHPDoc comment only containing the | ||
Reports multiple class declarations in a single file, which violates the PSR-0/PSR-4 standards. See PSR-0/PSR-4 standards (php-fig.org) for details. | | |
Reports named argument with order that does not match parameter order | | |
Reports the PHPDoc tags that have elements listed in non-canonical order. For example, for such tags as@property , @param , or @var , the inspection will report the usages of [name] ["Type"] instead of ["Type"] [name] . | ||
Reports the null-checking conditional expressions that can be safely replaced with the | | |
Reports old-style constructor declarations ( E_DEPRECATED error. If both a __construct() and a ClassName() method are defined, __construct() will be called. In namespaced classes, or any classes as of PHP 8.0, a ClassName() method never has any special meaning and will never be called as a constructor. As a result, the inspection does not report such cases if the PHP language level is set to 8.0 or later. See Constructors and destructors (php.net) for details. | | |
Reports the PHPDoc comments that contain at least one | | |
Reports PHP closing tag | | |
Reports short PHP opening tag | | |
Reports the control structures (such as loops or conditionals) whose bodies are enclosed in braces but only contain a single child statement. Using braces in such cases is not necessary. See Control structures (php.net) for details. | | |
Reports traditional array syntax ( | ||
Reports the class references that are resolved to traits but are specified outside | | |
Trait use rule resolved to method with different containing class | Reports the trait method | |
Reports the type cast operators used on the values that are already of the corresponding type. Such operators are redundant and can be safely removed. See Type juggling (php.net) for details. | | |
Reports the type casts that can be evaluated in place and suggests replacing them with actual computed values. See Type juggling (php.net) for details. | | |
Reports unnecessary | | |
Reports double-quoted string literals that do not contain string interpolation, escape sequences, or single quotes. | ||
Reports the usages of fully qualified class names, which can be shortened without adding the | | |
Reports the Foo\Bar as opposed to global names that do not, such as FooBar ), the leading backslash is unnecessary and not recommended, as import names must be fully qualified and are not processed relative to the current namespace. See Using namespaces: Aliasing/Importing (php.net) for details. | | |
Reports the expressions containing redundant parenthesis, which can be safely removed. | | |
Reports the usages of variable variables (dynamic variable names such as |
Probable bugs
Inspection | Description | Default Severity |
---|---|---|
Reports the assignments that are used in conditional expressions. | | |
Reports the arguments of enum's | | |
Reports the string concatenation expressions that are used together with | | |
Reports reassignments of constants. Since constants cannot be changed, such assignments will have no effect and will emit anE_NOTICE (in PHP 7.4 and earlier) or E_WARNING (in PHP 8.0 and later). | | |
Reports division by zero or modulo by zero. | | |
Reports duplicate bodies in | | |
Reports duplicate keys in array declarations. If multiple elements in the array declaration use the same key, only the last one will be used, and all others will be overwritten. | | |
Reports the | | |
Reports duplicate switch statement contains multiple duplicate case expressions, only the first one is executed. | | |
Reports duplicate characters provided in the | | |
Reports duplicate conditions in | | |
Reports the usages of empty index operator ( | | |
Reports the expressions that are calculated, but the calculation result is not used anywhere. Such errors can be caused, for example, by misspelling the= operator as == . | | |
Reports the variables that are used in a | | |
Reports the arguments of a format function (such as | | |
Reports the | | |
Reports invalid string offset usages that will result in a runtime error. The following usages are reported:
| | |
Reports unpacked function arguments and array elements whose type is neither Fatal error . | | |
Reports the variable assignments to new objects that are used only for writing the object's properties without observable side effects. | | |
Reports the attempts to convert the objects having no E_RECOVERABLE_ERROR level error. In PHP 7.4, a fatal non-recoverable ERROR is thrown. In PHP 8.0, the return value follows the standard PHP type semantics and will be coerced into a string if possible and if strict typing is disabled. If the Check __toString exists for each expression type option is enabled, the inspection will check all possible types of the expression and report if at least one of them doesn't contain the __toString method implementation. See __toString (php.net) for details. | | |
Reports the E_RECOVERABLE_ERROR level error. In PHP 7.4, a fatal non-recoverable ERROR is thrown. In PHP 8.0, the return value follows the standard PHP type semantics and will be coerced into a string if possible and if strict typing is disabled. See __toString (php.net) for details. | | |
Reports the case clause does not end with break or return , its execution can unintentionally fall through the next case. | | |
Reports the constructors that do not call their parent constructor. | | |
Reports the magic methods that do not call their parent magic method. | ||
Reports the methods that do not call their parent method. | ||
Reports the variables that are used as a key or value both by the inner and outer | | |
Reports the usages of the comparison operator (
| | |
Reports the optional parameters that appear before the required parameters in a function/method declaration. See Default argument values (php.net) for details. | | |
Reports the arguments in a function/method call that cannot be passed by reference. Only variables and references returned from functions can be passed by reference. See Passing by Reference (php.net) for details. | | |
Reports the assignment statements, in which both sides are equal. Such assignments have no effect and can be removed. | | |
Reports the | | |
Reports the statements that have empty bodies. While occasionally useful, such statements are often the result of typos and may cause confusion. | | |
Reports the | | |
Reports the assignments and function calls where the name of the variable or parameter probably doesn't match the name of the assigned or passed value. The following sets of names are supported:
| | |
Reports the | | |
Reports the | | |
Reports the conditions in === ) to check the types in match conditions against the match argument type, regardless of the strict_types directive. Since no type coercion occurs, some conditions may be non-matched due to non-matching types. See Match expression (php.net) for details. | | |
Reports the branches in | | |
Reports the usages of a void functions do not have a return value, such usages are most likely a programming mistake. | | |
Reports the attempts to concatenate strings by using the | |
Regular expressions
Inspection | Description | Default Severity |
---|---|---|
Reports the regular expression patterns that comprise repeating characters ending with an asterisk | | |
Reports the elements in regular expression character classes that are already covered by another element in the same class. Such elements are redundant and can be safely removed. | | |
Reports the alphabetic ranges or characters in regular expression character classes that only adjust the already existing ranges. Such elements can be merged with the adjusted ranges. | |
Naming conventions
Inspection | Description | Default Severity |
---|---|---|
Reports the classes' names that are either too short, too long, or do not follow the specified regular expression pattern. Some coding styles have a special naming convention for classes. Use the inspection options to specify minimum/maximum length and the regular expression expected for classes' names. To ignore the names' length, specify 0. To learn more about regular expressions, refer to the Quick Start guide (regular-expressions.info). | ||
Reports the constants' names that are either too short, too long, or do not follow the specified regular expression pattern. Some coding styles have a special naming convention for constants. Use the inspection options to specify minimum/maximum length and the regular expression expected for constants' names. To ignore the names' length, specify 0. To learn more about regular expressions, refer to the Quick Start guide (regular-expressions.info). | ||
Reports the functions' names that are either too short, too long, or do not follow the specified regular expression pattern. Some coding styles have a special naming convention for functions. Use the inspection options to specify minimum/maximum length and the regular expression expected for functions' names. To ignore the names' length, specify 0. To learn more about regular expressions, refer to the Quick Start guide (regular-expressions.info). | ||
Reports the methods' names that are either too short, too long, or do not follow the specified regular expression pattern. Some coding styles have a special naming convention for methods. Use the inspection options to specify minimum/maximum length and the regular expression expected for methods' names. To ignore the names' length, specify 0. To learn more about regular expressions, refer to the Quick Start guide (regular-expressions.info). | ||
Reports the properties' names that are either too short, too long, or do not follow the specified regular expression pattern. Some coding styles have a special naming convention for properties. Use the inspection options to specify minimum/maximum length and the regular expression expected for properties' names. To ignore the names' length, specify 0. To learn more about regular expressions, refer to the Quick Start guide (regular-expressions.info). | ||
Reports the variables' names that are either too short, too long, or do not follow the specified regular expression pattern. Some coding styles have a special naming convention for variables. Use the inspection options to specify minimum/maximum length and the regular expression expected for variables' names. To ignore the names' length, specify 0. To learn more about regular expressions, refer to the Quick Start guide (regular-expressions.info). |
General
Inspection | Description | Default Severity |
---|---|---|
Reports arguments with name identifiers. | | |
Reports arguments without name identifiers. | | |
Reports the write expressions on array indexes which are immediately overwritten before being accessed. | | |
Reports the classes that are implementing the Traversable interface is an internal engine interface; it cannot be implemented in PHP scripts. See The Traversable interface (php.net) for details. | | |
Checks the classes' hierarchy: abstract methods implementation, the compatibility of implementing/overriding methods with their declarations in parent classes, and properties' types redeclarations. All reported violations result in PHP fatal errors. It is not recommended disabling or suppressing this inspection. | | |
Reports the usages of curly brace syntax for accessing array elements and string offsets. | | |
Reports the usages of deprecated entities. In most cases, such usages should be removed or replaced with other constructs. | | |
Reports the usages of deprecated Serializable , and do not implement __serialize() and __unserialize() will throw a deprecation warning. See Phasing out Serializable (php.net) for details. | | |
Reports deprecated usage of the implode and join with an array as the first argument and a string as the second argument is deprecated. See Deprecations for PHP 7.4 (php.net) for details. | | |
Reports the calls to Standard PHP Library functions that are deprecated starting from PHP 8.1. The following calls are reported:
| | |
Reports deprecated cast expressions:
| | |
Reports the usages of classes, functions, and constants, for which the stubs for the corresponding PHP interpreter extensions are disabled. You can configure the set of stubs under Settings/Preferences | PHP | PHP Runtime. See PhpStorm stubs (blog.jetbrains.com/phpstorm) for details. | | |
Reports static calls to dynamic class methods. For classes having the magic method__callStatic , a separate inspection severity and highlighting level can be set. | | |
Reports the usages of entities which were introduced in PHP version later than configured one. | | |
Reports the class alias declarations that are ignored by the IDE because the actual class declaration with the same FQN exists. The inspection is intended to clarify the IDE’s behavior in the cases when both the class and the class alias declarations are present. When several declarations with the same FQN exist, the IDE usually fails to choose a single one between them. This leads to incorrect code completion, erroneous type inference, and so on. Since the class declaration prevails over the class alias declaration, the latter becomes redundant and therefore ignored by the IDE. Note that ignoring class alias declarations does not affect the behavior of the PHP interpreter. | | |
Reports incompatible magic methods signatures. See RFC: Ensure correct signatures of magic methods (php.net) for details. | | |
Reports the magic methods that are not declared as public or are declared as static. | | |
Reports the language features used in source code that are not supported for the selected language level. For example, union types can be used only in PHP 8.0 and later. | | |
Method declaration in parent class is incompatible with implemented interface | Reports the methods declarations in parent classes that are incompatible with implemented interfaces. | |
Reports the named arguments in method calls that might be unresolved depending on a specific class instance within the hierarchy. | | |
Reports nested ternary expressions, which are deprecated starting from PHP 7.4. | | |
Reports the methods' parameters whose names differ from the same parameters defined in parent methods. Starting with PHP 8.0, such code can cause runtime errors. | | |
Reports properties declared through promoted constructor parameters. Using promoted properties is only possible since PHP 8.0. In earlier PHP versions, it leads to a parse error. See Constructor Property Promotion (php.net) for details. | | |
Reports the properties that can be replaced with promoted versions. See Constructor Property Promotion (php.net) for details. | | |
Reports the write expressions on properties which are immediately overwritten before being accessed. | | |
Reports reassignments of | | |
Reports dynamic calls to static class methods. If the target has the magic method__call , a separate inspection severity and highlighting level can be set. | ||
Reports non-resolved | | |
Reports the usages of the entities that are marked as | | |
Write access to 'readonly' property outside of declaration scope | Reports the write accesses to | |
Error handling
Inspection | Description | Default Severity |
---|---|---|
Reports the | | |
Reports the exceptions that are neither enclosed in a | | |
Reports the exceptions that are already caught by a preceding exception and the exceptions that are caught twice. Thecatch clauses must be ordered from more specific to more generic ones. Otherwise, some exceptions may not be caught by the most specific handler. See Exceptions (php.net) for details. | |
Type compatibility
Inspection | Description | Default Severity |
---|---|---|
Reports the variables that are initialised via passing them by reference to a parameter incompatible with | | |
Reports arithmetic and bitwise expressions with unsupported operands. Starting with PHP 8.0, using the arithmetic and bitwise operators+ , - , * , / , ** , % , << , >> , & , | , ^ , ~ , ++ , -- when one of the operands is an array, resource, or non-overloaded object will result in a TypeError . The only exception is the array + array merge operation, which remains supported. See PHP's internal test source for the complete list of operations. | | |
Reports the array offset access expressions that are used on illegal types. | | |
Reports the array keys that are of illegal type, such as objects or arrays. See Arrays (php.net) for details. | | |
Reports the usages of non- | | |
Reports the | | |
Reports the | | |
Reports the parameters that have no type declaration specified. | | |
Reports the properties that have no type declaration. | | |
Reports the functions that have no return type declaration specified. | | |
Detects the missing | ||
Reports the parameters passed to a function call, whose types do not match the ones specified in the function definition via type declaration or the PHPDoc | | |
Reports the intersection type declarations that contain redundant types, for example, an intersection type that contains both the parent class and its subclass. See PHP RFC: Pure intersection types (php.net) for details. | | |
Reports violations of the strict type checking rules. In strict mode, only the variables exactly matching the declaration types are accepted. Strict type-checking mode can be enabled:
| | |
Reports union type declarations that contain redundant types, for example, a union type that contains both the class alias and the original class. See Union Types RFC: Duplicate and redundant types (php.net) for details. | | |
Reports type violations in properties assignments. | |
Undefined symbols
Inspection | Description | Default Severity |
---|---|---|
Reports the references to classes that have multiple declarations in project files. Use the options below to customize the inspection:
| | |
Reports polymorphic code usages. Such usages are ambiguous and can be potentially inoperable depending on the class instance passed as the argument. | | |
Reports the functions, methods, properties, or classes that are referenced from a callback but are not found. Use the options below to customize the inspection:
| ||
Reports the references to classes whose declarations are not found in the project files, configured include paths, or among the PHP predefined classes. Use the options below to customize the inspection:
| | |
Reports the references to class constants that are not declared. | | |
Reports the references to constants that are not found in the project files, configured include paths, or among the PHP predefined constants. | | |
Reports the references to functions that are not defined in the project files, configured include paths, or among the PHP predefined functions. | | |
Reports the goto label must reside in the same file and context: you cannot jump into or out of a function or method, and cannot jump into a loop or switch structure. See goto (php.net) for details. | | |
Reports the references to class methods that are not defined. | | |
Reports the references to a namespace that is not found. | | |
Reports the references to class properties that are not declared. The inspection skips the objects of thestdClass or derived types. | | |
Produces two types of warnings:
| |
Quality tools
Inspection | Description | Default Severity |
---|---|---|
Reports coding style problems detected by PHP CS Fixer. The inspection requires PHP CS Fixer to be properly installed and set up in the IDE under Settings/Preferences | PHP | Quality Tools | PHP CS Fixer. To learn more about installing PHP CS Fixer, see PHP-CS-Fixer installation (GitHub). | ||
Reports coding style problems detected by PHP Mess Detector. The inspection requires PHP Mess Detector to be properly installed and set up in the IDE under Settings/Preferences | PHP | Quality Tools | Mess Detector. To learn more about installing PHP Mess Detector, see PHP Mess Detector installation (phpmd.org) for details. You can use a predefined set of rules or add your own by specifying valid ruleset.xml files. See the rules index (phpmd.org) and How to create a custom rule set (phpmd.org) for details. | ||
Runs PHPStan to find code problems. The inspection requires PHPStan to be properly installed and set up in the IDE under Settings/Preferences | PHP | Quality Tools | PHPStan. To learn more about installing PHPStan, see: https://phpstan.org/user-guide/getting-started | ||
Reports coding style problems detected by PHP_CodeSniffer. The inspection requires PHP_CodeSniffer to be properly installed and set up in the IDE under Settings/Preferences | PHP | Quality Tools | PHP_CodeSniffer. To learn more about installing PHP_CodeSniffer, see PHP_CodeSniffer installation (GitHub). | ||
Runs Psalm to find code problems. The inspection requires Psalm to be properly installed and set up in the IDE under Settings/Preferences | PHP | Quality Tools | Psalm. To learn more about installing Psalm, see: https://psalm.dev/docs/running_psalm/installation/ |
Unused symbols
Inspection | Description | Default Severity |
---|---|---|
Reports the fields with default initializers that are always overwritten in the class constructor. | | |
Reports the classes, methods, functions, constants, or properties that are not used or not reachable from entry points. It also reports all method implementations/overriders. Some unused members might not be reported in the code editor on the fly. Due to performance reasons, a non-private member is checked only when its name rarely occurs in the project. To see all results, run the inspection in batch mode by using Code | Inspect Code... or Code | Run Inspection by Name.... | | |
Reports the imports that are never used. | | |
Reports the variables that are considered unused in the following cases:
| | |
Reports the parameters that are considered unused in the following cases:
| | |
Reports the private methods that are never used. | | |
Reports the private properties that are never used. | |
Refactoring opportunities
Inspection | Description | Default Severity |
---|---|---|
Reports the classes that have too many properties or methods. | ||
Reports the classes that are too complex. Class complexity is evaluated based on three metrics:
| ||
Reports the functions or methods that are too complex. Complexity is evaluated based on four metrics:
| ||
Reports the methods that have high cyclomatic complexity and can probably be simplified. See Cyclomatic complexity (wikipedia.org) for details. | ||
Reports the methods with high Halstead Complexity metric. See Halstead measure (wikipedia.org) for details. | ||
Reports the classes that have high Lack of Cohesion metric value, which represents the degree of cohesiveness of a class. It uses class dependency graph components for class cohesiveness measure (M. Hitz and B. Montazeri definition of LCOM metric) | ||
Reports the class methods and properties that should be pulled up to the parent class or interface. | ||
Reports the "Feature Envy" code smell. Feature envy is defined as occurring when a method calls methods on another class more times than on the source class. It often indicates that the intended functionality is located in the wrong class. Calls to library classes, parent classes, and contained or containing classes are not counted by this inspection. |
PHPDoc
Inspection | Description | Default Severity |
---|---|---|
Reports inappropriate
| | |
Reports the parameters' names and types in a PHPDoc comment that do not match the ones in the function/method declaration. | | |
Reports the | | |
Reports the | | |
Reports the PHPDoc comments that contain only the information already provided in declarations. | | |
Return type in PHPDoc comment does not match the actual return type | Reports the return types in PHPDoc comments that do not match the actual return type of a function. | |
Reports duplicate types in PHPDoc comments. | | |
Reports the properties' types in PHPDoc | |