diff --git a/lib/Parser.php b/lib/Parser.php index 08e4cbc..e36d620 100644 --- a/lib/Parser.php +++ b/lib/Parser.php @@ -51,6 +51,14 @@ class Parser { return static::parseDocumentOrFragment($data, $encodingOrContentType, null, null, $config ?? new Config); } + /** Parses a string to produce a partial document (a document fragment) + * + * @param \DOMElement $contextElement The context element. The fragment will be pparsed as if it is a collection of children of this element + * @param int|null $quirksMode The "quirks mode" property of the context element's document. Must be one of Parser::NO_QUIRKS_MODE, Parser::LIMITED_QUIRKS_MODE, or Parser::QUIRKS_MODE + * @param string $data The string to parse. This may be in any valid encoding + * @param string|null $encodingOrContentType The document encoding, or HTTP Content-Type header value, if known. If no provided encoding detection will be attempted + * @param \MensBeam\HTML\Parser\Config|null $config The configuration parameters to use, if any + */ public static function parseFragment(\DOMElement $contextElement, ?int $quirksMode, string $data, ?string $encodingOrContentType = null, ?Config $config = null): \DOMDocumentFragment { // parse the fragment into a temporary document $out = self::parseDocumentOrFragment($data, $encodingOrContentType, $contextElement, $quirksMode, $config ?? new Config); diff --git a/lib/Parser/Output.php b/lib/Parser/Output.php index 100c57c..5068800 100644 --- a/lib/Parser/Output.php +++ b/lib/Parser/Output.php @@ -7,8 +7,12 @@ declare(strict_types=1); namespace MensBeam\HTML\Parser; class Output { + /** @var \DOMDocument The parsed document */ public $document; + /** @var string The document's original encoding, as supplied by the user or detected during parsing */ public $encoding; + /** @var int The "quirks mode" property of the document, one of Parser::NO_QUIRKS_MODE, Parser::LIMITED_QUIRKS_MODE, or Parser::QUIRKS_MODE */ public $quirksMode; + /** @var array|null The list of parse errors emitted during processing if parse error reporting was turned on */ public $errors = null; -} \ No newline at end of file +}