Is there any way how I can also document the thrown exceptions if the method is documented via the PHPdoc tag @method
? According to the official documentation on @method
this seems impossible. But maybe there is an unofficial way which is understood by most IDEs? (My IDE is PHPstorm).
Example for a use case:
The PHP framework Laravel supports so-called "facade" classes which allow to access the method of an instance of a class in a static way. Hence, I frequently have a class like this:
class MyFooProvider {
/**
* Does something fancy.
*
* @param string $arg bla bla bla
* @return int blub blub blub
* @throws \InvalidArgumentException thrown, if ...
*/
public function bar(string $arg): int {
...
}
}
/*
* Provides access to methods of {@link MyFooProvider} in a static way.
*
* @internal keep the list of documented methods in sync with {@link MyFooProvider}
*
* @method static int bar(string $arg) Does something fancy.
*/
class Foo extends Facade {
protected static function getFacadeAccessor(): string {
return 'MyFooProvider';
}
}
However, if I use Foo::bar
the IDE does not know that Foo::bar
might throw the exception \InvalidArgumentException
.