Skip to content

[PhpUnitBridge] Fix error handler triggered outside of tests #57110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
private $configuration;

/**
* @var DeprecationGroup[]

Check failure on line 38 in src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

View workflow job for this annotation

GitHub Actions / Psalm

UndefinedDocblockClass

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php:38:13: UndefinedDocblockClass: Docblock-defined class, interface or enum named Symfony\Bridge\PhpUnit\DeprecationErrorHandler\DeprecationGroup does not exist (see https://psalm.dev/200)

Check failure on line 38 in src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

View workflow job for this annotation

GitHub Actions / Psalm

UndefinedDocblockClass

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php:38:13: UndefinedDocblockClass: Docblock-defined class, interface or enum named Symfony\Bridge\PhpUnit\DeprecationErrorHandler\DeprecationGroup does not exist (see https://psalm.dev/200)
*/
private $deprecationGroups = [];

Check failure on line 40 in src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

View workflow job for this annotation

GitHub Actions / Psalm

UndefinedDocblockClass

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php:40:5: UndefinedDocblockClass: Docblock-defined class, interface or enum named Symfony\Bridge\PhpUnit\DeprecationErrorHandler\DeprecationGroup does not exist (see https://psalm.dev/200)

private static $isRegistered = false;
private static $errorHandler;
Expand Down Expand Up @@ -234,12 +234,12 @@
private function resetDeprecationGroups()
{
$this->deprecationGroups = [
'unsilenced' => new DeprecationGroup(),

Check failure on line 237 in src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

View workflow job for this annotation

GitHub Actions / Psalm

UndefinedClass

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php:237:33: UndefinedClass: Class, interface or enum named Symfony\Bridge\PhpUnit\DeprecationErrorHandler\DeprecationGroup does not exist (see https://psalm.dev/019)
'self' => new DeprecationGroup(),

Check failure on line 238 in src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

View workflow job for this annotation

GitHub Actions / Psalm

UndefinedClass

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php:238:27: UndefinedClass: Class, interface or enum named Symfony\Bridge\PhpUnit\DeprecationErrorHandler\DeprecationGroup does not exist (see https://psalm.dev/019)
'direct' => new DeprecationGroup(),

Check failure on line 239 in src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

View workflow job for this annotation

GitHub Actions / Psalm

UndefinedClass

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php:239:29: UndefinedClass: Class, interface or enum named Symfony\Bridge\PhpUnit\DeprecationErrorHandler\DeprecationGroup does not exist (see https://psalm.dev/019)
'indirect' => new DeprecationGroup(),

Check failure on line 240 in src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

View workflow job for this annotation

GitHub Actions / Psalm

UndefinedClass

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php:240:31: UndefinedClass: Class, interface or enum named Symfony\Bridge\PhpUnit\DeprecationErrorHandler\DeprecationGroup does not exist (see https://psalm.dev/019)
'legacy' => new DeprecationGroup(),

Check failure on line 241 in src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

View workflow job for this annotation

GitHub Actions / Psalm

UndefinedClass

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php:241:29: UndefinedClass: Class, interface or enum named Symfony\Bridge\PhpUnit\DeprecationErrorHandler\DeprecationGroup does not exist (see https://psalm.dev/019)
'other' => new DeprecationGroup(),

Check failure on line 242 in src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

View workflow job for this annotation

GitHub Actions / Psalm

UndefinedClass

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php:242:28: UndefinedClass: Class, interface or enum named Symfony\Bridge\PhpUnit\DeprecationErrorHandler\DeprecationGroup does not exist (see https://psalm.dev/019)
];
}

Expand Down Expand Up @@ -368,22 +368,26 @@

if ('PHPUnit\Util\ErrorHandler::handleError' === $eh) {
return $eh;
} elseif (ErrorHandler::class === $eh) {
return function (int $errorNumber, string $errorString, string $errorFile, int $errorLine) {
ErrorHandler::instance()($errorNumber, $errorString, $errorFile, $errorLine);

return true;
};
}

foreach (debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS) as $frame) {
if (isset($frame['object']) && $frame['object'] instanceof TestResult) {
if (!isset($frame['object'])) {
continue;
}

if ($frame['object'] instanceof TestResult) {
return new $eh(
$frame['object']->getConvertDeprecationsToExceptions(),
$frame['object']->getConvertErrorsToExceptions(),
$frame['object']->getConvertNoticesToExceptions(),
$frame['object']->getConvertWarningsToExceptions()
);
} elseif (ErrorHandler::class === $eh && $frame['object'] instanceof TestCase) {

Check failure on line 385 in src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

View workflow job for this annotation

GitHub Actions / Psalm

UndefinedClass

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php:385:82: UndefinedClass: Class, interface or enum named Symfony\Bridge\PhpUnit\TestCase does not exist (see https://psalm.dev/019)
return function (int $errorNumber, string $errorString, string $errorFile, int $errorLine) {
ErrorHandler::instance()($errorNumber, $errorString, $errorFile, $errorLine);

return true;
};
}
}

Expand Down
Loading