Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
RecoverableErrorHandler | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 1 |
__invoke | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace Flow; |
4 | |
5 | use Flow\Exception\CatchableFatalErrorException; |
6 | |
7 | /** |
8 | * Catches E_RECOVERABLE_ERROR and converts into exceptions |
9 | * instead of fataling. |
10 | * |
11 | * Usage: |
12 | * set_error_handler( new RecoverableErrorHandler, E_RECOVERABLE_ERROR ); |
13 | * try { |
14 | * ... |
15 | * } catch ( CatchableFatalErrorException $fatal ) { |
16 | * |
17 | * } finally {} |
18 | * restore_error_handler(); |
19 | * } |
20 | */ |
21 | class RecoverableErrorHandler { |
22 | public function __invoke( $errno, $errstr, $errfile, $errline ) { |
23 | if ( $errno !== E_RECOVERABLE_ERROR ) { |
24 | return false; |
25 | } |
26 | |
27 | throw new CatchableFatalErrorException( $errstr, 0, $errno, $errfile, $errline ); |
28 | } |
29 | } |