Code style
- 'Closure::fromCallable()' can be converted to the first-class callable syntax
Reports the callable creation expressions that use Closure::fromCallable but can be replaced with first-class callable syntax f(...) available since PHP 8.1.
- 'array_fill' can be converted to loop
Reports the array_fill() calls that can be replaced with foreach loops.
- 'array_filter()' call can be converted to loop
Reports the array_filter() calls that can be replaced with foreach loops.
- 'array_map()' call can be converted to loop
Reports the array_map() calls that can be replaced with foreach loops.
- 'get_class()' call can be replaced with '::class'
Reports the get_class() calls and suggests replacing them with ::class when PHP Language level is set to 8.0 or later.
- 'if' can be replaced with 'match' expression
Reports the if statements inside if-elseif-else constructs that use strict comparisons (===) and could be replaced with match expressions.
- 'instanceof' checks in 'catch' block can be replaced with specific catches
Reports the instanceof checks in single catch blocks that could be replaced with multiple catch blocks specific for each exception instance.
- 'isset' can be replaced with coalesce
Reports the conditions using isset that can be safely replaced with expressions using the ?? null coalesce operator.
- 'isset' can check nested array access and sub properties directly
Reports constructions like isset($a['a']) && isset($a['a']['b']) && isset($b) && isset($b->b) that can be replaced with isset($a['a']['b']) && isset($b->b).
- 'json_decode()' and 'json_last_error()' can be converted to 'json_validate()'
In PHP 8.3 and later, suggests converting `json_decode()` and `json_last_error() === JSON_ERROR_NONE` to `json_validate()`.
- 'match' can be replaced with 'switch' statement
Reports the match expressions that can be replaced with switch statements.
- 'match' expression can be replace with ternary expression
Reports the match expressions containing a default arm and a single non-default arm.
- 'mixed' return type can be narrowed
Reports 'mixed' return types that can be narrowed down to more concrete types.
- 'mixed' type can be replaced with 'array'
Reports the mixed[] usages in PHPDoc blocks that can be safely replaced with array.
- 'pow()' call can be replaced with '**' operator
Reports the pow() calls that can be replaced with the ** operator, which adds no overhead of calling a function.
- 'readonly' modifier is redundant
Reports readonly modifiers applied to properties in read-only classes.
- 'str*()' calls can be replaced with PHP 8 'str_*()' calls
Reports the strpos and substr functions calls that can be replaced with the str_* functions calls (introduced in PHP 8.0).
- 'switch' can be replaced with 'match' expression
Reports 'switch' statements that could be replaced with 'match' expression.
- Automatic conversion of 'false' to array is deprecated
Reports automatic conversions of false values to arrays.
- Case mismatch in method call or class usage
Reports the usages of functions, methods, classes, and namespaces that do not match the case used in their declarations.
- Class can be 'readonly'
Reports classes which contain only readonly properties.
- Class constant can be 'final'
Reports the non-final class constants that are not redefined in child classes.
- Class path doesn't match project structure
Reports the classes with the filepath not following the PSR-0/PSR-4 project structure.
- Closure can be converted to arrow function
Reports the anonymous functions that can be transformed to short arrow functions.
- Comment can be replaced with named argument
Reports the inline comments before arguments in function calls that only contain the name of the parameter and thus serve as hints.
- Control statement body without braces
Reports the control structures (such as loops or conditionals) whose bodies are not enclosed in braces.
- Dangerous array initialization
Reports dangerous array initializations (such as $arr[] = value).
- Define constant name can be replaced with 'const' syntax
Reports the define() calls that can be replaced with const syntax.
- Expression without clarifying parentheses
Reports potentially ambiguous expressions and proposes enclosing them in clarifying parentheses.
- Fully qualified name usage
Reports the fully qualified class names that can be shortened by adding the use statement.
- Implicit octal literal can be replaced with explicit one
Reports the implicit octal literals such as 071 that could be replaced with explicit ones such as 0o71.
- Loop can be converted to 'array_fill()' call
Reports the for loops that can be replaced with array_fill() calls.
- Loop can be converted to 'array_filter()' call
Reports the foreach loops that can be replaced with array_filter() calls.
- Loop can be converted to 'array_map()' call
Reports the foreach loops that can be replaced with array_map() calls.
- Method can be made 'static'
Reports the methods that don't use any instance references and thus may be converted to static methods.
- Multiple 'isset' calls can be replaced with one
Reports multiple isset() checks that can be replaced with a single one.
- Multiple classes declarations in one file
Reports multiple class declarations in a single file, which violates the PSR-0/PSR-4 standards.
- Named arguments order does not match parameters order
Reports named argument with order that does not match parameter order.
- Nullsafe operator '?->' can be used
Reports the null-checking conditional expressions that can be safely replaced with the ?-> nullsafe operator.
- Old style constructor
Reports old-style constructor declarations (ClassName()) and suggests replacing them with new-style constructors (__construct()).
- Open 'echo' tag usage
Reports the <?php echo usages that can be replaced with a short tag <?=.
- Redundant closing tag
Reports PHP closing tag ?> usages, which are redundant in files containing only PHP code.
- Short open 'echo' tag usage
Reports short PHP echo tag <?= usages.
- Short open tag usage
Reports short PHP opening tag <? usages.
- Single-statement body with braces
Reports the control structures (such as loops or conditionals) whose bodies are enclosed in braces but only contain a single child statement.
- Traditional syntax array literal detected
Reports traditional array syntax (array()) usages in array literals and suggests replacing them with short array syntax ([]).
- Trait usage is not allowed
Reports the class references that are resolved to traits but are specified outside use statements.
- Trait use rule resolved to method with different containing class
Reports the trait method use rules that are resolved to methods from a different containing class rather than the one specified in the use declaration.
- Type cast is unnecessary
Reports the type cast operators used on the values that are already of the corresponding type.
- Type cast on a scalar value
Reports the type casts that can be evaluated in place and suggests replacing them with actual computed values.
- Type hint 'array|Traversable' can be replaced with 'iterable'
Reports the array|Traversable type hints that can be replaced with iterable.
- Unnecessary curly braces syntax for variable
Reports unnecessary { and } used for interpolating variables in string literals.
- Unnecessary double quotes
Reports double-quoted string literals that do not contain string interpolation, escape sequences, or single quotes.
- Unnecessary fully qualified name
Reports the usages of fully qualified class names, which can be shortened without adding the use statement.
- Unnecessary leading '\' in 'use' statement
Reports the use statements with an unnecessary leading \.
- Unnecessary parentheses
Reports the expressions containing redundant parenthesis, which can be safely removed.
- Usage of a variable variable
Reports the usages of variable variables (dynamic variable names such as $$a).
- Variable is only used inside closure
Reports variables in closures' use list that are only used inside closure.
- PSR-12
Sub-group of 8 inspections that provide checks for PSR-12