Skip to content

Commit 41ff9c0

Browse files
committed
ErrorToExceptionHandler: added documentation for trap() and trapAndRemoveFalse()
1 parent 23d23b1 commit 41ff9c0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/ErrorToExceptionHandler.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ public static function set() : void{
6969
}
7070

7171
/**
72+
* Runs the given closure inside the error-to-exception handler.
73+
* Using this function guarantees that any error will cause an exception to be thrown, regardless of whether the
74+
* global exception handler has been set properly or not.
75+
*
7276
* @phpstan-template TReturn
7377
* @phpstan-param \Closure() : TReturn $closure
7478
*
@@ -85,6 +89,9 @@ public static function trap(\Closure $closure){
8589
}
8690

8791
/**
92+
* Same as trap(), but removes false from the set of possible return values. Mainly useful for PHPStan to unfalsify
93+
* the results of stdlib functions that normally return false when emitting warnings.
94+
*
8895
* @phpstan-template TReturn
8996
* @phpstan-param \Closure() : (TReturn|false) $closure
9097
*

0 commit comments

Comments
 (0)