Skip to content

MIR0218

InvalidPropertyFetch

A property is accessed with ->prop on a value that is not an object. At runtime this will produce a fatal error.

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

Ensure the value is an object before accessing its properties, or fix the type annotation:

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