Is it possible to determine if class throws a specific exception without invoking methods from said class?

53 views Asked by At

Assume I have several classes like this:

class Child extends Parent {

    public function foo() {
        try {
             ChildEngine::bar()
        } catch (Exception\Custom $e) {
             //exception handling
        }
    }
}

In some of these classes, bar() never throws the aforementioned exception in its ChildEngine, and in some bar() might throw it. On instantiating Child I want to see whether Exception\Custom is thrown in Child without invoking foo().

Does PHP have this kind of functionality?

0

There are 0 answers