Skip to content

Commit

Permalink
refactor: Use closure for no-op error handlers
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Voříšek <mvorisek@mvorisek.cz>
Signed-off-by: Natsuki Ikeguchi <me@s6n.jp>
  • Loading branch information
siketyan and mvorisek committed Jan 23, 2024
1 parent 9dacf83 commit a5f3908
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Util/PHP/Template/TestCaseClass.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function __phpunit_run_isolated_test()

ini_set('xdebug.scream', '0');

set_error_handler('__phpunit_error_handler');
set_error_handler(static fn() => false);

// Not every STDOUT target stream is rewindable
@rewind(STDOUT);
Expand Down
12 changes: 6 additions & 6 deletions src/Util/PHP/Template/TestCaseMethod.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ if ($composerAutoload) {
require $phar;
}

function __phpunit_error_handler($errno, $errstr, $errfile, $errline)
{
return true;
}

function __phpunit_run_isolated_test()
{
$dispatcher = Facade::instance()->initForIsolation(
Expand Down Expand Up @@ -71,7 +66,7 @@ function __phpunit_run_isolated_test()

ini_set('xdebug.scream', '0');

set_error_handler('__phpunit_error_handler');
set_error_handler(static fn() => false);

// Not every STDOUT target stream is rewindable
@rewind(STDOUT);
Expand Down Expand Up @@ -103,6 +98,11 @@ function __phpunit_run_isolated_test()
);
}

function __phpunit_error_handler($errno, $errstr, $errfile, $errline)
{
return true;
}

set_error_handler('__phpunit_error_handler');

{constants}
Expand Down

0 comments on commit a5f3908

Please sign in to comment.