hookable
hookable copied to clipboard
Fix callParent method on php 8
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.
I appreciate this update. Would like to see it merged with master for php 8 support.
I appreciate this update. Would like to see it merged with master for php 8 support.
Hello, is there a version for php 8 yet?
@jarektkaczyk Any chance this pull request can get merged? It would help me use the wonderful mappable package in php8 projects.
@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.
@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.
I use composer's patches to apply the fixes.
@maqduni Can you elaborate on how you do this here?
@ballet-mecanique,
- 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"
}
}
},
- Install
cweagans/composer-patches
-composer install cweagans/composer-patches
. It should add the following settings to theconfig
block,
"config": {
"sort-packages": true,
"allow-plugins": {
"cweagans/composer-patches": true
}
},
- Generate the patches you need using
git diff
command (like the ones I have above) - Run
composer install
orcomposer update
and it should install all the packages and apply the patches on top of them
@jarektkaczyk Would appreciate it if we can have this merged into master.
@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!
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):
- Open the .diff version of this PR on https://github.com/jarektkaczyk/hookable/pull/31.diff
- Copy the contents
- Create a file in your project under
patches/sofa_hookable/fix_call_parent_method_on_php_8.diff
and paste the contents here. - 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"
}
}
},
- run
composer require cweagans/composer-patches
and make sure the following is added to the config block ofcomposer.json
:
"config": {
"sort-packages": true,
"allow-plugins": {
"cweagans/composer-patches": true
}
},
- run
composer update
orcomposer 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.