@@ -27,45 +27,52 @@ class DebugHandlersListener implements EventSubscriberInterface
2727private $ exceptionHandler ;
2828private $ logger ;
2929private $ levels ;
30- private $ debug ;
30+ private $ throwAt ;
31+ private $ scream ;
32+ private $ fileLinkFormat ;
3133
3234/**
33- * @param callable $exceptionHandler A handler that will be called on Exception
35+ * @param callable|null $exceptionHandler A handler that will be called on Exception
3436 * @param LoggerInterface|null $logger A PSR-3 logger
3537 * @param array|int $levels An array map of E_* to LogLevel::* or an integer bit field of E_* constants
36- * @param bool $debug Enables/disables debug mode
38+ * @param int|null $throwAt Thrown errors in a bit field of E_* constants, or null to keep the current value
39+ * @param bool $scream Enables/disables screaming mode, where even silenced errors are logged
3740 * @param string $fileLinkFormat The format for links to source files
3841 */
39- public function __construct ($ exceptionHandler ,LoggerInterface $ logger =null ,$ levels =null ,$ debug =true ,$ fileLinkFormat =null )
42+ public function __construct ($ exceptionHandler ,LoggerInterface $ logger =null ,$ levels =null ,$ throwAt = - 1 , $ scream =true ,$ fileLinkFormat =null )
4043 {
4144$ this ->exceptionHandler =$ exceptionHandler ;
4245$ this ->logger =$ logger ;
4346$ this ->levels =$ levels ;
44- $ this ->debug =$ debug ;
47+ $ this ->throwAt =is_numeric ($ throwAt ) ? (int )$ throwAt : (null ===$ throwAt ?null : ($ throwAt ? -1 :null ));
48+ $ this ->scream = (bool )$ scream ;
4549$ this ->fileLinkFormat =$ fileLinkFormat ?:ini_get ('xdebug.file_link_format ' ) ?:get_cfg_var ('xdebug.file_link_format ' );
4650 }
4751
4852public function configure ()
4953 {
50- if ($ this ->logger ) {
51- $ handler =set_error_handler ('var_dump ' ,0 );
52- $ handler =is_array ($ handler ) ?$ handler [0 ] :null ;
53- restore_error_handler ();
54- if ($ handlerinstanceof ErrorHandler) {
55- if ($ this ->debug ) {
56- $ handler ->throwAt (-1 );
57- }
54+ $ handler =set_error_handler ('var_dump ' ,0 );
55+ $ handler =is_array ($ handler ) ?$ handler [0 ] :null ;
56+ restore_error_handler ();
57+ if ($ handlerinstanceof ErrorHandler) {
58+ if ($ this ->logger ) {
5859$ handler ->setDefaultLogger ($ this ->logger ,$ this ->levels );
5960if (is_array ($ this ->levels )) {
6061$ scream =0 ;
6162foreach ($ this ->levels as $ type =>$ log ) {
6263$ scream |=$ type ;
6364 }
64- $ this ->levels =$ scream ;
65+ }else {
66+ $ scream =null ===$ this ->levels ?E_ALL |E_STRICT :$ this ->levels ;
6567 }
66- $ handler ->screamAt ($ this ->levels );
68+ if ($ this ->scream ) {
69+ $ handler ->screamAt ($ scream );
70+ }
71+ $ this ->logger =$ this ->levels =null ;
72+ }
73+ if (null !==$ this ->throwAt ) {
74+ $ handler ->throwAt ($ this ->throwAt ,true );
6775 }
68- $ this ->logger =$ this ->levels =null ;
6976 }
7077if ($ this ->exceptionHandler ) {
7178$ handler =set_exception_handler ('var_dump ' );
@@ -78,7 +85,9 @@ public function configure()
7885 }
7986if ($ handlerinstanceof ExceptionHandler) {
8087$ handler ->setHandler ($ this ->exceptionHandler );
81- $ handler ->setFileLinkFormat ($ this ->fileLinkFormat );
88+ if (null !==$ this ->fileLinkFormat ) {
89+ $ handler ->setFileLinkFormat ($ this ->fileLinkFormat );
90+ }
8291 }
8392$ this ->exceptionHandler =null ;
8493 }