Skip to content

Commit af0ecf4

Browse files
[Debug] make screaming configurable
1 parent a8888be commit af0ecf4

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,25 @@ class DebugHandlersListener implements EventSubscriberInterface
2727
private $exceptionHandler;
2828
private $logger;
2929
private $levels;
30-
private $debug;
30+
private $throw;
31+
private $scream;
32+
private $fileLinkFormat;
3133

3234
/**
3335
* @param callable $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 bool $throw Enables/disables throwing on PHP errors
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, $throw = true, $scream = true, $fileLinkFormat = null)
4043
{
4144
$this->exceptionHandler = $exceptionHandler;
4245
$this->logger = $logger;
4346
$this->levels = $levels;
44-
$this->debug = $debug;
47+
$this->throw = $throw;
48+
$this->scream = $scream;
4549
$this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
4650
}
4751

@@ -52,18 +56,19 @@ public function configure()
5256
$handler = is_array($handler) ? $handler[0] : null;
5357
restore_error_handler();
5458
if ($handler instanceof ErrorHandler) {
55-
if ($this->debug) {
56-
$handler->throwAt(-1);
57-
}
5859
$handler->setDefaultLogger($this->logger, $this->levels);
5960
if (is_array($this->levels)) {
60-
$scream = 0;
61+
$levels = 0;
6162
foreach ($this->levels as $type => $log) {
62-
$scream |= $type;
63+
$levels |= $type;
6364
}
64-
$this->levels = $scream;
65+
} else {
66+
$levels = null === $this->levels ? E_ALL | E_STRICT : $this->levels;
67+
}
68+
$handler->throwAt($this->throw ? $levels : ($handler->throwAt(0) & ~$levels));
69+
if ($this->scream) {
70+
$handler->screamAt($levels);
6571
}
66-
$handler->screamAt($this->levels);
6772
}
6873
$this->logger = $this->levels = null;
6974
}

0 commit comments

Comments
 (0)