1.2.1289. Unsupported Operand Types

This error is raised when trying to combine two values of incompatible type. For example, adding an array and an integer; adding an integer with an object; etc.

Always checks that the types are compatible with the planned operations.

That compatibility may be tricky with numeric strings: these are string that PHP can easily convert to an integer or a float. In such case, they are considered as their converted values.

PHP detects this error at linting time, when using literal values. When static or dynamic expression are involved, this error appears at execution time.

<?php

const MY_ARRAY = 'error';

// Unsupported operand types
$b = MY_ARRAY + array(3,4);

?>

See also PHP - Fatal error: Unsupported operand types [duplicate].

1.2.1289.2. Connex PHP features

1.2.1289.2.1. Suggestions

  • Make sure all the planned operations are compatible with the type used.

1.2.1289.2.2. Specs

Short name

Structures/UnsupportedOperandTypes

Rulesets

All, Analyze, Changed Behavior, PHP recommendations

Exakat since

1.7.2

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

High

Available in

Entreprise Edition, Exakat Cloud