Skip to content

Commit

Permalink
bot: fix cs [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
nikophil authored and kbond committed Apr 18, 2024
1 parent 9174dc6 commit 71bbaa2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/Test/ResetDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static function _resetDatabase(): void

PersistenceManager::resetDatabase(
static fn() => static::bootKernel(),
static function (): void {
static function(): void {
static::ensureKernelShutdown();
restorePhpUnitErrorHandler();
},
Expand All @@ -56,7 +56,7 @@ public static function _resetSchema(): void

PersistenceManager::resetSchema(
static fn() => static::bootKernel(),
static function (): void {
static function(): void {
static::ensureKernelShutdown();
restorePhpUnitErrorHandler();
},
Expand Down
19 changes: 14 additions & 5 deletions src/phpunit_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

declare(strict_types=1);

/*
* This file is part of the zenstruck/foundry package.
*
* (c) Kevin Bond <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Zenstruck\Foundry;

/**
Expand All @@ -18,12 +27,12 @@
function restorePhpUnitErrorHandler(): void
{
while (true) {
$previousHandler = set_error_handler(static fn() => null); // @phpstan-ignore-line
restore_error_handler();
$isPhpUnitErrorHandler = ($previousHandler instanceof \PHPUnit\Runner\ErrorHandler); // @phpstan-ignore-line
if ($previousHandler === null || $isPhpUnitErrorHandler) {
$previousHandler = \set_error_handler(static fn() => null); // @phpstan-ignore-line
\restore_error_handler();
$isPhpUnitErrorHandler = $previousHandler instanceof \PHPUnit\Runner\ErrorHandler; // @phpstan-ignore-line
if (null === $previousHandler || $isPhpUnitErrorHandler) {
break;
}
restore_error_handler();
\restore_error_handler();
}
}

0 comments on commit 71bbaa2

Please sign in to comment.