-
-
Notifications
You must be signed in to change notification settings - Fork 934
Closed
phpstan/phpstan-src
#1170Labels
Milestone
Description
Bug report
As of PHPStan 1.5.0 and 1.5.1, the return type on curl_getinfo($ch, CURLINFO_CONTENT_TYPE) seems to string even though false will be returned when the header is not present.
I did glance at the PR that added the dynamic types and the author seems to have intended to handle this case. It was not immediately clear to me why it wasn't working.
Code snippet that reproduces the problem
For instance, the following code results in an error:
$contentType = curl_getinfo($curl, \CURLINFO_CONTENT_TYPE);
return [
$statusCode,
($contentType === false ? null : $contentType),
...
]See this link.
Output:
------ -------------------------------------------------------------------------------------
Line src/WebService/Http/CurlRequest.php
------ -------------------------------------------------------------------------------------
132 Strict comparison using === between string and false will always evaluate to false.
------ -------------------------------------------------------------------------------------
Expected output
I expect no output from this code.
Did PHPStan help you today? Did it make you happy in any way?
PHPStan is extremely helpful in finding issues without running and testing the code.