Skip to content

Add more precise type info for stubs #6005

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

Conversation

kocsismate
Copy link
Member

@kocsismate kocsismate commented Aug 17, 2020

This PR tries to move a bunch of type info from PHPDoc to actual declaration, while fixing a few related things.

After this PR, most of the type info will be added as a declaration, except for:

  • lots of resource types, which we shouldn't worry about
  • a few array|string, array|string|null and array|string|int types
  • a few array|int types
  • a few string|int types
  • quite a few GMP|int|bool|string types in ext/gmp
  • a few callable types in ext/session and ext/xml
  • a few funky types, like callable|int, scalar, types where multiple classes are involved

@kocsismate kocsismate changed the title Add more precise type info for ArrayAccess methods Add more precise type info for stubs Aug 19, 2020
@@ -227,7 +226,7 @@ function numfmt_parse_currency(NumberFormatter $fmt, string $value, &$currency,
/** @param int|float $value */
function numfmt_set_attribute(NumberFormatter $fmt, int $attr, $value): bool {}

function numfmt_get_attribute(NumberFormatter $fmt, int $attr): int|double|false {}
function numfmt_get_attribute(NumberFormatter $fmt, int $attr): int|float|false {}
Copy link
Member Author

Choose a reason for hiding this comment

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

ouch

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should check against this in gen_stub?

@kocsismate kocsismate force-pushed the array-access-stub branch 4 times, most recently from 62102b4 to 90da7d4 Compare August 19, 2020 12:22
@kocsismate kocsismate force-pushed the array-access-stub branch 2 times, most recently from 9bc84f1 to c74a8fe Compare August 31, 2020 21:37
@@ -227,7 +226,7 @@ function numfmt_parse_currency(NumberFormatter $fmt, string $value, &$currency,
/** @param int|float $value */
function numfmt_set_attribute(NumberFormatter $fmt, int $attr, $value): bool {}

function numfmt_get_attribute(NumberFormatter $fmt, int $attr): int|double|false {}
function numfmt_get_attribute(NumberFormatter $fmt, int $attr): int|float|false {}
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should check against this in gen_stub?

Z_PARAM_ZVAL(value)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(timeout)
Z_PARAM_LONG(retries)
Copy link
Member

Choose a reason for hiding this comment

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

omfg

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I had a similar feeling when migrating this code to the new ZPP :D

Copy link
Member

Choose a reason for hiding this comment

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

From the docs (emphasis mine): "snmp3_set() is used to set the value of an SNMP object specified by the object_id."

@@ -57,20 +47,19 @@ public function getIteratorMode() {}
public function offsetExists($index) {}
Copy link
Member

Choose a reason for hiding this comment

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

Wanted to say that these should have an int type now, but ... gah, we can't :(

@php-pulls php-pulls closed this in f7fbc63 Sep 1, 2020
@kocsismate kocsismate deleted the array-access-stub branch September 1, 2020 14:39
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