Skip to content

Fix type for CURLOPT_POSTFIELDS#1777

Closed
VincentLanglet wants to merge 2 commits intophpstan:1.8.xfrom
VincentLanglet:fixCurl
Closed

Fix type for CURLOPT_POSTFIELDS#1777
VincentLanglet wants to merge 2 commits intophpstan:1.8.xfrom
VincentLanglet:fixCurl

Conversation

@VincentLanglet
Copy link
Copy Markdown
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 ?)

}

if (defined('CURLOPT_POSTFIELDS') && $curlOpt === CURLOPT_SSL_VERIFYHOST) {
return new UnionType([new StringType(), new ArrayType(new MixedType(), new MixedType())]);
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

return new UnionType([new ConstantIntegerType(0), new ConstantIntegerType(2)]);
}

if (defined('CURLOPT_POSTFIELDS') && $curlOpt === CURLOPT_SSL_VERIFYHOST) {
Copy link
Copy Markdown
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
Copy Markdown
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

Development

Successfully merging this pull request may close these issues.

3 participants