paquettg / php-html-parser

An HTML DOM parser. It allows you to manipulate HTML. Find tags on an HTML page with selectors just like jQuery.
MIT License
2.36k stars 460 forks source link

Error with method signature of Collection::offsetGet() #290

Open davidbyoung opened 2 years ago

davidbyoung commented 2 years ago

PHP 8.1 RC3 errors due to the fact that Collection::offsetGet() does not declare the return type.

PHP Fatal error:  During inheritance of ArrayAccess: Uncaught ErrorException: Return type of PHPHtmlParser\Dom\Node\Collection::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /vendor/paquettg/php-html-parser/src/PHPHtmlParser/Dom/Node/Collection.php:133

Rather than upgrade to PHP 8, this library could use the #[\ReturnTypeWillChange] as suggested in the error, which will just be interpreted as a harmless PHP comment in PHP < 8.

DgithubA commented 1 year ago

i use php ver 8.2.0 and still got this error.

error Trace: error Trace

code: code