Skip to content

Commit 3a36925

Browse files
committed
Added debug argument to decide if debug page should be shown or not
1 parent a597890 commit 3a36925

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Debug.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ public static function enable(): ErrorHandler
3131

3232
DebugClassLoader::enable();
3333

34-
return ErrorHandler::register(new ErrorHandler(new BufferingLogger()));
34+
return ErrorHandler::register(new ErrorHandler(new BufferingLogger(), true));
3535
}
3636
}

ErrorHandler.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class ErrorHandler
9292
private $screamedErrors = 0x55; // E_ERROR + E_CORE_ERROR + E_COMPILE_ERROR + E_PARSE
9393
private $loggedErrors = 0;
9494
private $traceReflector;
95+
private $debug;
9596

9697
private $isRecursive = 0;
9798
private $isRoot = false;
@@ -180,14 +181,15 @@ public static function call(callable $function, ...$arguments)
180181
}
181182
}
182183

183-
public function __construct(BufferingLogger $bootstrappingLogger = null)
184+
public function __construct(BufferingLogger $bootstrappingLogger = null, bool $debug = false)
184185
{
185186
if ($bootstrappingLogger) {
186187
$this->bootstrappingLogger = $bootstrappingLogger;
187188
$this->setDefaultLogger($bootstrappingLogger);
188189
}
189190
$this->traceReflector = new \ReflectionProperty('Exception', 'trace');
190191
$this->traceReflector->setAccessible(true);
192+
$this->debug = $debug;
191193
}
192194

193195
/**
@@ -697,7 +699,7 @@ public static function handleFatalError(array $error = null): void
697699
*/
698700
private function renderException(\Throwable $exception): void
699701
{
700-
$renderer = \in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) ? new CliErrorRenderer() : new HtmlErrorRenderer(0 !== $this->scopedErrors);
702+
$renderer = \in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) ? new CliErrorRenderer() : new HtmlErrorRenderer($this->debug);
701703

702704
$exception = $renderer->render($exception);
703705

0 commit comments

Comments
 (0)