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 CURLOPT_POSTFIELDS #1777

Closed
wants to merge 2 commits into from

Conversation

VincentLanglet
Copy link
Contributor

@VincentLanglet VincentLanglet commented Sep 30, 2022

Closes #8065

Should I target 1.8.x (bugfix) or 1.9.x (since it's maybe the next release ?)

@@ -515,6 +515,10 @@ private static function getCurlOptValueType(int $curlOpt): ?Type
return new UnionType([new ConstantIntegerType(0), new ConstantIntegerType(2)]);
}

if (defined('CURLOPT_POSTFIELDS') && $curlOpt === CURLOPT_SSL_VERIFYHOST) {
return new UnionType([new StringType(), new ArrayType(new MixedType(), new MixedType())]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can the array key/value types be more precise then mixed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Honestly, I dunno.

Doc say

The full data to post in a HTTP "POST" operation. This parameter can either be passed as a urlencoded string like 'para1=val1&para2=val2&...' or as an array with the field name as key and field data as value. If value is an array, the Content-Type header will be set to multipart/form-data. Files can be sent using [CURLFile](https://www.php.net/manual/en/class.curlfile.php) or [CURLStringFile](https://www.php.net/manual/en/class.curlstringfile.php), in which case value must be an array.

So, value can be string, arrays, but maybe others things...

And keys, it's string. But I'm kinda worried bout the int keys.

$a[0] = 'foo';
$a[1] = 'bar';

which could be considered as '0=foo&1=bar'. (since '0' key would still be casted to int...)

Copy link
Member

@ondrejmirtes ondrejmirtes left a comment

Choose a reason for hiding this comment

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

1.8.x base branch is correct.

@@ -515,6 +515,10 @@ private static function getCurlOptValueType(int $curlOpt): ?Type
return new UnionType([new ConstantIntegerType(0), new ConstantIntegerType(2)]);
}

if (defined('CURLOPT_POSTFIELDS') && $curlOpt === CURLOPT_SSL_VERIFYHOST) {
Copy link
Member

Choose a reason for hiding this comment

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

Copy paste error most likely here. Would be nice to verify also when a wrong type is passed when setting CURLOPT_POSTFIELDS.

@ondrejmirtes
Copy link
Member

Superseded by #1782

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants