{"record":{"id":"f039dde23a3dab21","repo":"sebastianbergmann/phpunit","slug":"configured-code-coverage-driver-class-s-is-not","errorCode":null,"errorMessage":"Configured code coverage driver class \"%s\" is not instantiable","messagePattern":"Configured code coverage driver class \"(.+?)\" is not instantiable","errorType":"exception","errorClass":"CodeCoverageDriverException","httpStatus":null,"severity":"error","filePath":"src/Runner/CodeCoverage.php","lineNumber":631,"sourceCode":"            );\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            );\n        }\n\n        $constructor = $reflection->getConstructor();\n\n        if ($constructor !== null && $constructor->getNumberOfRequiredParameters() > 0) {\n            $driver = $reflection->newInstance($filter);\n        } else {\n            $driver = $reflection->newInstance();\n        }\n\n        /** @phpstan-ignore instanceof.internalClass */\n        assert($driver instanceof Driver);\n","sourceCodeStart":613,"sourceCodeEnd":649,"githubUrl":"https://github.com/sebastianbergmann/phpunit/blob/f123cdb2a2d49f15025794166cfed8bda8627dd2/src/Runner/CodeCoverage.php#L613-L649","documentation":"The class named in <coverage driver=\"...\"> exists and extends SebastianBergmann\\CodeCoverage\\Driver\\Driver, but ReflectionClass reports it is not instantiable — it is abstract, an interface, an enum, or its constructor is private/protected. PHPUnit reflectively constructs the driver during coverage activation (passing the coverage Filter to the constructor when it has required parameters).","triggerScenarios":"driver pointing at an abstract base class instead of a concrete subclass; an interface extending Driver; a driver whose constructor is private (singleton pattern); an enum-backed driver.","commonSituations":"Refactoring a driver family and leaving the config pointing at the base; singletons exposing only static getInstance(); a copied driver whose constructor became non-public.","solutions":["Point driver at a concrete subclass with a public constructor.","If the constructor is private for singleton reasons, make it public — PHPUnit instantiates the class itself, optionally passing the Filter as the first argument.","For interfaces or abstract families, register the concrete implementation in the attribute instead."],"exampleFix":"<!-- before -->\n<coverage driver=\"App\\Coverage\\AbstractDriver\"/>\n\n<!-- after -->\n<coverage driver=\"App\\Coverage\\XdebugCliDriver\"/>","handlingStrategy":"validation","validationCode":"// Preflight: the configured driver must be reflectively instantiable\n$class = 'App\\\\Coverage\\\\MyDriver';\nif (!(new ReflectionClass($class))->isInstantiable()) {\n    fwrite(STDERR, \"Coverage driver {$class} is abstract or has a non-public constructor\\n\");\n    exit(1);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Point driver at a concrete class with a public constructor; PHP instantiates it itself.","The constructor may optionally receive the coverage Filter when it declares required parameters.","Avoid singletons as drivers; expose a plain instantiable class instead."],"tags":["phpunit","php","code-coverage","configuration","reflection"],"backgroundTag":"coverage-driver-misconfigured","analyzedSha":"f123cdb2a2d49f15025794166cfed8bda8627dd2","analyzedAt":"2026-08-23T01:20:58.058Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}