-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Q | A |
---|---|
PHPUnit version | 11.1.3 |
PHP version | 8.2.x |
Installation Method | both |
Summary
set_error_handler
and set_exception_handler
do not necessarily return a callable - the PHP docs are wrong. See php/doc-en#3421
Since phpunit uses both to store and then set them again in e.g. https://github.com/sebastianbergmann/phpunit/blob/main/src/Framework/TestCase.php#L1938 in conjunction with https://github.com/sebastianbergmann/phpunit/blob/main/src/Framework/TestCase.php#L1950 this leads to phpunit not working
In case this error handler originates from a dependency/outside of the project, that can't be changed and phpunit cannot be used at all
Current behavior
phpunit doesn't work/fatal
How to reproduce
See the php-doc issue for examples
Expected behavior
No fatal
EDIT: as a possible solution checking
if (!is_callable($previousHandler) {
// @todo report risky or something?
break;
}
before the assignment https://github.com/sebastianbergmann/phpunit/blob/main/src/Framework/TestCase.php#L1944C17-L1944C39