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 type for array_splice() argument $replacement #901

Merged
merged 1 commit into from Feb 1, 2022
Merged

Fix type for array_splice() argument $replacement #901

merged 1 commit into from Feb 1, 2022

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
4 participants