Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Collection::offsetGet() signature for PHP 8.1 #291

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

davidbyoung
Copy link

Fixes #290

@kiwijuicer
Copy link

Merge would be appreciated

@dyaskur
Copy link

dyaskur commented Dec 31, 2021

merged :
https://github.com/1forU/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.

hope help other too

thanks.

@AkioSarkiz AkioSarkiz mentioned this pull request Feb 20, 2022
@dakur
Copy link

dakur commented Mar 31, 2022

You can also patch it with composer-patches composer plugin.

Patch file (e.g. patches/paquettg_phphtmlparser_fix_offsetget_deprecation.patch):

diff --git a/src/PHPHtmlParser/Dom/Node/Collection.php b/src/PHPHtmlParser/Dom/Node/Collection.php
index ff44725..6125b19 100644
--- a/src/PHPHtmlParser/Dom/Node/Collection.php
+++ b/src/PHPHtmlParser/Dom/Node/Collection.php
@@ -130,6 +130,7 @@ class Collection implements IteratorAggregate, ArrayAccess, Countable
      *
      * @return mixed
      */
+	#[\ReturnTypeWillChange]
     public function offsetGet($offset)
     {
         return $this->collection[$offset] ?? null;

List it in composer.json:

{
    "extra": {
        "patches": {
            "paquettg/php-html-parser": {
                "Fix deprecation notices for offsetGet() return type": "patches/paquettg_phphtmlparser_fix_offsetget_deprecation.patch"
            },
    }
}

⚠ Note that you have to have aforementioned composer-patches composer plugin installed first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error with method signature of Collection::offsetGet()
4 participants