Menu

#200 "Creation of dynamic property" warning in PHP 8.2 (version 1.9.1)

open
None
2022-05-09
2022-05-02
No

I get the following deprecated warning in PHP 8.2-dev:
"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"

In 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

To fix:
Add this line in simple_html_dom.php, after line 1461 (in the version 1.9.1 code base)

protected $optional_closing_array;

Discussion

  • LogMANOriginal

    LogMANOriginal - 2022-05-09

    Thanks for your bug report.

    This is actually a typo.
    The variable should be called $optional_closing_tags.

    There is a recent commit in master that illustrates the fix. This should also work in PHP 8.2 and higher.

    [8dc21bcb714c4edcb4318bdc3f198f4f78762381]

     

    Related

    Commit: [8dc21b]

  • LogMANOriginal

    LogMANOriginal - 2022-05-09
    • assigned_to: LogMANOriginal
     

Log in to post a comment.