Skip to content
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.0 | Hooks::dispatch(): prevent potential fatal error #599

Merged
merged 2 commits into from
Nov 10, 2021

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Nov 7, 2021

PHP 8.0 | Hooks::dispatch(): prevent potential fatal error

This commit adds a safeguard on the off-chance that the Hooks::dispatch() method would ever be called with an associative array for the parameters.

This prevents a potential fatal Unknown named parameter ... error in PHP 8.x.

Includes unit test.

Related to #533

🆕 Hooks::dispatch(): modernize dynamic function call

... by replacing the call_user_func_array() with a variable function call in combination with the spread operator.

Includes adding a dedicated test to safeguard that this change does not break the handling of references when passed as part of the $parameters to dispatch.

@jrfnl jrfnl added this to the 2.0.0 milestone Nov 7, 2021
@jrfnl jrfnl requested a review from schlessera November 7, 2021 00:22
@jrfnl jrfnl mentioned this pull request Nov 7, 2021
14 tasks
src/Hooks.php Outdated Show resolved Hide resolved
This commit adds a safeguard on the off-chance that the `Hooks::dispatch()` method would ever be called with an associative array for the parameters.

This prevents a potential fatal `Unknown named parameter ...` error in PHP 8.x.

Includes unit test.
@jrfnl jrfnl force-pushed the feature/php-8.0-named-params-call-user-func-array branch from 90dae9b to 7d5014d Compare November 8, 2021 11:17
... by replacing the `call_user_func_array()` with a variable function call in combination with the spread operator.

Includes adding a dedicated test to safeguard that this change does not break the handling of references when passed as part of the `$parameters` to dispatch.
@jrfnl jrfnl force-pushed the feature/php-8.0-named-params-call-user-func-array branch from 7d5014d to 5926bb1 Compare November 10, 2021 13:33
@jrfnl
Copy link
Member Author

jrfnl commented Nov 10, 2021

FYI: re-pushed commit has no functional changes, just added the $message parameter to the assertions as there are multiple assertions in the testDispatchHandlesParametersPassedByReference() test.

@schlessera schlessera merged commit ffcd411 into develop Nov 10, 2021
@schlessera schlessera deleted the feature/php-8.0-named-params-call-user-func-array branch November 10, 2021 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants