-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Debug] simplify error_reporting levels given php version > 5.3 #16916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,8 +113,6 @@ public static function register(self $handler = null, $replace = true) | |
register_shutdown_function(__CLASS__.'::handleFatalError'); | ||
} | ||
|
||
$levels = -1; | ||
|
||
if ($handlerIsNew = null === $handler) { | ||
$handler = new static(); | ||
} | ||
|
@@ -131,7 +129,7 @@ public static function register(self $handler = null, $replace = true) | |
restore_error_handler(); | ||
} | ||
|
||
$handler->throwAt($levels & $handler->thrownErrors, true); | ||
$handler->throwAt(E_ALL & $handler->thrownErrors, true); | ||
|
||
return $handler; | ||
} | ||
|
@@ -151,7 +149,7 @@ public function __construct(BufferingLogger $bootstrappingLogger = null) | |
* @param array|int $levels An array map of E_* to LogLevel::* or an integer bit field of E_* constants | ||
* @param bool $replace Whether to replace or not any existing logger | ||
*/ | ||
public function setDefaultLogger(LoggerInterface $logger, $levels = null, $replace = false) | ||
public function setDefaultLogger(LoggerInterface $logger, $levels = E_ALL, $replace = false) | ||
{ | ||
$loggers = array(); | ||
|
||
|
@@ -163,7 +161,7 @@ public function setDefaultLogger(LoggerInterface $logger, $levels = null, $repla | |
} | ||
} else { | ||
if (null === $levels) { | ||
$levels = E_ALL | E_STRICT; | ||
$levels = E_ALL; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will add a deprecation for the null case in 3.1 as it is useless now. |
||
} | ||
foreach ($this->loggers as $type => $log) { | ||
if (($type & $levels) && (empty($log[0]) || $replace || $log[0] === $this->bootstrappingLogger)) { | ||
|
@@ -255,7 +253,7 @@ public function setExceptionHandler(callable $handler = null) | |
public function throwAt($levels, $replace = false) | ||
{ | ||
$prev = $this->thrownErrors; | ||
$this->thrownErrors = (E_ALL | E_STRICT) & ($levels | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED; | ||
$this->thrownErrors = E_ALL & ($levels | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED; | ||
if (!$replace) { | ||
$this->thrownErrors |= $prev; | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,12 +45,12 @@ class DebugHandlersListener implements EventSubscriberInterface | |
* @param bool $scream Enables/disables screaming mode, where even silenced errors are logged | ||
* @param string $fileLinkFormat The format for links to source files | ||
*/ | ||
public function __construct(callable $exceptionHandler = null, LoggerInterface $logger = null, $levels = null, $throwAt = -1, $scream = true, $fileLinkFormat = null) | ||
public function __construct(callable $exceptionHandler = null, LoggerInterface $logger = null, $levels = E_ALL, $throwAt = E_ALL, $scream = true, $fileLinkFormat = null) | ||
{ | ||
$this->exceptionHandler = $exceptionHandler; | ||
$this->logger = $logger; | ||
$this->levels = $levels; | ||
$this->throwAt = is_numeric($throwAt) ? (int) $throwAt : (null === $throwAt ? null : ($throwAt ? -1 : null)); | ||
$this->levels = null === $levels ? E_ALL : $levels; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will add a deprecation for the null case in 3.1 as it is useless now. |
||
$this->throwAt = is_numeric($throwAt) ? (int) $throwAt : (null === $throwAt ? null : ($throwAt ? E_ALL : null)); | ||
$this->scream = (bool) $scream; | ||
$this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); | ||
} | ||
|
@@ -79,7 +79,7 @@ public function configure(Event $event = null) | |
$scream |= $type; | ||
} | ||
} else { | ||
$scream = null === $this->levels ? E_ALL | E_STRICT : $this->levels; | ||
$scream = $this->levels; | ||
} | ||
if ($this->scream) { | ||
$handler->screamAt($scream); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add a deprecation for the
null
case in 3.1 as it is useless now.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might become an issue in the future when new constants are introduced in future PHP versions (similar to the introduction of the
E_STRICT
constant).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The E_ALL is supposed to include everything which is why it was changed in 5.4