Inspectopedia Help

Code smell

'__toString' may throw an exception  

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  

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  

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  

Reports the continue statements that are targeting switch statements.

'func_get_arg()' call can be replaced with parameter access  

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

'if' can be merged with subsequent condition  

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

'in_array' can be replaced with comparison  

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  

Reports the match expressions only containing a default arm.

'preg_match' can be replaced with 'str_contains'  

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

'preg_match()' can be replaced with comparison  

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  

Reports the preg_replace() calls with empty replacement.

'preg_split' can be replaced with 'explode'  

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

'switch' with single 'case'  

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

Accessing static trait members  

Reports the static member access expressions used on traits.

Argument of 'instanceof' should be only objects or strings  

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

Array access can be replaced with 'foreach' value  

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

Array internal pointer reset is unnecessary  

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  

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

Array to string conversion  

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  

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  

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  

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

Condition can be replaced with 'min()'/'max()' call  

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

Constant name defined with a leading slash  

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

Duplicate branch in 'catch' statement  

Reports catch statements with duplicated bodies.

Duplicate operand in comparison  

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

Exception is immediately rethrown  

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  

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

Format function call with single argument  

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

Idempotent operation in binary expression  

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

Inconsistent return points  

Reports inconsistencies in function/method exit points.

Logical expression has same operands  

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

Loop can be replaced with 'implode()'  

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

Loop can be replaced with 'in_array()' or 'array_key_exists()' call  

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

Loop can be replaced with 'str_repeat'  

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

Method visibility should not be overridden  

Checks that the methods don't override visibility.

Method's return value is never used  

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

Modulo operation with '1' as operand  

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

Nested 'dirname()' call can be replaced with 'levels' parameter usage  

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

Nested 'min/max' call  

Reports nested min/max calls.

Parameter's value is always the same  

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

Parameters number mismatch declaration  

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

Pointless boolean expression inside 'if' condition  

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

Private property can be local  

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

Property usages have same access  

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

Redundant 'array_values' call on a value iterated in 'foreach'  

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

Redundant 'continue/break' argument  

Reports the redundant 1 argument of continue and break statements.

Redundant 'static' in final class  

Reports static usages inside final class.

Redundant assignment to promoted property  

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

Redundant cast to boolean  

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

Redundant cast to string  

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

Redundant closure '.*'  

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

Redundant method override  

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

Redundant optional argument  

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

Ternary expression can be replaced with condition  

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  

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

Too many parameters in function declaration  

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

Unnecessary 'return/continue' statement  

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

Unnecessary local variable  

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

Unnecessary pass-by-ref  

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  

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

Usage of a silence operator  

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

Useless trailing comma  

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  

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: 18 June 2024