-
Notifications
You must be signed in to change notification settings - Fork 8k
tree-wide: Replace ZEND_WRONG_PARAM_COUNT()
by its definition
#20066
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
base: master
Are you sure you want to change the base?
Conversation
This is a direct alias.
This macro was hiding control flow (the return statement) and thus was particularly unhygienic.
ext/gd/gd.c
Outdated
if (ZEND_NUM_ARGS() < 2 || ZEND_NUM_ARGS() > IMAGE_FILTER_MAX_ARGS) { | ||
WRONG_PARAM_COUNT; | ||
zend_wrong_param_count(); | ||
RETURN_THROWS(); | ||
} else if (zend_parse_parameters(2, "Ol", &tmp, gd_image_ce, &filtertype) == FAILURE) { | ||
RETURN_THROWS(); | ||
} | ||
|
||
if (filtertype >= 0 && filtertype <= IMAGE_FILTER_MAX) { | ||
filters[filtertype](INTERNAL_FUNCTION_PARAM_PASSTHRU); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we actually need this? Can't we not just have the else if
branch, and then the filters handling the "too many" args case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #20158
@Girgias I also considered improving the error messages, but I'm not really familiar with all the extensions and I also wanted to avoid combining the internal cleanup with a behavioral change. Especially when the API needs this function, it is not great in the first place, so I feel improving the error message is a little like polishing a turd. So I just did the mechanical change that allowed to clean up zend_API 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should do that.
This macro is simple enough and properly abstracts what it does.
I don't mind a rename/alias to RETURN_WRONG_PARAM_COUNT(); or similar, if you want to indicate the control flow as part of the macro.
It feels odd that this specific exception-throwing function (which is already very rarely needed and will be needed even more rarely once Gina's PRs ship) is special-cased by having a macro that implies the return when all other exception-throwing functions don't. |
This macro was hiding control flow (the return statement) and thus was particularly unhygienic.