Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8ed9bb0

Browse filesBrowse files
committed
bug #57110 [PhpUnitBridge] Fix error handler triggered outside of tests (HypeMC)
This PR was merged into the 5.4 branch. Discussion ---------- [PhpUnitBridge] Fix error handler triggered outside of tests | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #57071 | License | MIT The error handler should be invoked only if the error occurred inside a test. Commits ------- 348f11a [PhpUnitBridge] Fix error handler triggered outside of tests
2 parents 0625660 + 348f11a commit 8ed9bb0
Copy full SHA for 8ed9bb0

File tree

1 file changed

+11
-7
lines changed
Filter options

1 file changed

+11
-7
lines changed

‎src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php
+11-7Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -368,22 +368,26 @@ private static function getPhpUnitErrorHandler()
368368

369369
if ('PHPUnit\Util\ErrorHandler::handleError' === $eh) {
370370
return $eh;
371-
} elseif (ErrorHandler::class === $eh) {
372-
return function (int $errorNumber, string $errorString, string $errorFile, int $errorLine) {
373-
ErrorHandler::instance()($errorNumber, $errorString, $errorFile, $errorLine);
374-
375-
return true;
376-
};
377371
}
378372

379373
foreach (debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS) as $frame) {
380-
if (isset($frame['object']) && $frame['object'] instanceof TestResult) {
374+
if (!isset($frame['object'])) {
375+
continue;
376+
}
377+
378+
if ($frame['object'] instanceof TestResult) {
381379
return new $eh(
382380
$frame['object']->getConvertDeprecationsToExceptions(),
383381
$frame['object']->getConvertErrorsToExceptions(),
384382
$frame['object']->getConvertNoticesToExceptions(),
385383
$frame['object']->getConvertWarningsToExceptions()
386384
);
385+
} elseif (ErrorHandler::class === $eh && $frame['object'] instanceof TestCase) {
386+
return function (int $errorNumber, string $errorString, string $errorFile, int $errorLine) {
387+
ErrorHandler::instance()($errorNumber, $errorString, $errorFile, $errorLine);
388+
389+
return true;
390+
};
387391
}
388392
}
389393

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.