Skip to content

MIR0015

PossiblyUndefinedMethod

A method is called on a union type where at least one member declares the method and another does not. Reported as info; a method missing from every member is UndefinedMethod.

<?php
class Reader { public function read(): void {} }
class Writer { public function write(): void {} }
function run(Reader|Writer $io): void {
$io->read(); // Writer has no read method
}

Narrow the receiver (instanceof) before the call, or fix the declared type.