Masterminds / html5-php

An HTML5 parser and serializer for PHP.
http://masterminds.github.io/html5-php/
Other
1.55k stars 114 forks source link

Fix masterminds-html5 lib php8-1 notice return type use phpstan #231

Closed igumnovaleksey closed 5 months ago

igumnovaleksey commented 1 year ago

The following deprecated notices were found while using the phpstan tool:

all/libraries/composer/vendor/masterminds/html5/src/HTML5/Parser/StringInputStream.php 180 line Return type mixed of method Masterminds\HTML5\Parser\StringInputStream::current() is not covariant with tentative return type mixed of method Iterator::current(). 189 line Return type mixed of method Masterminds\HTML5\Parser\StringInputStream::next() is not covariant with tentative return type void of method Iterator::next() 197 line Return type mixed of method Masterminds\HTML5\Parser\StringInputStream::rewind() is not covariant with tentative return type void of method Iterator::rewind() 207 line Return type mixed of method Masterminds\HTML5\Parser\StringInputStream::valid() is not covariant with tentative return type bool of method Iterator::valid() 327 line Return type mixed of method Masterminds\HTML5\Parser\StringInputStream::key() is not covariant with tentative return type mixed of method Iterator::key()

goetas commented 1 year ago

This library aims to be compatible with php 5.3, this return types are not supported

alecpl commented 1 year ago

Use #[ReturnTypeWillChange] instead.

PavelSPN commented 5 months ago

Hi there!

@goetas As I know the #[ReturnTypeWillChange] is not impact on php5.3 it's just for backward compatibility of older code. Some information: https://stackoverflow.com/questions/71133749/reference-return-type-of-should-either-be-compatible-with-or-the-re As for me, the PR created by @igumnovaleksey can be merged that allow the code to be more compatible with PHP8.1 and higher.