diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b6c72ce..ef98342 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,7 +11,7 @@ jobs: strategy: matrix: - php: ['5.6', '7.3', '7.4'] + php: ['5.6', '7.3', '7.4', '8.0', '8.1'] runs-on: ubuntu-latest diff --git a/Mf2/Parser.php b/Mf2/Parser.php index 410883a..8b6485b 100644 --- a/Mf2/Parser.php +++ b/Mf2/Parser.php @@ -364,8 +364,13 @@ class Parser { * @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. */ public function __construct($input, $url = null, $jsonMode = false) { + $emptyDocDefault = ''; libxml_use_internal_errors(true); if (is_string($input)) { + if (empty($input)) { + $input = $emptyDocDefault; + } + if (class_exists('Masterminds\\HTML5')) { $doc = new \Masterminds\HTML5(array('disable_html_ns' => true)); $doc = $doc->loadHTML($input); @@ -377,7 +382,7 @@ public function __construct($input, $url = null, $jsonMode = false) { $doc = clone $input; } else { $doc = new DOMDocument(); - @$doc->loadHTML(''); + @$doc->loadHTML($emptyDocDefault); } // Create an XPath object and allow some PHP functions to be used within XPath queries.