Skip to content

Conversation

ahmedash95
Copy link
Contributor

@ahmedash95 ahmedash95 commented Oct 1, 2022

Hi Ondrej,

CURLOPT_POSTFIELDS accepts string or array but PHPStan reports a type error if the value is not a string
https://phpstan.org/r/db599e65-dfae-4e85-90bc-6bc96feadf96

I'm not sure about TypeCombinator::union but it's what I was able to find to achieve the fix.

closes phpstan/phpstan#8053.

Thanks.

@ahmedash95 ahmedash95 force-pushed the fix-curl-opt-postfields branch from 18d7317 to e515b25 Compare October 1, 2022 23:22
@ondrejmirtes
Copy link
Member

Hi Ahmed :) There's already #1777 but I can't merge it because of coding standards and requirements checker failures. So yours PR might be correct sooner and might win the race :)

Your PR passes but is missing any tests - it'd be nice to add tests for cases when it should pass, and at least one test for the case when the rule should report an error.

Also please base the PR on 1.8.x so it can be released sooner.

@ahmedash95 ahmedash95 changed the base branch from 1.9.x to 1.8.x October 2, 2022 09:54
@ahmedash95
Copy link
Contributor Author

Thanks for pointing out the other PR. I did not know about it because it's not mentioned in the issue.

I've added the tests and changed that base 1.8.x. I assume it's ready to be merged in case the other one is not.

@ondrejmirtes ondrejmirtes force-pushed the fix-curl-opt-postfields branch from 3e8df38 to 576edf0 Compare October 2, 2022 09:57
@ondrejmirtes ondrejmirtes merged commit 228a345 into phpstan:1.8.x Oct 2, 2022
@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.

CURLOPT_POSTFIELDS accepts also an array
2 participants