Skip to content

Conversation

@TimWolla
Copy link
Member

It is becoming increasingly common to have enum parameters on internal functions. Manually turning the singleton enum object into the case name is verbose, especially for optional parameters.

Add a new Z_PARAM_ENUM_NAME() helper to directly retrieve the case name.

It is becoming increasingly common to have enum parameters on internal
functions. Manually turning the singleton enum object into the case name is
verbose, especially for optional parameters.

Add a new `Z_PARAM_ENUM_NAME()` helper to directly retrieve the case name.
Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

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

Makes sense to me. Just a few questions regarding const qualifiers.

php_random_randomizer *randomizer = Z_RANDOM_RANDOMIZER_P(ZEND_THIS);
double min, max;
zend_object *bounds = NULL;
zend_string *bounds = NULL;
Copy link
Member

Choose a reason for hiding this comment

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

Why not mark this as const as you did with other usages?

Suggested change
zend_string *bounds = NULL;
const zend_string *bounds = NULL;

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably related to the order of replacements I made some file reminded me that this could be const. I'll fix this up before merging.

PHP_FUNCTION(pcntl_setqos_class)
{
zval *qos_obj;
zend_string *qos;
Copy link
Member

Choose a reason for hiding this comment

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

Ditto

Suggested change
zend_string *qos;
const zend_string *qos;

Copy link
Member

@ndossche ndossche left a comment

Choose a reason for hiding this comment

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

No further remarks from my side. This is nicer.
I wonder whether we should also add the _OR_NULL & _EX variants etc.

@TimWolla
Copy link
Member Author

I wonder whether we should also add the _OR_NULL

I feel that a nullable enum is something that is rarely needed, since the "null case" could just be part of the enum with a proper name.

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.

3 participants