From 2e2b903146b358360d6cefb936857b0b6dedb45d Mon Sep 17 00:00:00 2001 From: Gemini_13 Date: Tue, 29 Dec 2020 14:03:31 +0200 Subject: [PATCH] Fix for str_replace() Error: `TypeError: str_replace(): Argument #3 ($subject) must be of type array|string, null given` --- src/PHPHtmlParser/Dom/Node/TextNode.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/PHPHtmlParser/Dom/Node/TextNode.php b/src/PHPHtmlParser/Dom/Node/TextNode.php index 1c8b646c..6f5c30c1 100644 --- a/src/PHPHtmlParser/Dom/Node/TextNode.php +++ b/src/PHPHtmlParser/Dom/Node/TextNode.php @@ -53,6 +53,9 @@ public function __construct(string $text, $removeDoubleSpace = true) if ($replacedText === false) { throw new LogicalException('mb_ereg_replace returns false when attempting to clean white space from "' . $text . '".'); } + if ($replacedText === null) { + throw new LogicalException('mb_ereg_replace encountered an invalid encoding for "' . $text . '".'); + } $text = $replacedText; }