Skip to content

MIR0230

InvalidMethodCall

A method is called with ->method() on a value that is a scalar or array. At runtime this throws an Error.

<?php
function label(string $item): string {
return $item->label(); // string is not an object
}

Ensure the value is an object before calling methods on it, or fix the type annotation:

<?php
function label(Item $item): string {
return $item->label();
}