Skip to content

Commit ade21a7

Browse files
Attempt 2 at Empty Document Default for PHP 8+
1 parent c42bc26 commit ade21a7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Mf2/Parser.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,11 @@ class Parser {
364364
* @param boolean $jsonMode Whether or not to use a stdClass instance for an empty `rels` dictionary. This breaks PHP looping over rels, but allows the output to be correctly serialized as JSON.
365365
*/
366366
public function __construct($input, $url = null, $jsonMode = false) {
367+
$emptyDocDefault = '<html><body></body></html>';
367368
libxml_use_internal_errors(true);
368369
if (is_string($input)) {
369370
if (empty($input)) {
370-
$input = '<html><body></body></html>';
371+
$input = $emptyDocDefault;
371372
}
372373

373374
if (class_exists('Masterminds\\HTML5')) {
@@ -381,7 +382,7 @@ public function __construct($input, $url = null, $jsonMode = false) {
381382
$doc = clone $input;
382383
} else {
383384
$doc = new DOMDocument();
384-
@$doc->loadHTML('');
385+
@$doc->loadHTML($emptyDocDefault);
385386
}
386387

387388
// Create an XPath object and allow some PHP functions to be used within XPath queries.

0 commit comments

Comments
 (0)