Skip to content

Use ZEND_PARSE_PARAMETERS_NONE() macro #3116

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

Closed
wants to merge 1 commit into from
Closed

Use ZEND_PARSE_PARAMETERS_NONE() macro #3116

wants to merge 1 commit into from

Conversation

carusogabriel
Copy link
Contributor

Something that I suggested to @dstogov in 6fadb72#commitcomment-27597259

Zend/zend_API.h Outdated
@@ -266,6 +266,8 @@ ZEND_API int zend_copy_parameters_array(int param_count, zval *argument_array);
#define zend_parse_parameters_none_throw() \
(EXPECTED(ZEND_NUM_ARGS() == 0) ? SUCCESS : zend_wrong_parameters_none_exception())

#define ZEND_PARSE_PARAMS_NONE() { if(ZEND_NUM_ARGS() != 0 && zend_wrong_parameters_none_error()) return; }
Copy link
Member

@nikic nikic Feb 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There already is a ZEND_PARSE_PARAMETERS_NONE() macro which does the same thing ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do need to study more C, I thought that one was different because of the do/while struct 🤦‍♂️

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@carusogabriel Function-like macros with more than one statement are usually wrapped in do/while, see https://stackoverflow.com/questions/154136/why-use-apparently-meaningless-do-while-and-if-else-statements-in-macros.

@carusogabriel carusogabriel changed the title Use ZEND_PARSE_PARAMS_NONE() macro Use ZEND_PARSE_PARAMETERS_NONE() macro Feb 19, 2018
@carusogabriel
Copy link
Contributor Author

Closing as I'll probably work in #1665

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants