-
Notifications
You must be signed in to change notification settings - Fork 127
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 PHP8 call_user_func_array breaking change #210
Conversation
Beginning with PHP 8, "args keys will now be interpreted as parameter names, instead of being silently ignored." https://www.php.net/manual/en/function.call-user-func-array.php This solution effectively ignores named parameters in PHP8 by filtering out any named parameters. Not ideal, but it seems to work -- open to better ideas!
I think this is broken for named parameters that appear out of order. As I recall, the original code might take a uri like [ What you've done is reduce this array of params to: [ and then pass it to the handler function, but you've lost the ability to name the parameters, and if the handler function has them in a different order to how they appear in the URI, they will be passed to the wrong parameter. For example:
Note that the function takes
My fix at https://github.com/neekfenwick/tonic/tree/v3.4-alpha/src/Tonic does not have this problem. As this project appears dead I have not bothered creating a PR. If we get any feedback from @peej or anyone with write permissions to this repo, I'll think about making one, but until then forking seems the way to go. |
@neekfenwick, thank you for this thorough explanation! I agree -- your solution is superior. |
I did have to run a test to check I was correct :) Are you thinking of using my repo? I'm not sure how 'official' to try to make it. For now I'm happy with a |
@PBillodeau this PR is still Open, are you going to close it? |
@neekfenwick thanks for the reminder! PR closed. Right now I have our project setup to apply the patch you created using https://github.com/cweagans/composer-patches. |
Ah, good stuff :) I'll probably make an official Release from my forked repo soon as we're probably rolling out my latest work tomorrow. Do you have any other patches you're applying that I should be aware of that might be useful adding to my repo? |
Beginning with PHP 8, "args keys will now be interpreted as parameter names, instead of being silently ignored." https://www.php.net/manual/en/function.call-user-func-array.php
This solution effectively ignores named parameters in PHP8 by filtering out any named parameters. Not ideal, but it seems to work -- open to better ideas!