Assuming the following example code:
/**
* @method bool someMethod()
*/
class MyClass
{
/**
* @throws MyClassException
*/
public function __call($method, $args)
{
if ($this->someCheck()) {
throw new MyClassException();
}
}
}
//...
try {
(new MyClass())->someMethod();
} catch (MyClassException $e) { // Reported by PHPStorm as not thrown!
// of course the exception is properly caught
}
How can I make IDE detect exceptions thrown by a methods declared with @method
docblock? Wonder if this is even possible to do, if not - what are my alternatives?
It seems like @throws
declared in magic methods are totally ignored in cases like this. Of course I could disable inspections but this isn't clean solution for me...