Skip to content

Commit 3e9b629

Browse files
oschwaldondrejmirtes
authored andcommitted
Fix curl_getinfo($ch, CURLINFO_CONTENT_TYPE)
This returns `string|false`. `false` is returned if the header is not set. I suspect some of the other dynamic types for this function are also wrong in similar cases, but I have only verified this one. Closes #6929.
1 parent bc81647 commit 3e9b629

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Type/Php/CurlGetinfoFunctionDynamicReturnTypeExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
9393
'CURLINFO_SSL_VERIFYRESULT' => $integerType,
9494
'CURLINFO_CONTENT_LENGTH_DOWNLOAD' => $floatType,
9595
'CURLINFO_CONTENT_LENGTH_UPLOAD' => $floatType,
96-
'CURLINFO_CONTENT_TYPE' => $stringType,
96+
'CURLINFO_CONTENT_TYPE' => $stringFalseType,
9797
'CURLINFO_PRIVATE' => $stringFalseType,
9898
'CURLINFO_RESPONSE_CODE' => $integerType,
9999
'CURLINFO_HTTP_CONNECTCODE' => $integerType,

tests/PHPStan/Analyser/data/curl_getinfo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function bar()
4444
assertType('int', curl_getinfo($handle, CURLINFO_SSL_VERIFYRESULT));
4545
assertType('float', curl_getinfo($handle, CURLINFO_CONTENT_LENGTH_DOWNLOAD));
4646
assertType('float', curl_getinfo($handle, CURLINFO_CONTENT_LENGTH_UPLOAD));
47-
assertType('string', curl_getinfo($handle, CURLINFO_CONTENT_TYPE));
47+
assertType('string|false', curl_getinfo($handle, CURLINFO_CONTENT_TYPE));
4848
assertType('string|false', curl_getinfo($handle, CURLINFO_PRIVATE));
4949
assertType('int', curl_getinfo($handle, CURLINFO_RESPONSE_CODE));
5050
assertType('int', curl_getinfo($handle, CURLINFO_HTTP_CONNECTCODE));

0 commit comments

Comments
 (0)