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.
Example
Section titled “Example”<?phpclass Reader { public function read(): void {} }class Writer { public function write(): void {} }
function run(Reader|Writer $io): void { $io->read(); // Writer has no read method}How to fix
Section titled “How to fix”Narrow the receiver (instanceof) before the call, or fix the declared type.
