PHP 8.2.30
Preview: SchemaDetector.php Size: 1.16 KB
/home/byroehnu/easetack.com/vendor/phpunit/phpunit/src/TextUI/Configuration/Xml/SchemaDetector/SchemaDetector.php

<?php declare(strict_types=1);
/*
 * This file is part of PHPUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace PHPUnit\TextUI\XmlConfiguration;

use PHPUnit\Util\Xml\Loader;
use PHPUnit\Util\Xml\XmlException;

/**
 * @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
 */
final readonly class SchemaDetector
{
    /**
     * @throws XmlException
     */
    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;
    }
}

Directory Contents

Dirs: 0 × Files: 4

Name Size Perms Modified Actions
602 B lrw-rw-rw- 2025-04-08 07:59:11
Edit Download
924 B lrw-rw-rw- 2025-04-08 07:59:11
Edit Download
1.16 KB lrw-rw-rw- 2025-04-08 07:59:11
Edit Download
1.01 KB lrw-rw-rw- 2025-04-08 07:59:11
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).