Inspectopedia 2024.3 Help

Code smell

'__toString' may throw an exception   New in this release

Reports the usages of __toString that may throw an exception, which is not allowed for PHP language level lower than 7.4.

'array_push()' with single element   New in this release

Reports the array_push() calls that are used to add a single element to an array.

'array_search()' can be replaced with 'in_array()' call   New in this release

Reports the array_search() calls that are only used for checking whether an element exists in array, that is, the expressions like if (array_search($a, $b) === false) {}.

'continue' is targeting 'switch' statement   New in this release

Reports the continue statements that are targeting switch statements.

'func_get_arg()' call can be replaced with parameter access   New in this release

Reports the func_get_arg() calls that can be replaced with direct parameter access.

'if' can be merged with subsequent condition   New in this release

Reports the if statements that are followed by elseif or other if statements having the same bodies.

'in_array' can be replaced with comparison   New in this release

Reports the in_array() calls that are provided with a single-element array as the $haystack argument.

'match' expression has only default arm and should be simplified   New in this release

Reports the match expressions only containing a default arm.

'preg_match' can be replaced with 'str_contains'   New in this release

Reports the preg_match() calls with pattern arguments that don't use any regexp facilities.

'preg_match()' can be replaced with comparison   New in this release

Reports the preg_match() calls that are provided with a string argument starting with ^ (Start of String anchor) and ending with $ (End of String anchor).

'preg_replace()' can be replaced with '(l|r)trim' call   New in this release

Reports the preg_replace() calls with empty replacement.

'preg_split' can be replaced with 'explode'   New in this release

Reports preg_split() calls that can be replaced with explode().

'switch' with single 'case'   New in this release

Reports the switch statements that only contain a single case statement.

Accessing static trait members   New in this release

Reports the static member access expressions used on traits.

Argument of 'instanceof' should be only objects or strings   New in this release

Reports arguments of 'instanceof' that are not objects or strings.

Array access can be replaced with 'foreach' value   New in this release

Reports the array access expressions inside foreach loops that can be replaced with a foreach value.

Array internal pointer reset is unnecessary   New in this release

Reports the reset($array) calls on arrays whose internal pointer is already set on the first element.

Array is always empty at the point of access   New in this release

Reports the iterated/accessed arrays that are known to be empty at the point of access.

Array to string conversion   New in this release

Reports array to string conversions, that is, the arrays that are provided in the contexts where a string is expected.

Array used only with write access   New in this release

Reports local arrays that are only updated, but never queried.

Boolean expression can be simplified  

Reports the boolean expressions that contain the true or false literals and can be simplified.

Class constant referenced via child class   New in this release

Reports reference to a class constant via child class which gets this constant from the parent class by inheritance and does not override it within its own scope.

Concatenation to empty string can be merged with assignment   New in this release

Reports the .= concatenation assignments performed right after assignment to an empty string literal.

Condition can be replaced with 'min()'/'max()' call   New in this release

Reports the conditions that perform manual min/max calculation instead of calling min/max functions.

Constant name defined with a leading slash   New in this release

Reports the define constructs in which the constant's FQN starts with a leading slash.

Duplicate branch in 'catch' statement   New in this release

Reports catch statements with duplicated bodies.

Duplicate operand in comparison   New in this release

Reports duplicate operands in binary expressions (+, -, *, /, &&, ||, and .) that are in turn used inside comparison expressions.

Exception is immediately rethrown   New in this release

Reports the catch statements that only rethrow a caught exception, which is located in a class hierarchy different from the subsequent exception types.

Foreach over array literal with single element   New in this release

Reports the foreach statements that iterate over an array literal containing a single element.

Format function call with single argument   New in this release

Reports the sprintf() and vsprintf() calls with a single argument.

Idempotent operation in binary expression   New in this release

