@@ -92,6 +92,7 @@ class ErrorHandler
92
92
private $ screamedErrors = 0x55 ; // E_ERROR + E_CORE_ERROR + E_COMPILE_ERROR + E_PARSE
93
93
private $ loggedErrors = 0 ;
94
94
private $ traceReflector ;
95
+ private $ debug ;
95
96
96
97
private $ isRecursive = 0 ;
97
98
private $ isRoot = false ;
@@ -107,7 +108,7 @@ class ErrorHandler
107
108
/**
108
109
* Registers the error handler.
109
110
*/
110
- public static function register (self $ handler = null , bool $ replace = true ): self
111
+ public static function register (self $ handler = null , bool $ replace = true , bool $ debug = false ): self
111
112
{
112
113
if (null === self ::$ reservedMemory ) {
113
114
self ::$ reservedMemory = str_repeat ('x ' , 10240 );
@@ -150,6 +151,7 @@ public static function register(self $handler = null, bool $replace = true): sel
150
151
}
151
152
152
153
$ handler ->throwAt (E_ALL & $ handler ->thrownErrors , true );
154
+ $ handler ->debug = $ debug ;
153
155
154
156
return $ handler ;
155
157
}
@@ -180,14 +182,15 @@ public static function call(callable $function, ...$arguments)
180
182
}
181
183
}
182
184
183
- public function __construct (BufferingLogger $ bootstrappingLogger = null )
185
+ public function __construct (BufferingLogger $ bootstrappingLogger = null , bool $ debug = false )
184
186
{
185
187
if ($ bootstrappingLogger ) {
186
188
$ this ->bootstrappingLogger = $ bootstrappingLogger ;
187
189
$ this ->setDefaultLogger ($ bootstrappingLogger );
188
190
}
189
191
$ this ->traceReflector = new \ReflectionProperty ('Exception ' , 'trace ' );
190
192
$ this ->traceReflector ->setAccessible (true );
193
+ $ this ->debug = $ debug ;
191
194
}
192
195
193
196
/**
@@ -697,7 +700,7 @@ public static function handleFatalError(array $error = null): void
697
700
*/
698
701
private function renderException (\Throwable $ exception ): void
699
702
{
700
- $ renderer = \in_array (\PHP_SAPI , ['cli ' , 'phpdbg ' ], true ) ? new CliErrorRenderer () : new HtmlErrorRenderer (0 !== $ this ->scopedErrors );
703
+ $ renderer = \in_array (\PHP_SAPI , ['cli ' , 'phpdbg ' ], true ) ? new CliErrorRenderer () : new HtmlErrorRenderer ($ this ->debug );
701
704
702
705
$ exception = $ renderer ->render ($ exception );
703
706
0 commit comments