hookable icon indicating copy to clipboard operation
hookable copied to clipboard

Fix callParent method on php 8

Open electrotumbao opened this issue 3 years ago • 12 comments

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.

electrotumbao avatar Jun 29 '21 13:06 electrotumbao

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

ncolgrove avatar Dec 02 '21 20:12 ncolgrove

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

JimmyBastos avatar May 24 '22 15:05 JimmyBastos

Hello, is there a version for php 8 yet?

oksim14 avatar Jun 16 '22 14:06 oksim14

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

ballet-mecanique avatar Sep 29 '22 13:09 ballet-mecanique

@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.

cy-david-ciulla avatar Oct 21 '22 04:10 cy-david-ciulla

@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.

Kenny-MWI avatar Nov 10 '22 20:11 Kenny-MWI

I use composer's patches to apply the fixes.

maqduni avatar Apr 06 '23 00:04 maqduni

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

ballet-mecanique avatar Apr 06 '23 07:04 ballet-mecanique

@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

maqduni avatar Apr 06 '23 14:04 maqduni

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

edoniti avatar Jun 19 '23 12:06 edoniti

@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 avatar Aug 19 '23 07:08 ballet-mecanique

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.

ballet-mecanique avatar Aug 19 '23 07:08 ballet-mecanique