Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/Reflection/ParametersAcceptorSelector.php
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,6 @@ private static function getCurlOptValueType(int $curlOpt): ?Type
}

$nullableStringConstants = [
'CURLOPT_ACCEPT_ENCODING',
'CURLOPT_CUSTOMREQUEST',
'CURLOPT_DNS_INTERFACE',
'CURLOPT_DNS_LOCAL_IP4',
Expand Down Expand Up @@ -1032,7 +1031,7 @@ private static function getCurlOptValueType(int $curlOpt): ?Type

$stringConstants = [
'CURLOPT_COOKIEFILE',
'CURLOPT_ENCODING',
'CURLOPT_ENCODING', // Alias: CURLOPT_ACCEPT_ENCODING
'CURLOPT_PRE_PROXY',
'CURLOPT_PRIVATE',
'CURLOPT_PROXY',
Expand Down
26 changes: 17 additions & 9 deletions tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1321,40 +1321,48 @@ public function testCurlSetOpt(): void
18,
],
[
'Parameter #3 $value of function curl_setopt expects bool, int given.',
'Parameter #3 $value of function curl_setopt expects string, int given.',
19,
],
[
'Parameter #3 $value of function curl_setopt expects string, int given.',
20,
],
[
'Parameter #3 $value of function curl_setopt expects bool, int given.',
22,
],
[
'Parameter #3 $value of function curl_setopt expects bool, string given.',
21,
23,
],
[
'Parameter #3 $value of function curl_setopt expects int, string given.',
23,
25,
],
[
'Parameter #3 $value of function curl_setopt expects array, string given.',
25,
27,
],
[
'Parameter #3 $value of function curl_setopt expects resource, string given.',
27,
29,
],
[
'Parameter #3 $value of function curl_setopt expects array|string, int given.',
29,
31,
],
[
'Parameter #3 $value of function curl_setopt expects non-empty-string, \'\' given.',
31,
33,
],
[
'Parameter #3 $value of function curl_setopt expects non-empty-string|null, \'\' given.',
32,
34,
],
[
'Parameter #3 $value of function curl_setopt expects array<int, string>, array<string, string> given.',
73,
77,
],
]);
}
Expand Down
4 changes: 4 additions & 0 deletions tests/PHPStan/Rules/Functions/data/curl_setopt.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public function errors(int $i, string $s) {
curl_setopt($curl, CURLOPT_URL, $i);
curl_setopt($curl, CURLOPT_HTTPHEADER, $i);
curl_setopt($curl, CURLOPT_ABSTRACT_UNIX_SOCKET, null);
curl_setopt($curl, CURLOPT_ENCODING, $i);
curl_setopt($curl, CURLOPT_ACCEPT_ENCODING, $i);
// expecting bool
curl_setopt($curl, CURLOPT_AUTOREFERER, $i);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, $s);
Expand Down Expand Up @@ -62,6 +64,8 @@ public function allGood(string $url, array $header) {
curl_setopt($curl, CURLOPT_PRE_PROXY, '');
curl_setopt($curl, CURLOPT_PROXY, '');
curl_setopt($curl, CURLOPT_PRIVATE, '');
curl_setopt($curl, CURLOPT_ENCODING, '');
curl_setopt($curl, CURLOPT_ACCEPT_ENCODING, '');
}

public function bug9263() {
Expand Down
Loading