Skip to content

Conversation

herndlm
Copy link
Contributor

@herndlm herndlm commented Apr 20, 2022

Noticed that there's room to improve because of phpstan/phpstan#7068 (comment).

Improves 2 things related to variadic parameters

  • detection of "all constant arrays"
    e.g. assertType('array{17}', array_merge([], ...[[17]])); would previously be non-empty-array<0, 17>
  • detection of nonEmpty arrays
    e.g. assertType('array<int>', array_merge([], ...$bar1)); would previously be non-empty-array<int>

Still not happy about the complexity variadic and constant array param handling introduces. Maybe things could get cleaned up a bit in general via some helper utilities for such cases. I could take a look at refactoring this later I guess.

@herndlm herndlm changed the base branch from 1.6.x to 1.5.x April 20, 2022 11:22
@herndlm herndlm force-pushed the improve-variadic-param-support-in-array-merge branch from e1e79c5 to 6e919a7 Compare April 20, 2022 11:50
@ondrejmirtes ondrejmirtes merged commit 8862d57 into phpstan:1.5.x Apr 20, 2022
@ondrejmirtes
Copy link
Member

Thank you!

@herndlm herndlm deleted the improve-variadic-param-support-in-array-merge branch April 20, 2022 12:01
@herndlm
Copy link
Contributor Author

herndlm commented Apr 20, 2022

In case I start looking into extracting some of the complexity - assuming it is really a refactor and does not change behaviour, shall I open the PR against 1.5.x or 1.6.x? But it might take me a couple of days anyways, maybe over the weekend..

@ondrejmirtes
Copy link
Member

You can do it in 1.6.x, the end for 1.5.x is near anyway :)

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