Skip to content

MIR1503

InvalidCatch

A catch block specifies a type that does not implement the Throwable interface. Only Throwable and its descendants (Exception, Error, and their subclasses) can be caught.

<?php
class NotAnException {}
try {
doSomething();
} catch (NotAnException $e) { // NotAnException is not Throwable
// unreachable
}

Only catch classes that implement Throwable. If NotAnException is meant to represent an error condition, make it extend \Exception or \RuntimeException.