From 6360120a8ac1f8e660a102ca169a2eebb72daf29 Mon Sep 17 00:00:00 2001 From: Lewis Cowles Date: Mon, 27 Jun 2022 09:51:30 +0100 Subject: [PATCH 1/3] Add 8 and 8.1 to CI branches --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From c42bc26868c68584d2a0a60ca656d753d96defd8 Mon Sep 17 00:00:00 2001 From: Lewis Cowles Date: Mon, 27 Jun 2022 10:00:29 +0100 Subject: [PATCH 2/3] Overcome empty document error for PHP8+ --- Mf2/Parser.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Mf2/Parser.php b/Mf2/Parser.php index 410883a..5ce529e 100644 --- a/Mf2/Parser.php +++ b/Mf2/Parser.php @@ -366,6 +366,10 @@ class Parser { public function __construct($input, $url = null, $jsonMode = false) { libxml_use_internal_errors(true); if (is_string($input)) { + if (empty($input)) { + $input = ''; + } + if (class_exists('Masterminds\\HTML5')) { $doc = new \Masterminds\HTML5(array('disable_html_ns' => true)); $doc = $doc->loadHTML($input); From ade21a70d2c1d06f65581dde3c40f6e2b9350a84 Mon Sep 17 00:00:00 2001 From: Lewis Cowles Date: Mon, 27 Jun 2022 10:03:42 +0100 Subject: [PATCH 3/3] Attempt 2 at Empty Document Default for PHP 8+ --- Mf2/Parser.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Mf2/Parser.php b/Mf2/Parser.php index 5ce529e..8b6485b 100644 --- a/Mf2/Parser.php +++ b/Mf2/Parser.php @@ -364,10 +364,11 @@ 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 = ''; + $input = $emptyDocDefault; } if (class_exists('Masterminds\\HTML5')) { @@ -381,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.