Aggiornato Composer

This commit is contained in:
Paolo A
2024-05-17 12:24:19 +00:00
parent 4ac62108b5
commit ec201d75b2
2238 changed files with 38684 additions and 59785 deletions

View File

@@ -2,15 +2,24 @@
/*
* This file is part of PharIo\Manifest.
*
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
* Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PharIo\Manifest;
use DOMDocument;
use DOMElement;
use Throwable;
use function count;
use function file_get_contents;
use function is_file;
use function libxml_clear_errors;
use function libxml_get_errors;
use function libxml_use_internal_errors;
use function sprintf;
class ManifestDocument {
public const XMLNS = 'https://phar.io/xml/manifest/1.0';
@@ -19,28 +28,31 @@ class ManifestDocument {
private $dom;
public static function fromFile(string $filename): ManifestDocument {
if (!\file_exists($filename)) {
if (!is_file($filename)) {
throw new ManifestDocumentException(
\sprintf('File "%s" not found', $filename)
sprintf('File "%s" not found', $filename)
);
}
return self::fromString(
\file_get_contents($filename)
file_get_contents($filename)
);
}
public static function fromString(string $xmlString): ManifestDocument {
$prev = \libxml_use_internal_errors(true);
\libxml_clear_errors();
$prev = libxml_use_internal_errors(true);
libxml_clear_errors();
$dom = new DOMDocument();
$dom->loadXML($xmlString);
try {
$dom = new DOMDocument();
$dom->loadXML($xmlString);
$errors = libxml_get_errors();
libxml_use_internal_errors($prev);
} catch (Throwable $t) {
throw new ManifestDocumentException($t->getMessage(), 0, $t);
}
$errors = \libxml_get_errors();
\libxml_use_internal_errors($prev);
if (\count($errors) !== 0) {
if (count($errors) !== 0) {
throw new ManifestDocumentLoadingException($errors);
}
@@ -94,7 +106,7 @@ class ManifestDocument {
if (!$element instanceof DOMElement) {
throw new ManifestDocumentException(
\sprintf('Element %s missing', $elementName)
sprintf('Element %s missing', $elementName)
);
}