Skip to content

Conversation

@spawnia
Copy link
Contributor

@spawnia spawnia commented Jan 2, 2022

Resolves phpstan/phpstan#6288

Thanks to @herndlm

Copy link
Contributor

@simPod simPod left a comment

Choose a reason for hiding this comment

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

I think we will need to also change

public function getTypeFromFunctionCall(
to merge the types.

But it might be tricky because of

Note: If replacement is not an array, it will be typecast to one (i.e. (array) $replacement). This may result in unexpected behavior when using an object or null replacement.

@herndlm
Copy link
Contributor

herndlm commented Jan 2, 2022

I think we will need to also change

public function getTypeFromFunctionCall(

to merge the types.

I'm not sure if this is related to this PR. At least it reads and looks like it already ignores $replacement completely right now, which is not really correct yes, see https://phpstan.org/r/347cf306-c06c-462b-9daf-af41b2380da7. So it could be improved, but maybe in a follow-up?

Well, let's see what Ondrej says :)

@ondrejmirtes ondrejmirtes merged commit 13e1257 into phpstan:master Feb 1, 2022
@ondrejmirtes
Copy link
Member

Thank you!

Anyone, feel free to send an update to the array_splice dynamic return type extension so that it reads the replacement argument :)

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.

Parameter #4 $replacement of function array_splice expects array|string

4 participants