Reports the binary expression operands that do not change the expression result (such as + 0 or .

Inconsistent return points   New in this release

Reports inconsistencies in function/method exit points.

Logical expression has same operands   New in this release

Reports the expressions that use the same operands, but should rather use different operands (for example, $var == $var).

Loop can be replaced with 'implode()'   New in this release

Reports the foreach loops that can be safely replaced with implode() calls.

Loop can be replaced with 'in_array()' or 'array_key_exists()' call   New in this release

Reports the foreach loops that can be safely replaced with in_array() or array_key_exists() calls.

Loop can be replaced with 'str_repeat'   New in this release

Reports the for loops that can be safely replaced with str_repeat() calls.

Method visibility should not be overridden   New in this release

Checks that the methods don't override visibility.

Method's return value is never used   New in this release

Reports the private methods returning the values that are not used.

Modulo operation with '1' as operand   New in this release

Reports the modulo expressions % that always evaluate to 0 or 1.

Nested 'dirname()' call can be replaced with 'levels' parameter usage   New in this release

Reports the nested dirname() calls that can be omitted by using the levels parameter instead.

Nested 'min/max' call   New in this release

Reports nested min/max calls.

Parameter's value is always the same   New in this release

Reports the parameters in private methods that have the same value across all method calls.

Parameters number mismatch declaration   New in this release

Reports the function/method calls that take more parameters than specified in their declaration.

Pointless boolean expression inside 'if' condition   New in this release

Reports the boolean expressions inside if conditions that contain $expr == true or $expr == false.

Private property can be local   New in this release

Reports the private properties that are used only in a single method.

Property usages have same access   New in this release

Reports the private properties that are: written but never read read but never written.

Redundant 'array_values' call on a value iterated in 'foreach'   New in this release

Reports the array_values() calls inside foreach loops in which the iterated value is used without a key.

Redundant 'continue/break' argument   New in this release

Reports the redundant 1 argument of continue and break statements.

Redundant 'static' in final class   New in this release

Reports static usages inside final class.

Redundant assignment to promoted property   New in this release

Reports redundant assignments to class properties that duplicate automatic assignments performed through promoted constructor parameters.

Redundant cast to boolean   New in this release

Reports the (bool)/(boolean) casts and boolval() calls that are redundant since casting to bool is performed implicitly.

Redundant cast to string   New in this release

Reports the (string) casts and strval() calls that are redundant since casting to string is performed implicitly.

Redundant closure '.*'   New in this release

Reports redundant leading and trailing '.*' in pattern for `preg_match` function.

Redundant method override   New in this release

Reports the overriding methods that only consist of a single call to the parent method.

Redundant optional argument   New in this release

Reports redundant arguments that match the corresponding default values for optional parameters.

Ternary expression can be replaced with condition   New in this release

Reports the ternary expressions specified as condition ? true : false that can be safely replaced with just condition.

Ternary expression can be replaced with short version   New in this release

Reports the ?: ternary expressions in which the condition and the true statement are matching.

Too many parameters in function declaration   New in this release

Reports the function/method declarations with the number of parameters exceeding the specified limit.

Unnecessary 'return/continue' statement   New in this release

Reports unnecessary return and continue statements that can be safely removed.

Unnecessary local variable   New in this release

Reports the local variables that are used in exit statements, such as throw, return, or yield, immediately after assignment.

Unnecessary pass-by-ref   New in this release

Reports the variables that are passed by reference to a function/method but are not modified in the function/method body.

Unnecessary semicolon  

Reports unnecessary semicolons.

Unnecessary spread operator for function call argument   New in this release

Reports the usages of the spread operator (...) on array literals in function call arguments that may be safely unwrapped.

Usage of a silence operator   New in this release

Reports the usages of the silence operator (@), which is highly discouraged.

Useless trailing comma   New in this release

Reports the trailing commas in parameters lists and closures' use lists that do not bring any benefit.

Using 'count()' as index for appending value to array   New in this release

Reports the count($array) calls that are used as an array index for appending an element to the array: $array[count($array)] = 42.

Last modified: 11 September 2024