Code Inspection: Function call is not compatible with 'callable' declaration
Reports the parameters in function calls whose types are not compatible with the ones defined via Closure
.
In the following example, the Closure
annotation indicates that a returned function expects two integer
parameters, while the function call is erroneously provided with the array
argument.
/**
* @return Closure(int, int) : int
*/
function delayedAdd(): Closure {
return function($a, $b) {
return $a + $b;
};
}
$numbers = [1, 2];
$adder = delayedAdd();
echo $adder($numbers, 5);
Suppress an inspection in the editor
Place the caret at the highlighted line and press Alt+Enter or click .
Click the arrow next to the inspection you want to suppress and select the necessary suppress action.
Last modified: 25 March 2024