-
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
PHP 8 support? Named parameter $whatever overwrites previous argument #209
Comments
I've found what I think is a great description of the problem at https://www.drupal.org/project/rules/issues/3210303#comment-14070697 .. essentially Tonic is overloading the 'params' member of Request with both integer-indexed entries and named entries, which then causes For example in my simple example above, calling
The
I imagine the aim of adding the named parameter as well as the integer-indexed one is to support handlers that have multiple arguments that are provided out-of-order compared to their URI, for example:
With the named parameters One solution to this would be to replace
As I'm new to this problem and don't know much about this library's history, any feedback would be great to hear. I also believe this project is unmaintained, so I may be forking it to maintain our own PHP 8 compatible version, anyone else who's done this would be good to hear from :) |
@neekfenwick, I'm also new to this library, so be skeptical :) That said, my solution is available here: #210. From my understanding named parameters were silently ignored by the call_user_func_array function before PHP8, so my solution was to simply filter out the named parameters when it's used by the call_user_func_array function. Everything else stays the same. Did you run into any unintentional side-effects with your solution, or has it run smoothly? |
My fix is working well on my PHP 8.1 development system. Since this project appears dead and I doubt any PR will be accepted, I've made a Release on my fork of the project at https://github.com/neekfenwick/tonic/releases - calling it alpha just while I test things but it's going well so far. I believe my fix is more elegant than yours, as it builds the $params array in only one way, either with numerical indices or named parameters, and I believe yours is broken, I'll feedback on your PR. |
The following GET handler works fine on PHP 7, but on PHP 8 produces a fatal Error:
The Error is raised on the line in Resource.php trying to invoke the
get
function:The error looks like:
This looks like normal PHP 8 behaviour. Would
tonic
need a rewrite to support PHP 8 or is there some simpler workaround we can employ? (or move to a completely different library)The text was updated successfully, but these errors were encountered: