Skip to content

Commit cf4ef92

Browse files
committed
Merge branch '5.4' into 6.4
* 5.4: [PhpUnitBridge] Fix error handler triggered outside of tests
2 parents 0c74981 + 8ed9bb0 commit cf4ef92

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -376,22 +376,26 @@ private static function getPhpUnitErrorHandler(): callable
376376

377377
if ('PHPUnit\Util\ErrorHandler::handleError' === $eh) {
378378
return $eh;
379-
} elseif (ErrorHandler::class === $eh) {
380-
return function (int $errorNumber, string $errorString, string $errorFile, int $errorLine) {
381-
ErrorHandler::instance()($errorNumber, $errorString, $errorFile, $errorLine);
382-
383-
return true;
384-
};
385379
}
386380

387381
foreach (debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS) as $frame) {
388-
if (isset($frame['object']) && $frame['object'] instanceof TestResult) {
382+
if (!isset($frame['object'])) {
383+
continue;
384+
}
385+
386+
if ($frame['object'] instanceof TestResult) {
389387
return new $eh(
390388
$frame['object']->getConvertDeprecationsToExceptions(),
391389
$frame['object']->getConvertErrorsToExceptions(),
392390
$frame['object']->getConvertNoticesToExceptions(),
393391
$frame['object']->getConvertWarningsToExceptions()
394392
);
393+
} elseif (ErrorHandler::class === $eh && $frame['object'] instanceof TestCase) {
394+
return function (int $errorNumber, string $errorString, string $errorFile, int $errorLine) {
395+
ErrorHandler::instance()($errorNumber, $errorString, $errorFile, $errorLine);
396+
397+
return true;
398+
};
395399
}
396400
}
397401

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy