Skip to content

Commit 69a0c98

Browse files
committed
Add CURLINFO_SIZE_DELIVERED and the size_delivered key to curl_getinfo() return types
Closes phpstan/phpstan#15371
1 parent 0e156a6 commit 69a0c98

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

‎src/Type/Php/CurlGetinfoFunctionDynamicReturnTypeExtension.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
147147
'CURLINFO_HTTPAUTH_USED' => $integerFalseType,
148148
'CURLINFO_PROXYAUTH_USED' => $integerFalseType,
149149
'CURLINFO_CONN_ID' => $integerFalseType,
150+
'CURLINFO_SIZE_DELIVERED' => $integerFalseType,
150151
];
151152

152153
foreach ($componentTypesPairedConstants as $constantName => $type) {
@@ -193,6 +194,7 @@ private function createAllComponentsReturnType(): Type
193194
'pretransfer_time' => $floatType,
194195
'size_upload' => $floatType,
195196
'size_download' => $floatType,
197+
'size_delivered' => $integerType,
196198
'speed_download' => $floatType,
197199
'speed_upload' => $floatType,
198200
'download_content_length' => $floatType,

‎tests/PHPStan/Analyser/nsrt/curl_getinfo.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Foo
99
{
1010
public function bar()
1111
{
12-
$curlGetInfoType = '(array{url: string, content_type: string|null, http_code: int, header_size: int, request_size: int, filetime: int, ssl_verify_result: int, redirect_count: int, total_time: float, namelookup_time: float, connect_time: float, pretransfer_time: float, size_upload: float, size_download: float, speed_download: float, speed_upload: float, download_content_length: float, upload_content_length: float, starttransfer_time: float, redirect_time: float, redirect_url: string, primary_ip: string, certinfo: list<array<string, string>>, primary_port: int, local_ip: string, local_port: int, http_version: int, protocol: int, ssl_verifyresult: int, scheme: string, appconnect_time_us: int, queue_time_us: int, connect_time_us: int, namelookup_time_us: int, pretransfer_time_us: int, redirect_time_us: int, starttransfer_time_us: int, posttransfer_time_us: int, total_time_us: int, request_header: string, effective_method: string, capath: string, cainfo: string, used_proxy: int, httpauth_used: int, proxyauth_used: int, conn_id: int}|false)';
12+
$curlGetInfoType = '(array{url: string, content_type: string|null, http_code: int, header_size: int, request_size: int, filetime: int, ssl_verify_result: int, redirect_count: int, total_time: float, namelookup_time: float, connect_time: float, pretransfer_time: float, size_upload: float, size_download: float, size_delivered: int, speed_download: float, speed_upload: float, download_content_length: float, upload_content_length: float, starttransfer_time: float, redirect_time: float, redirect_url: string, primary_ip: string, certinfo: list<array<string, string>>, primary_port: int, local_ip: string, local_port: int, http_version: int, protocol: int, ssl_verifyresult: int, scheme: string, appconnect_time_us: int, queue_time_us: int, connect_time_us: int, namelookup_time_us: int, pretransfer_time_us: int, redirect_time_us: int, starttransfer_time_us: int, posttransfer_time_us: int, total_time_us: int, request_header: string, effective_method: string, capath: string, cainfo: string, used_proxy: int, httpauth_used: int, proxyauth_used: int, conn_id: int}|false)';
1313

1414
$handle = new CurlHandle();
1515
assertType('mixed', curl_getinfo());
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php // lint >= 8.6
2+
3+
namespace CurlGetinfo86;
4+
5+
use CurlHandle;
6+
use function PHPStan\Testing\assertType;
7+
8+
class Foo
9+
{
10+
public function bar()
11+
{
12+
$handle = new CurlHandle();
13+
assertType('int|false', curl_getinfo($handle, CURLINFO_SIZE_DELIVERED));
14+
}
15+
}

0 commit comments

Comments
 (0)