function SchemaDetector::detect
Throws
File
-
vendor/
phpunit/ phpunit/ src/ TextUI/ Configuration/ Xml/ SchemaDetector/ SchemaDetector.php, line 25
Class
- SchemaDetector
- @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
Namespace
PHPUnit\TextUI\XmlConfigurationCode
public function detect(string $filename) : SchemaDetectionResult {
$document = (new Loader())->loadFile($filename);
$schemaFinder = new SchemaFinder();
foreach ($schemaFinder->available() as $candidate) {
$schema = (new SchemaFinder())->find($candidate);
if (!(new Validator())->validate($document, $schema)
->hasValidationErrors()) {
return new SuccessfulSchemaDetectionResult($candidate);
}
}
return new FailedSchemaDetectionResult();
}