Skip to content

Commit

Permalink
Respect the error_reporting() level.
Browse files Browse the repository at this point in the history
  • Loading branch information
jails committed May 30, 2021
1 parent 44cc488 commit 9bc7340
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions spec/Suite/Suite.spec.php
Expand Up @@ -1586,9 +1586,19 @@ public function __call($method, $params = [])

});

it('ignores supressed errors', function () {
it('respects the error_reporting() level', function () {

$closure = function () {
trigger_error('deprecated', E_USER_DEPRECATED);
};

error_reporting(E_ALL ^ E_USER_DEPRECATED);
expect($closure)->not->toThrow();
error_reporting(E_ALL);

skipIf(PHP_MAJOR_VERSION >= 8);
});

it('ignores supressed errors', function () {

$closure = function () {
$failing = function () {
Expand Down
2 changes: 1 addition & 1 deletion src/Suite.php
Expand Up @@ -146,7 +146,7 @@ protected function _errorHandler($enable, $options = [])
return restore_error_handler();
}
$handler = function ($code, $message, $file, $line = 0, $args = []) {
if (error_reporting() === 0) {
if (!(error_reporting() & $code)) {
return;
}
$trace = debug_backtrace();
Expand Down

0 comments on commit 9bc7340

Please sign in to comment.