Skip to content

Add more accurate types to stubs again #6068

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 2 commits into from

Conversation

kocsismate
Copy link
Member

No description provided.

@@ -1221,8 +1221,8 @@ static zend_always_inline zval *zend_try_array_init(zval *zv)
_(Z_EXPECTED_DOUBLE_OR_NULL, "of type ?float") \
_(Z_EXPECTED_NUMBER, "of type int|float") \
_(Z_EXPECTED_NUMBER_OR_NULL, "of type int|float|null") \
_(Z_EXPECTED_STRING_OR_ARRAY, "of type string|array") \
_(Z_EXPECTED_STRING_OR_ARRAY_OR_NULL, "of type string|array|null") \
_(Z_EXPECTED_STRING_OR_ARRAY, "of type array|string") \
Copy link
Member Author

Choose a reason for hiding this comment

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

So that we use the canonical form. I'll carve out these changes to a separate commit.

@kocsismate kocsismate force-pushed the more-accurate-types3 branch 2 times, most recently from 66dc599 to c4dce3b Compare September 3, 2020 15:12
Copy link
Member

@nikic nikic left a comment

Choose a reason for hiding this comment

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

I'm a bit concerned that we don't have snmp in CI -- not even as an "it builds" check.

@kocsismate
Copy link
Member Author

I'm a bit concerned that we don't have snmp in CI -- not even as an "it builds" check.

Oh gosh, I didn't know it :/ But! I could compile snmp (actually, there was a warning about an unused variable). Unfortunately, I could only run a function reflection test, which was failing - but instead of fixing it, I rather removed it.

@kocsismate kocsismate force-pushed the more-accurate-types3 branch 2 times, most recently from 9540d95 to c6a712d Compare September 3, 2020 20:35
@@ -1577,6 +1580,23 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
#define Z_PARAM_OBJECT_OR_NULL(dest) \
Z_PARAM_OBJECT_EX(dest, 1, 0)

#define Z_PARAM_OBJ_EX2(dest, check_null, deref, separate) \
Copy link
Member Author

Choose a reason for hiding this comment

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

I added a Z_PARAM_OBJ which uses the zend_object type, rather than zval. If it was a bad idea, I can revert it, but I felt that it would help the previous efforts to migrate our APIs from zvals to zend_object.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe add a comment above it, so it's obvious what the difference is?

@kocsismate
Copy link
Member Author

kocsismate commented Sep 3, 2020

Now, there is only a handful of functions remaining which have a parameter for which a native type could/might be worth to add with a relatively small effort:

  • array|int type:
    • filter_input(), filter_var(), filter_input_array(), filter_var_array() ($options)
    • PDO::setAttribute() ($value)
    • session_set_cookie_params() ($lifetime_or_options)
  • class-of-type|int type:
    • DatePeriod::__construct() ($interval)
    • datefmt_create() ($calendar)
    • datefmt_set_calendar() ($which)
    • IntlDateFormatter::__construct() ($calendar)

Is it really worth to add a ZPP macro for them? If so, I'll create a one last PR for migrating custom type checks to ZPP.

@cmb69
Copy link
Member

cmb69 commented Sep 3, 2020

I'm a bit concerned that we don't have snmp in CI -- not even as an "it builds" check.

It's built on AppVeyor at least, if I'm not mistaken. I worked a bit on the test suite months ago (Debian), but it is still partially broken, because it depends on certain data files in certain locations. Would be really good to have some maintainer for ext/snmp.

@@ -1577,6 +1580,23 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
#define Z_PARAM_OBJECT_OR_NULL(dest) \
Z_PARAM_OBJECT_EX(dest, 1, 0)

#define Z_PARAM_OBJ_EX2(dest, check_null, deref, separate) \
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add a comment above it, so it's obvious what the difference is?

static const php_password_algo* php_password_algo_find_zval(zval *arg) {
return php_password_algo_find_zval_ex(arg, php_password_algo_default());
static const php_password_algo* php_password_algo_find_zval(zend_string *arg_str, zend_long arg_long, zend_bool arg_is_null) {
return php_password_algo_find_zval_ex(arg_str, arg_long, arg_is_null, php_password_algo_default());
Copy link
Member

Choose a reason for hiding this comment

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

php_password_algo_find_zval_ex is used only here, I'd inline it.

Copy link
Member Author

Choose a reason for hiding this comment

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

All done!

@php-pulls php-pulls closed this in 8107a1d Sep 4, 2020
@kocsismate kocsismate deleted the more-accurate-types3 branch September 4, 2020 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants