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

Fix callParent method on php 8 #31

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

Conversation

electrotumbao
Copy link

The call_user_func_array function has been slightly changed on PHP 8 — it supports named arguments now and interprets assoc arrays like them.
Also, calling parent methods now for some reason doesn't work this way.

@ncolgrove
Copy link

I appreciate this update. Would like to see it merged with master for php 8 support.

@JimmyBastos
Copy link

I appreciate this update. Would like to see it merged with master for php 8 support.

@oksim14
Copy link

oksim14 commented Jun 16, 2022

Hello, is there a version for php 8 yet?

@ballet-mecanique
Copy link

@jarektkaczyk Any chance this pull request can get merged? It would help me use the wonderful mappable package in php8 projects.

@cy-david-ciulla
Copy link

@jarektkaczyk Thanks for this neat package! As mentioned by others here, there are some issues on PHP8, so it would be highly appreciated if this pull request could be merged soon.

@Kenny-MWI
Copy link

@jarektkaczyk Are there any plans to merge this in? Is this project still being maintained? This is preventing us from upgrading to PHP 8. PHP 7.4 goes end of life on 28 Nov 2022.

@maqduni
Copy link

maqduni commented Apr 6, 2023

I use composer's patches to apply the fixes.

@ballet-mecanique
Copy link

@maqduni Can you elaborate on how you do this here?

@maqduni
Copy link

maqduni commented Apr 6, 2023

@ballet-mecanique,

  1. Add the following block to composer.json
"extra": {
        "laravel": {
            "dont-discover": []
        },
        "enable-patching": "true",
        "patches": {
            "sofa/hookable": {
                "Fix Parameter Grouping with Laravel 7.x": "patches/sofa_hookable/fix_parameter_grouping_with_laravel_7_x.diff",
                "Fix callParent method on php 8": "patches/sofa_hookable/fix_call_parent_method_on_php_8.diff"
            }
        }
    },
  1. Install cweagans/composer-patches - composer install cweagans/composer-patches. It should add the following settings to the config block,
"config": {
        "sort-packages": true,
        "allow-plugins": {
            "cweagans/composer-patches": true
        }
    },
  1. Generate the patches you need using git diff command (like the ones I have above)
  2. Run composer install or composer update and it should install all the packages and apply the patches on top of them

@edoniti
Copy link

edoniti commented Jun 19, 2023

@jarektkaczyk Would appreciate it if we can have this merged into master.

@ballet-mecanique
Copy link

ballet-mecanique commented Aug 19, 2023

@maqduni Sorry for the delayed response! And thanks so much for the suggestion.

I've tried this avenue, and it almost works - the only thing is that composer times out and I can see why when I run verbose mode with -v : I'm being asked for the file name that needs to be patched in the CLI. Somehow it is not automatically patching the file.

Any idea what setting I may be missing?

Or can you paste the contents of your diff file patches/sofa_hookable/fix_call_parent_method_on_php_8.diff ?

Thanks again!

@ballet-mecanique
Copy link

ballet-mecanique commented Aug 19, 2023

Sorry @maqduni, scratch that. I've found the solution meanwhile and it all works now.

For the others on the thread, here's a step-by-step to how you can patch this into the package with a composer installation (thanks to @maqduni for being the actual source of the solution):

  1. Open the .diff version of this PR on https://github.com/jarektkaczyk/hookable/pull/31.diff
  2. Copy the contents
  3. Create a file in your project under patches/sofa_hookable/fix_call_parent_method_on_php_8.diff and paste the contents here.
  4. Add the following block to composer.json:
"extra": {
        "laravel": {
            "dont-discover": []
        },
        "enable-patching": "true",
        "patches": {
            "sofa/hookable": {
                "Fix callParent method on php 8": "patches/sofa_hookable/fix_call_parent_method_on_php_8.diff"
            }
        }
    },
  1. run composer require cweagans/composer-patches and make sure the following is added to the config block of composer.json:
"config": {
        "sort-packages": true,
        "allow-plugins": {
            "cweagans/composer-patches": true
        }
    },
  1. run composer update or composer install

The patch should now be applied.

@maqduni also patched another file with the entry "Fix Parameter Grouping with Laravel 7.x": "patches/sofa_hookable/fix_parameter_grouping_with_laravel_7_x.diff", under the patches (see his post above). I haven't tested this yet, and my project works without it, but this might be useful for others.

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.

9 participants