Files
PhpSpreadsheet/tests/bootstrap.php
T
Adrien Crivelli ec4098c8fd Strict mode for all tests
While we might never be able to have 100% of our code strict, we can at
the very least do it for all of our tests. This ensures that our tests
are using our API with the types as intended by the test author, and not
silently be cast to what our API requires.
2023-09-07 17:44:56 +08:00

38 lines
880 B
PHP

<?php
declare(strict_types=1);
setlocale(LC_ALL, 'en_US.utf8');
function phpunit10ErrorHandler(int $errno, string $errstr, string $filename, int $lineno): bool
{
$x = error_reporting() & $errno;
if (
in_array(
$errno,
[
E_DEPRECATED,
E_WARNING,
E_NOTICE,
E_USER_DEPRECATED,
E_USER_NOTICE,
E_USER_WARNING,
],
true
)
) {
if (0 === $x) {
return true; // message suppressed - stop error handling
}
throw new \Exception("$errstr $filename $lineno");
}
return false; // continue error handling
}
if (!method_exists(\PHPUnit\Framework\TestCase::class, 'setOutputCallback')) {
ini_set('error_reporting', E_ALL);
set_error_handler('phpunit10ErrorHandler');
}