Skip to content

Commit e7ab4f7

Browse files
committed
Rich PHPDoc for ExceptionTypeResolver
1 parent 03c26f2 commit e7ab4f7

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

src/Rules/Exceptions/ExceptionTypeResolver.php

+27-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,33 @@
44

55
use PHPStan\Analyser\Scope;
66

7-
/** @api */
7+
/**
8+
* @api
9+
*
10+
* This interface allows you to write custom logic that can dynamically decide
11+
* whether an exception is checked or unchecked type.
12+
*
13+
* Because the interface accepts a Scope, you can ask about the place in the code where
14+
* it's being decided - a file, a namespace or a class name.
15+
*
16+
* There can only be a single ExceptionTypeResolver per project, and you can register it
17+
* in your configuration file like this:
18+
*
19+
* ```
20+
* services:
21+
* exceptionTypeResolver!:
22+
* class: PHPStan\Rules\Exceptions\ExceptionTypeResolver
23+
* ```
24+
*
25+
* You can also take advantage of the `PHPStan\Rules\Exceptions\DefaultExceptionTypeResolver`
26+
* by injecting it into the constructor of your ExceptionTypeResolver
27+
* and delegate the logic of the classes and places you don't care about.
28+
*
29+
* DefaultExceptionTypeResolver decides the type of the exception based on configuration
30+
* parameters like `exceptions.uncheckedExceptionClasses` etc.
31+
*
32+
* Learn more: https://phpstan.org/blog/bring-your-exceptions-under-control
33+
*/
834
interface ExceptionTypeResolver
935
{
1036

0 commit comments

Comments
 (0)