Skip to content

add some stubs for array func in basic_functions #4519

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

Conversation

jason-liew
Copy link
Contributor

add stubs for array sort funcs in basic_functions

@cmb69
Copy link
Member

cmb69 commented Aug 11, 2019

I think it's better to stick with the existing arginfo parameter names.

@@ -60,6 +60,24 @@ function stream_wrapper_restore(string $protocol): bool {}
/** @return int|false */
function array_push(array &$stack, ...$args) {}

function krsort(array &$stack, int $sort_flags = PHP_SORT_REGULAR): bool {}
Copy link
Contributor

Choose a reason for hiding this comment

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

We can't typehint reference arguments. See #4501 (comment).

Copy link
Member

Choose a reason for hiding this comment

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

Well, krsort() expects an array on entry, so in this case the type declaration should be fine.


function count(mixed $array, int $mode = COUNT_NORAML): bool {}

function natsort(array &$stack){}
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing return type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry, add void return type.


function natsort(array &$stack){}

function natcasesort(array &$stack){}
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing return type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry, add void return type.


function ksort(array &$stack, int $sort_flags = PHP_SORT_REGULAR): bool {}

function count(mixed $array, int $mode = COUNT_NORAML): bool {}
Copy link
Member

Choose a reason for hiding this comment

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

mixed is not a valid type hint, moreover doesn't this need a doc comment @param array|Countable $array ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry, I've add doc comment @param array|Countable.

@@ -66,9 +66,9 @@ function ksort(array &$stack, int $sort_flags = PHP_SORT_REGULAR): bool {}

function count(mixed $array, int $mode = COUNT_NORAML): bool {}

function natsort(array &$stack){}
function natsort(array &$stack): void {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is ir void or bool?

Copy link
Member

Choose a reason for hiding this comment

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

It is bool, but actually only TRUE will ever be returned. It might be sensible to change it to void, but that would be a BC break.

Copy link
Contributor

Choose a reason for hiding this comment

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

@cmb69 Yeah, this goes to our list at https://bugs.php.net/bug.php?id=75958

@cmb69
Copy link
Member

cmb69 commented Aug 12, 2019

Please have a look at the test failures.

@cmb69
Copy link
Member

cmb69 commented Aug 12, 2019

The test are failing because of #4519 (comment)

@jason-liew
Copy link
Contributor Author

The test are failing because of #4519 (comment)

thanks, I find a fail case in ext/reflection in ci log .

@jason-liew jason-liew force-pushed the add-array-php-stubs branch from 1a29b0e to a829ed4 Compare August 12, 2019 17:39
@jason-liew
Copy link
Contributor Author

Please have a look at the test failures.

all test passed now, Please review again, Thanks.

@@ -60,6 +60,25 @@ function stream_wrapper_restore(string $protocol): bool {}
/** @return int|false */
function array_push(array &$stack, ...$args) {}

function krsort(array &$arg, int $sort_flags = PHP_SORT_REGULAR): bool {}
Copy link
Member

Choose a reason for hiding this comment

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

PHP_SORT_REGULAR is a C macro; its PHP pendant is SORT_REGULAR. I'm taking the liberty to fix that myself. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it. Thanks.

@cmb69
Copy link
Member

cmb69 commented Aug 14, 2019

Thanks. Applied as ffffaf1.

@cmb69 cmb69 closed this Aug 14, 2019
@jason-liew jason-liew deleted the add-array-php-stubs branch August 14, 2019 14:37
@cmb69 cmb69 added Stubs and removed Feature labels Aug 19, 2019
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.

4 participants