Skip to content

[phpunit-bridge] getPhpUnitErrorHandler doesn't support PHPUnit10 #41580

Closed
@sabat24

Description

@sabat24

Symfony version(s) affected: 5.3.0

Description
Method getPhpUnitErrorHandler

Method checks if PHPUnit\Util\ErrorHandler class exists. However in PHPUnit 10 they changed the name of that class to: PHPUnit\Util\Error\Handler

This is why you should add one more condition to check if you are between 8.3 and 10 version of PHPUnit. Then you have to create a proper error Handler.

Some dirty fix:

use PHPUnit\Util\Error\Handler;
private static $isAtLeastPhpUnit100;

...

if (!isset(self::$isAtLeastPhpUnit83)) {
    self::$isAtLeastPhpUnit83 = class_exists(ErrorHandler::class) && method_exists(ErrorHandler::class, '__invoke');
}

if (!isset(self::$isAtLeastPhpUnit100)) {
    self::$isAtLeastPhpUnit100 = class_exists(Handler::class) && method_exists(Handler::class, '__invoke');
}

...
if (!self::$isAtLeastPhpUnit100) {
    return new ErrorHandler();
} else {
    return new Handler();
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions