class ExtensionBootstrapper
@no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
@internal This class is not covered by the backward compatibility promise for PHPUnit
Hierarchy
- class \PHPUnit\Runner\Extension\ExtensionBootstrapper
Expanded class hierarchy of ExtensionBootstrapper
1 file declares its use of ExtensionBootstrapper
- Application.php in vendor/
phpunit/ phpunit/ src/ TextUI/ Application.php
File
-
vendor/
phpunit/ phpunit/ src/ Runner/ Extension/ ExtensionBootstrapper.php, line 28
Namespace
PHPUnit\Runner\ExtensionView source
final class ExtensionBootstrapper {
private readonly Configuration $configuration;
private readonly Facade $facade;
public function __construct(Configuration $configuration, Facade $facade) {
$this->configuration = $configuration;
$this->facade = $facade;
}
/**
* @psalm-param class-string $className
* @psalm-param array<string, string> $parameters
*/
public function bootstrap(string $className, array $parameters) : void {
if (!class_exists($className)) {
EventFacade::emitter()->testRunnerTriggeredWarning(sprintf('Cannot bootstrap extension because class %s does not exist', $className));
return;
}
if (!in_array(Extension::class, class_implements($className), true)) {
EventFacade::emitter()->testRunnerTriggeredWarning(sprintf('Cannot bootstrap extension because class %s does not implement interface %s', $className, Extension::class));
return;
}
try {
$instance = (new ReflectionClass($className))->newInstance();
assert($instance instanceof Extension);
$instance->bootstrap($this->configuration, $this->facade, ParameterCollection::fromArray($parameters));
} catch (Throwable $t) {
EventFacade::emitter()->testRunnerTriggeredWarning(sprintf('Bootstrapping of extension %s failed: %s%s%s', $className, $t->getMessage(), PHP_EOL, $t->getTraceAsString()));
return;
}
EventFacade::emitter()->testRunnerBootstrappedExtension($className, $parameters);
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
ExtensionBootstrapper::$configuration | private | property | |
ExtensionBootstrapper::$facade | private | property | |
ExtensionBootstrapper::bootstrap | public | function | @psalm-param class-string $className @psalm-param array<string, string> $parameters |
ExtensionBootstrapper::__construct | public | function |