Skip to content

Correct and improve return types for sorting functions #906

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

Conversation

johnbillion
Copy link
Contributor

@johnbillion johnbillion commented Jan 3, 2022

Various corrections and improvements to array sorting functions and methods.

  • Corrects the return type of natcasesort, natsort, uasort, and uksort, these are all nullable in PHP 7
  • Narrows the return types of all the array sorting functions that now return only boolean true in PHP 8
  • Corrects the return types of various ArrayIterator, ArrayObject, and RecursiveArrayIterator methods which are currently marked as void but always return boolean true
  • Adds all of the above to the functionMetadata files to specify that they produce side effects

The reason for narrowing bool to true is to clarify that the return value of these functions cannot be used to determine success or failure, similarly to #850.

References:

Copy link
Member

@ondrejmirtes ondrejmirtes left a comment

Choose a reason for hiding this comment

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

Also please remove the merge commit (rebase cleanly on top of master).

@johnbillion johnbillion marked this pull request as ready for review January 6, 2022 19:13
@johnbillion johnbillion marked this pull request as draft February 2, 2022 23:59
@ondrejmirtes ondrejmirtes force-pushed the 1.5.x branch 3 times, most recently from ddd20b4 to 95d480b Compare March 18, 2022 19:53
@johnbillion johnbillion changed the base branch from 1.5.x to 1.7.x May 15, 2022 20:26
@johnbillion
Copy link
Contributor Author

These changes are breaking a large number of tests and I'm not familiar enough with the internals of PHPStan to know why. Closing this off, would be great if someone else could pick it up though.

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.

2 participants