diff --git a/src/lib/types/src/Flow/Types/Value/HTMLDocument.php b/src/lib/types/src/Flow/Types/Value/HTMLDocument.php index 3ee238d67a..9293bb085a 100644 --- a/src/lib/types/src/Flow/Types/Value/HTMLDocument.php +++ b/src/lib/types/src/Flow/Types/Value/HTMLDocument.php @@ -12,7 +12,9 @@ final class HTMLDocument implements \Stringable public function __construct(string|object $value) { - if (\is_string($value)) { + if ('' === $value) { + $this->value = $value; + } elseif (\is_string($value)) { if (\class_exists('\Dom\HTMLDocument', false)) { $options = \LIBXML_HTML_NOIMPLIED; diff --git a/src/lib/types/tests/Flow/Types/Tests/Unit/Type/Logical/HTMLTypeTest.php b/src/lib/types/tests/Flow/Types/Tests/Unit/Type/Logical/HTMLTypeTest.php index 63869914c6..31125ec054 100644 --- a/src/lib/types/tests/Flow/Types/Tests/Unit/Type/Logical/HTMLTypeTest.php +++ b/src/lib/types/tests/Flow/Types/Tests/Unit/Type/Logical/HTMLTypeTest.php @@ -6,6 +6,7 @@ use function Flow\Types\DSL\{type_from_array, type_html}; use Flow\Types\Exception\{CastingException, InvalidTypeException}; +use Flow\Types\Value\HTMLDocument; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; @@ -13,8 +14,8 @@ final class HTMLTypeTest extends TestCase { public static function assert_data_provider() : \Generator { - yield 'valid \DOMDocument' => [ - 'value' => new \DOMDocument, + yield 'valid HTMLDocument' => [ + 'value' => new HTMLDocument(''), 'exceptionClass' => null, ]; @@ -66,7 +67,6 @@ public static function cast_data_provider() : \Generator 'expected' => <<<'HTML'