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 CtrlAlt0S.
Inspection | Description | Default Severity |
---|---|---|
Reports the keys and values in | | |
Reports the | | |
Reports the functions with the See noreturn type (php.net) for details. | | |
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 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 report | | |
Reports the | | |
Reports the attempts to read from an uninitialized typed property. Such attempts will result in Typed properties should be initialized in any of the following ways:
See Uninitialized and Unset Properties (php.net) for details. | | |
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 It is recommended to destroy such references by using See foreach (php.net) and unset (php.net) for details. | |
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. | |
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, | |
Inspection | Description | Default Severity |
---|---|---|
Reports the parameters in function calls whose types are not compatible with the ones defined via | |
Inspection | Description | Default Severity |
---|---|---|
Reports the PHPUnit | | |
Reports the See assertEmpty (phpunit.readthedocs.io) for details. | | |
Reports the | | |
Reports the references to functions/methods in the | | |
Reports the deprecated The string See Usage of the assertEquals function (phpunit.readthedocs.io) for details. | | |
Reports deprecated usages of the The optional See Usage of the assertEquals function (phpunit.readthedocs.io) for details. | | |
Reports the deprecated usages of the The optional 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 Support for using the Instead, the See Testing PHP Errors, Warnings, and Notices (phpunit.readthedocs.io) for details. | | |
Reports the methods and classes that are incorrectly mocked in PHPUnit tests. The following entities are reported:
| | |
Method 'assertArrayHasKey/assertArrayNotHasKey' can be used instead | Reports the See assertArrayHasKey (phpunit.readthedocs.io) for details. | |
Reports the calls to the PHPUnit assertion methods that are removed in PHPUnit 10. | | |
Reports the calls to PHPUnit equality assertion methods (such as See assertEquals for details. | | |
Reports the test classes and methods, for which no corresponding production classes or methods were found. | | |
Reports the references to functions/methods in the Note that when resolving | | |
Usage 'assertCount/assertSameSize' methods instead of assertEquals | Reports alternative usage of the See Usage of the assertCount for details. See Usage of the assertSameSize for details. | |
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 According to PSR-12, the keyword 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:
See PSR-12: Extended Coding Style (php-fig.org) for details. | ||
Reports the cases of several traits being imported via a single According to PSR-12, each individual trait imported into a class MUST be included one-per-line, and each inclusion MUST have its own 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:
See PSR-12: Extended Coding Style (php-fig.org) for details. | ||
Reports usages of long form type keywords. According to PSR-12, short form of type keywords MUST be used, that is See Keywords and Types (php-fig.org) for details. | ||
Reports the usages of the According to PSR-12, the See PSR-12: Extended Coding Style (php-fig.org) for details. |
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 See Attributes (php.net) for details. | | |
Reports line comments starting with See Attributes (php.net) for details. | | |
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 See Attributes (php.net) for details. | | |
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 See Attributes (php.net) for details. | | |
Reports repeated attributes without the See Attributes (php.net) for details. | | |
Reports the | | |
Reports empty arguments lists in attributes. See Attributes (php.net) for details. | |
Inspection | Description | Default Severity |
---|---|---|
Reports the usages of | | |
Reports the See array_push (php.net) for details. | | |
Reports the | | |
Reports the
See continue (php.net), break (php.net), and switch (php.net) for details. | | |
Reports the | | |
Reports the | | |
Reports the See in_array (php.net) for details. | | |
'match' expression has only default arm and should be simplified | Reports the See Match expression (php.net) for details. | |
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 See reset (php.net) for details. | | |
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 a | | |
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 duplicate operands in binary expressions ( | | |
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:
Technically these are not errors, but practically they usually indicate a programming mistake. | | |
Reports the expressions that use the same operands, but should rather use different operands (for example, | | |
Reports the See implode (php.net) for details. | | |
Reports the | | |
Checks that the methods don't override visibility. Overriding a 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 boolean expressions inside | | |
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 See continue (php.net) and break (php.net) for details. | | |
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 See Passing by Reference (php.net) for details. | | |
Reports unnecessary semicolons. | | |
Reports the usages of the spread operator ( | | |
Reports the usages of the silence operator ( See Error Control Operators (php.net) for details. | ||
Reports the trailing commas in parameters lists and closures'
| | |
Reports the | |
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. | |
Inspection | Description | Default Severity |
---|---|---|
'Closure::fromCallable()' can be converted to the first-class callable syntax | Reports the See First-class callable syntax (php.net) for details. | |
Reports the | | |
Reports the | | |
Reports the | | |
Reports the See Allow ::class on objects (php.net) for details. | | |
Reports the | | |
'instanceof' checks in 'catch' block can be replaced with specific catches | Reports the | |
Reports the conditions using See Null coalesce operator (php.net) for details. | | |
Reports the Note that See match (php.net) and switch (php.net) for details. | | |
Reports the See Match expression (php.net) for details. | | |
Reports 'mixed' return types that can be narrowed down to more concrete types. | | |
Reports the | | |
Reports the See Power operator (php.net) for details. | | |
Reports the See str_contains (php.net) and str_starts_with and str_ends_with functions (php.net) for details. | | |
Reports 'switch' statements that could be replaced with 'match' expression | | |
Reports automatic conversions of See Deprecate autovivification on false for details. | | |
Reports the usages of functions, methods, classes, and namespaces that do not match the case used in their declarations. | ||
Reports the non- See Final class constants (php.net) for details. | | |
Reports the classes with the filepath not following the PSR-0/PSR-4 project structure. You can configure the project vendor roots under Settings | 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 This practice is discouraged because if 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 You can use Missing PHPDoc Comment inspection to report only non-fully typed elements. | ||
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 Explicit octal literals using the 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. | | |
Reports missing PHPDoc The exception classes added to the Unchecked Exceptions list under Settings | PHP | Analysis are excluded from the inspection scope. | | |
Reports non-fully typed elements without a PHPDoc comment or with a PHPDoc comment only containing the You can use the Enforce PHPDoc Comment inspection to report fully typed elements. | ||
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 | ||
Reports the null-checking conditional expressions that can be safely replaced with the | | |
Reports old-style constructor declarations ( Prior to PHP 8.0, old-style constructor syntax used in the classes in the global namespace is treated as deprecated and will result in an In namespaced classes, or any classes as of PHP 8.0, a See Constructors and destructors (php.net) for details. | | |
Reports the PHPDoc comments that contain at least one | | |
Reports PHP closing tag | | |
Reports short PHP | | |
Reports short PHP opening tag See PHP tags (php.net) for details. | | |
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 See Traits (php.net) for details. | | |
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 See Variable parsing (php.net) for details. | | |
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 For namespaced names (fully qualified namespace names containing a namespace separator, such as 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 |
Inspection | Description | Default Severity |
---|---|---|
Reports the assignments that are used in conditional expressions. | | |
Reports the arguments of enum's See Enumerations (php.net) for details. | | |
Reports the string concatenation expressions that are used together with See Concatenation precedence (php.net) for details. | | |
Reports reassignments of constants. Since constants cannot be changed, such assignments will have no effect and will emit an | | |
Reports division by zero or modulo by zero. | | |
Reports duplicate bodies in See Match expression (php.net) for details. | | |
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 If a | | |
Reports duplicate characters provided in the | | |
Reports duplicate conditions in See Match expression (php.net) for details. | | |
Reports the usages of empty index operator ( Starting from PHP 7.1, applying the empty index operator on a string throws a fatal error. See Creating/modifying with square bracket syntax (php.net) for details. | | |
Reports the expressions that are calculated, but the calculation result is not used anywhere. Such errors can be caused, for example, by misspelling the | | |
Reports the variables that are used in a Commonly, this is the result of a typing error. | | |
Reports the arguments of a format function (such as See printf (php.net) and sprintf (php.net) for details. | | |
Reports the See goto (php.net) for details. | | |
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 Starting with PHP 8.0, such usages will result in | | |
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 Prior to PHP 7.4, this would lead to a fatal 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 See __toString (php.net) for details. | | |
Reports the Prior to PHP 7.4, this would lead to a fatal See __toString (php.net) for details. | | |
Reports the | | |
Reports the If a | | |
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 ( Object variables are compared as follows:
See Comparing Objects (php.net) for details. | | |
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. | | |
Private method may be inaccessible during late static binding call | Reports the late static binding method calls (that is, performed via See Late Static Bindings (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 See PHP type comparison tables (php.net) for details. | | |
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 See Using namespaces: Aliasing/Importing (php.net) for details. | | |
Reports the conditions in Similarly to PHP Engine behavior, the inspection uses strict comparison ( See Match expression (php.net) for details. | | |
Reports the branches in See Enumerations (php.net) for details. | | |
Reports the usages of a Since | | |
Reports the attempts to concatenate strings by using the | |
Inspection | Description | Default Severity |
---|---|---|
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. | | |
Reports the | | |
Reports the usages of the | |
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. For more information 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. For more information 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. For more information 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. For more information 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. For more information 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. For more information about regular expressions, refer to the Quick Start guide (regular-expressions.info). |
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 The | | |
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 Starting from PHP 8.1, classes that are non-abstract, implement See Phasing out Serializable (php.net) for details. | | |
Reports the
See __autoload (php.net) for details. | | |
Reports the
See assert (php.net) for details. | | |
Reports deprecated usage of the Starting from PHP 7.4, using 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:
See PHP RFC: Deprecations for PHP 8.1 for details. | | |
Reports deprecated cast expressions:
See Deprecated features in PHP 7.2.x (php.net) and Deprecations for PHP 7.4 (php.net) for details. | | |
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 | 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 | | |
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. | | |
Reports method reference chains that are too long for IDE to analyze. | | |
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 private promoted properties that are never written to. In PHP 8.1 and later, such properties can be declared See Readonly properties (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 See Readonly properties (php.net) for details. | | |
Reports dynamic calls to static class methods. If the target has the magic method | ||
Reports non-resolved | | |
Reports the usages of the entities that are marked as In most cases, the reported usages should be removed or replaced with other constructs. | | |
Write access to 'readonly' property outside of declaration scope | Reports the write accesses to See Readonly properties (php.net) for details. | |
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. The See Exceptions (php.net) for details. | |
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 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- Starting from PHP 5.4, string offsets have to be either integers or integer-like strings. Since it's considered bad practice to use strings as a string offset, the inspection reports them, as well. See String access and modification by character (php.net) for details. | | |
Reports the | | |
Reports the See foreach (php.net) for details. | | |
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 See Strict typing (php.net) to learn more about why you may need use this directive. | ||
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 See Type declarations (php.net) and @param (phpdoc.org) for details. | | |
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:
See Strict typing (php.net) for details. | | |
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. | |
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 The target 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 the | | |
Produces two types of warnings:
Use the options below to customize the inspection:
| |
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 | PHP | Quality Tools | PHP CS Fixer. For more information 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 | PHP | Quality Tools | Mess Detector. For more information 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 | PHP | Quality Tools | PHPStan. For more information 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 | PHP | Quality Tools | PHP_CodeSniffer. For more information 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 | PHP | Quality Tools | Psalm. For more information about installing Psalm, see: https://psalm.dev/docs/running_psalm/installation/ |
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. | |
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. |
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 exception classes added to the Unchecked Exceptions list under Settings | PHP | Analysis are excluded from the inspection scope. | | |
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 | |
Thanks for your feedback!