Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b1c774f

Browse files
committed
simplify debug error_reporting levels given php version > 5.3
1 parent 99884c7 commit b1c774f

File tree

4 files changed

+11
-13
lines changed

4 files changed

+11
-13
lines changed

src/Symfony/Component/Debug/Debug.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Debug
3131
* @param int $errorReportingLevel The level of error reporting you want
3232
* @param bool $displayErrors Whether to display errors (for development) or just log them (for production)
3333
*/
34-
public static function enable($errorReportingLevel = null, $displayErrors = true)
34+
public static function enable($errorReportingLevel = E_ALL, $displayErrors = true)
3535
{
3636
if (static::$enabled) {
3737
return;
@@ -42,7 +42,7 @@ public static function enable($errorReportingLevel = null, $displayErrors = true
4242
if (null !== $errorReportingLevel) {
4343
error_reporting($errorReportingLevel);
4444
} else {
45-
error_reporting(-1);
45+
error_reporting(E_ALL);
4646
}
4747

4848
if ('cli' !== php_sapi_name()) {

src/Symfony/Component/Debug/ErrorHandler.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,6 @@ public static function register(self $handler = null, $replace = true)
113113
register_shutdown_function(__CLASS__.'::handleFatalError');
114114
}
115115

116-
$levels = -1;
117-
118116
if ($handlerIsNew = null === $handler) {
119117
$handler = new static();
120118
}
@@ -131,7 +129,7 @@ public static function register(self $handler = null, $replace = true)
131129
restore_error_handler();
132130
}
133131

134-
$handler->throwAt($levels & $handler->thrownErrors, true);
132+
$handler->throwAt(E_ALL & $handler->thrownErrors, true);
135133

136134
return $handler;
137135
}
@@ -151,7 +149,7 @@ public function __construct(BufferingLogger $bootstrappingLogger = null)
151149
* @param array|int $levels An array map of E_* to LogLevel::* or an integer bit field of E_* constants
152150
* @param bool $replace Whether to replace or not any existing logger
153151
*/
154-
public function setDefaultLogger(LoggerInterface $logger, $levels = null, $replace = false)
152+
public function setDefaultLogger(LoggerInterface $logger, $levels = E_ALL, $replace = false)
155153
{
156154
$loggers = array();
157155

@@ -163,7 +161,7 @@ public function setDefaultLogger(LoggerInterface $logger, $levels = null, $repla
163161
}
164162
} else {
165163
if (null === $levels) {
166-
$levels = E_ALL | E_STRICT;
164+
$levels = E_ALL;
167165
}
168166
foreach ($this->loggers as $type => $log) {
169167
if (($type & $levels) && (empty($log[0]) || $replace || $log[0] === $this->bootstrappingLogger)) {
@@ -255,7 +253,7 @@ public function setExceptionHandler(callable $handler = null)
255253
public function throwAt($levels, $replace = false)
256254
{
257255
$prev = $this->thrownErrors;
258-
$this->thrownErrors = (E_ALL | E_STRICT) & ($levels | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED;
256+
$this->thrownErrors = E_ALL & ($levels | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED;
259257
if (!$replace) {
260258
$this->thrownErrors |= $prev;
261259
}

src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class DebugClassLoaderTest extends \PHPUnit_Framework_TestCase
2626

2727
protected function setUp()
2828
{
29-
$this->errorReporting = error_reporting(E_ALL | E_STRICT);
29+
$this->errorReporting = error_reporting(E_ALL);
3030
$this->loader = new ClassLoader();
3131
spl_autoload_register(array($this->loader, 'loadClass'), true, true);
3232
DebugClassLoader::enable();

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ class DebugHandlersListener implements EventSubscriberInterface
4545
* @param bool $scream Enables/disables screaming mode, where even silenced errors are logged
4646
* @param string $fileLinkFormat The format for links to source files
4747
*/
48-
public function __construct(callable $exceptionHandler = null, LoggerInterface $logger = null, $levels = null, $throwAt = -1, $scream = true, $fileLinkFormat = null)
48+
public function __construct(callable $exceptionHandler = null, LoggerInterface $logger = null, $levels = E_ALL, $throwAt = E_ALL, $scream = true, $fileLinkFormat = null)
4949
{
5050
$this->exceptionHandler = $exceptionHandler;
5151
$this->logger = $logger;
52-
$this->levels = $levels;
53-
$this->throwAt = is_numeric($throwAt) ? (int) $throwAt : (null === $throwAt ? null : ($throwAt ? -1 : null));
52+
$this->levels = null === $levels ? E_ALL : $levels;
53+
$this->throwAt = is_numeric($throwAt) ? (int) $throwAt : (null === $throwAt ? null : ($throwAt ? E_ALL : null));
5454
$this->scream = (bool) $scream;
5555
$this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
5656
}
@@ -79,7 +79,7 @@ public function configure(Event $event = null)
7979
$scream |= $type;
8080
}
8181
} else {
82-
$scream = null === $this->levels ? E_ALL | E_STRICT : $this->levels;
82+
$scream = $this->levels;
8383
}
8484
if ($this->scream) {
8585
$handler->screamAt($scream);

0 commit comments

Comments
 (0)