-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
16 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
||
/** | ||
|
@@ -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(); | ||
} | ||
} |