diff --git a/README.md b/README.md index 714d4a55..f098053a 100755 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Install Install the latest version using composer. ```bash -$ composer require 1foru/php-html-parser +$ composer require wapplersystems/php-html-parser ``` Since the original creator seemed to have abandoned this project and I can not install it on my project, so I created a fork and published it as a new package to allow me to install it on my project. diff --git a/composer.json b/composer.json index 2cc70d3a..029b6b87 100755 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "1foru/php-html-parser", + "name": "wapplersystems/php-html-parser", "type": "library", "description": "An HTML DOM parser. It allows you to manipulate HTML. Find tags on an HTML page with selectors just like jQuery.", "keywords": ["html", "dom", "parser"], diff --git a/src/PHPHtmlParser/Contracts/DomInterface.php b/src/PHPHtmlParser/Contracts/DomInterface.php index f259c9d1..2103ba30 100644 --- a/src/PHPHtmlParser/Contracts/DomInterface.php +++ b/src/PHPHtmlParser/Contracts/DomInterface.php @@ -19,5 +19,5 @@ public function loadStr(string $str, ?Options $options = null): Dom; public function setOptions(Options $options): Dom; - public function find(string $selector, int $nth = null); + public function find(string $selector, ?int $nth = null); } diff --git a/src/PHPHtmlParser/Dom.php b/src/PHPHtmlParser/Dom.php index 0b6ac475..2ef3ee19 100755 --- a/src/PHPHtmlParser/Dom.php +++ b/src/PHPHtmlParser/Dom.php @@ -180,7 +180,7 @@ public function setOptions(Options $options): Dom * * @return mixed|Collection|null */ - public function find(string $selector, int $nth = null) + public function find(string $selector, ?int $nth = null) { $this->isLoaded(); diff --git a/src/PHPHtmlParser/Dom/Parser.php b/src/PHPHtmlParser/Dom/Parser.php index faefd287..5fcc4c88 100644 --- a/src/PHPHtmlParser/Dom/Parser.php +++ b/src/PHPHtmlParser/Dom/Parser.php @@ -105,6 +105,10 @@ public function detectCharset(Options $options, string $defaultCharset, Abstract { // set the default $encode = new Encoder(); + $encoderOptions = new \StringEncoder\Options(); + $encoderOptions->setDefaultTargetEncoding($defaultCharset); + $encoderOptions->setCaseSensitiveEncoding(false); + $encode->setOptions($encoderOptions); $encode->setSourceEncoding($defaultCharset); $encode->setTargetEncoding($defaultCharset);