Skip to content
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

Fix return type of array_reverse() with optional keys #3406

Conversation

herndlm
Copy link
Contributor

@herndlm herndlm commented Sep 5, 2024

Fixes phpstan/phpstan#11549

We cannot simply reverse indices and values for arrays with optional keys and preserve_keys=false. In that case the array has to be re-built to account for the optional keys properly.

fyi @tscni and thanks for the nice example / test case :)

@herndlm herndlm marked this pull request as draft September 5, 2024 21:40
@herndlm herndlm marked this pull request as ready for review September 5, 2024 21:42
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@herndlm herndlm marked this pull request as draft September 6, 2024 09:23
@herndlm herndlm force-pushed the fix-constant-array-reverse-with-optional-keys branch from b38f709 to 61ccc70 Compare October 6, 2024 17:56
@herndlm herndlm marked this pull request as ready for review October 6, 2024 17:56
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@ondrejmirtes ondrejmirtes merged commit 2e65472 into phpstan:1.12.x Oct 7, 2024
471 of 500 checks passed
@ondrejmirtes
Copy link
Member

Thank you.

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