php-simple-html-dom-parser icon indicating copy to clipboard operation
php-simple-html-dom-parser copied to clipboard

"Creation of dynamic property" warning in PHP 8.2

Open rosell-dk opened this issue 2 years ago • 2 comments

I get:

Deprecated: Creation of dynamic property simple_html_dom\simple_html_dom::$optional_closing_array is deprecated in /home/rosell/github/dom-util-for-webp/vendor/kub-at/php-simple-html-dom-parser/src/KubAT/PhpSimple/lib/simple_html_dom.php on line 1489

From PHP 8.2, properties needs to be defined before used. In PHP 8.2, a warning is triggered. In PHP 9.0, an error will be thrown

See: https://wiki.php.net/rfc/deprecate_dynamic_properties

I'm aware that this should be fixed in the original simple_html_dom.php, but until then, I propose that it is fixed here.

rosell-dk avatar May 02 '22 11:05 rosell-dk

To fix: Add this line in simple_html_dom.php, after line 1461:

protected $optional_closing_array;

rosell-dk avatar May 02 '22 11:05 rosell-dk

I have created a ticket here as well: https://sourceforge.net/p/simplehtmldom/bugs/200/

rosell-dk avatar May 02 '22 12:05 rosell-dk