Skip to content

Fix callParent method on php 8#31

Open
electrotumbao wants to merge 1 commit into
jarektkaczyk:masterfrom
clickclickdrive:master
Open

Fix callParent method on php 8#31
electrotumbao wants to merge 1 commit into
jarektkaczyk:masterfrom
clickclickdrive:master

Conversation

@electrotumbao

Copy link
Copy Markdown

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
Copy Markdown

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

@JimmyBastos

Copy link
Copy Markdown

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

@oksim14

oksim14 commented Jun 16, 2022

Copy link
Copy Markdown

Hello, is there a version for php 8 yet?

@ballet-mecanique

Copy link
Copy Markdown

@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
Copy Markdown

@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
Copy Markdown

@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

maqduni commented Apr 6, 2023

Copy link
Copy Markdown

I use composer's patches to apply the fixes.

@ballet-mecanique

Copy link
Copy Markdown

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

@maqduni

maqduni commented Apr 6, 2023

Copy link
Copy Markdown

@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

edoniti commented Jun 19, 2023

Copy link
Copy Markdown

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

@ballet-mecanique

ballet-mecanique commented Aug 19, 2023

Copy link
Copy Markdown

@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

ballet-mecanique commented Aug 19, 2023

Copy link
Copy Markdown

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