From 9fc4b4241a3e2925d956286694cb8008a5e896f5 Mon Sep 17 00:00:00 2001 From: Roman Rudavskyi Date: Thu, 6 May 2021 22:03:45 +0300 Subject: [PATCH 1/2] Add comment about mb_detect_encoding performance --- src/Dom/Document.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Dom/Document.php b/src/Dom/Document.php index a1a8bd170..ad2b54bc1 100644 --- a/src/Dom/Document.php +++ b/src/Dom/Document.php @@ -350,6 +350,8 @@ public function __construct($version = '', $encoding = null) /** * Named constructor to provide convenient way of transforming HTML into DOM. * + * Due to slow automatic encoding detection, we recommend passing it ether in meta charset or in $options. + * * @param string $html HTML to turn into a DOM. * @param array|string $options Optional. Array of options to configure the document. Used as encoding if a string * is passed. Defaults to an empty array. @@ -377,6 +379,7 @@ public static function fromHtml($html, $options = []) * Named constructor to provide convenient way of transforming a HTML fragment into DOM. * * The difference to Document::fromHtml() is that fragments are not normalized as to their structure. + * Due to slow automatic encoding detection, we recommend passing it in $options. * * @param string $html HTML to turn into a DOM. * @param array|string $options Optional. Array of options to configure the document. Used as encoding if a string From a1103ee4cbc16e0124672279be60dcd1b064dcfc Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Tue, 11 May 2021 17:13:46 +0100 Subject: [PATCH 2/2] Rephrase recommendation --- src/Dom/Document.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Dom/Document.php b/src/Dom/Document.php index ad2b54bc1..b15c5e6c9 100644 --- a/src/Dom/Document.php +++ b/src/Dom/Document.php @@ -350,7 +350,8 @@ public function __construct($version = '', $encoding = null) /** * Named constructor to provide convenient way of transforming HTML into DOM. * - * Due to slow automatic encoding detection, we recommend passing it ether in meta charset or in $options. + * Due to slow automatic encoding detection, it is recommended to provide an explicit + * charset either via a tag or via $options. * * @param string $html HTML to turn into a DOM. * @param array|string $options Optional. Array of options to configure the document. Used as encoding if a string @@ -379,7 +380,9 @@ public static function fromHtml($html, $options = []) * Named constructor to provide convenient way of transforming a HTML fragment into DOM. * * The difference to Document::fromHtml() is that fragments are not normalized as to their structure. - * Due to slow automatic encoding detection, we recommend passing it in $options. + * + * Due to slow automatic encoding detection, it is recommended to pass in an explicit + * charset via $options. * * @param string $html HTML to turn into a DOM. * @param array|string $options Optional. Array of options to configure the document. Used as encoding if a string