{"record":{"id":"536969566df91107","repo":"sebastianbergmann/phpunit","slug":"configured-code-coverage-driver-class-s-does-no-536969","errorCode":null,"errorMessage":"Configured code coverage driver class \"%s\" does not extend %s","messagePattern":"Configured code coverage driver class \"(.+?)\" does not extend (.+?)","errorType":"exception","errorClass":"CodeCoverageDriverException","httpStatus":null,"severity":"error","filePath":"src/Runner/CodeCoverage.php","lineNumber":618,"sourceCode":"    }\n\n    /**\n     * @phpstan-ignore return.internalClass\n     */\n    private function instantiateDriver(string $driverClass, Filter $filter, Granularity $granularity): Driver\n    {\n        if (!class_exists($driverClass)) {\n            throw new CodeCoverageDriverException(\n                sprintf(\n                    'Configured code coverage driver class \"%s\" does not exist',\n                    $driverClass,\n                ),\n            );\n        }\n\n        /** @phpstan-ignore classConstant.internalClass */\n        if (!is_subclass_of($driverClass, Driver::class)) {\n            throw new CodeCoverageDriverException(\n                sprintf(\n                    'Configured code coverage driver class \"%s\" does not extend %s',\n                    $driverClass,\n                    /** @phpstan-ignore classConstant.internalClass */\n                    Driver::class,\n                ),\n            );\n        }\n\n        $reflection = new ReflectionClass($driverClass);\n\n        if (!$reflection->isInstantiable()) {\n            throw new CodeCoverageDriverException(\n                sprintf(\n                    'Configured code coverage driver class \"%s\" is not instantiable',\n                    $driverClass,\n                ),\n            );","sourceCodeStart":600,"sourceCodeEnd":636,"githubUrl":"https://github.com/sebastianbergmann/phpunit/blob/f123cdb2a2d49f15025794166cfed8bda8627dd2/src/Runner/CodeCoverage.php#L600-L636","documentation":"The class named in the <coverage driver=\"...\"> attribute exists, but is_subclass_of() showed it is not a subclass of SebastianBergmann\\CodeCoverage\\Driver\\Driver — the contract PHPUnit's coverage subsystem drives. Only Driver subclasses can be instantiated, so activation aborts with this error.","triggerScenarios":"driver pointing at a class implementing an older php-code-coverage driver interface (version skew after upgrading php-code-coverage), a plain class with a similarly named API, or a wrapper around Xdebug/PCOV functions that never extended Driver.","commonSituations":"Upgrading PHPUnit/php-code-coverage while keeping a custom driver built against the old API; drivers copied from another project; implementing a same-shaped interface instead of extending the Driver base class.","solutions":["Make the class extend SebastianBergmann\\CodeCoverage\\Driver\\Driver and implement its abstract methods.","Align the php-code-coverage version with what this PHPUnit build expects (composer why-not phpunit/phpunit, then update).","If the custom driver is not maintained, drop the driver attribute and use the built-in driver selector."],"exampleFix":"// before\nclass MyDriver\n{\n    public function start(): void {}\n    public function stop(): array { return []; }\n}\n\n// after\nclass MyDriver extends \\SebastianBergmann\\CodeCoverage\\Driver\\Driver\n{\n    // implement the abstract methods of the Driver base class\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"function isUsableCoverageDriver(string $class): bool\n{\n    return class_exists($class)\n        && is_subclass_of($class, \\SebastianBergmann\\CodeCoverage\\Driver\\Driver::class);\n}","tryCatchPattern":null,"preventionTips":["Extend SebastianBergmann\\CodeCoverage\\Driver\\Driver when writing custom drivers, and re-verify after php-code-coverage upgrades.","Lock php-code-coverage to the version your PHPUnit build requires (composer why-not).","Add a CI check asserting is_subclass_of($driverClass, Driver::class) for the configured driver."],"tags":["phpunit","php","code-coverage","configuration","inheritance"],"backgroundTag":"coverage-driver-misconfigured","analyzedSha":"f123cdb2a2d49f15025794166cfed8bda8627dd2","analyzedAt":"2026-08-23T01:20:58.058Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}