Allow to keep certain Exceptions on non primary level
Closed this issue · 3 comments
/**
* @throws \Exception
*/
protected function foo()
{
// this will throw an exception that should be propagated to the caller of foo()
$this->nestedFoo();
}
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
174 | ERROR | [x] @throw annotation `\Exception` superfluous and
| | needs to be removed
----------------------------------------------------------------------
The sniffer only allows primary level exceptions, as those are possible to keep in sync with the code.
Manual exceptions usually start to lie (be out of sync).
In some cases this is however desired.
We could add support for bang-overwrite or alike via
* @throws \Exception !
* @throws \Another\Exception ! Here comes an optional comment as well.
If such an overwrite as comment is found, the removal will not be required.
The idea I used already here and here in a similar context.
Any ideas here, feedback?
If someone wants to make a PR here to support this, feel free to do so, the library is open source.
The only problem I see here is those propagating all the way up to facades. But that might also be a good idea to have for "expected" exceptions
I think that is then the concern of the concrete use cases, and this is also only for project level case afaik.
So in core we would not use this anyway.
Pr open