Skip to content

Commit 2bbad83

Browse files
cs278ondrejmirtes
authored andcommitted
Fix type definition of curl "certinfo" array
1 parent 0f4b760 commit 2bbad83

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/Type/Php/CurlGetinfoFunctionDynamicReturnTypeExtension.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
6666
$falseType = new ConstantBooleanType(false);
6767
$stringFalseType = TypeCombinator::union($stringType, $falseType);
6868
$integerStringArrayType = new ArrayType($integerType, $stringType);
69-
$nestedIntegerStringArrayType = new ArrayType($integerType, $integerStringArrayType);
69+
$nestedStringStringArrayType = new ArrayType($integerType, new ArrayType($stringType, $stringType));
7070

7171
$componentTypesPairedConstants = [
7272
'CURLINFO_EFFECTIVE_URL' => $stringType,
@@ -105,7 +105,7 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
105105
'CURLINFO_COOKIELIST' => $integerStringArrayType,
106106
'CURLINFO_FTP_ENTRY_PATH' => $stringFalseType,
107107
'CURLINFO_APPCONNECT_TIME' => $floatType,
108-
'CURLINFO_CERTINFO' => $nestedIntegerStringArrayType,
108+
'CURLINFO_CERTINFO' => $nestedStringStringArrayType,
109109
'CURLINFO_CONDITION_UNMET' => $integerType,
110110
'CURLINFO_RTSP_CLIENT_CSEQ' => $integerType,
111111
'CURLINFO_RTSP_CSEQ_RECV' => $integerType,
@@ -158,7 +158,7 @@ private function createAllComponentsReturnType(): Type
158158
$integerType = new IntegerType();
159159
$floatType = new FloatType();
160160
$stringOrNullType = TypeCombinator::union($stringType, new NullType());
161-
$integerStringArrayType = new ArrayType($integerType, $stringType);
161+
$nestedStringStringArrayType = new ArrayType($integerType, new ArrayType($stringType, $stringType));
162162

163163
$componentTypesPairedStrings = [
164164
'url' => $stringType,
@@ -183,7 +183,7 @@ private function createAllComponentsReturnType(): Type
183183
'redirect_time' => $floatType,
184184
'redirect_url' => $stringType,
185185
'primary_ip' => $stringType,
186-
'certinfo' => $integerStringArrayType,
186+
'certinfo' => $nestedStringStringArrayType,
187187
'primary_port' => $integerType,
188188
'local_ip' => $stringType,
189189
'local_port' => $integerType,

tests/PHPStan/Analyser/data/curl_getinfo.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ public function bar()
1414
assertType('mixed', CURL_GETINFO());
1515
assertType('mixed', CuRl_GeTiNfO());
1616
assertType('false', curl_getinfo($handle, 'Invalid Argument'));
17-
assertType('(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: array<int, string>, primary_port: int, local_ip: string, local_port: int, http_version: int, protocol: int, ssl_verifyresult: int, scheme: string}|false)', curl_getinfo($handle, PHP_INT_MAX));
18-
assertType('(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: array<int, string>, primary_port: int, local_ip: string, local_port: int, http_version: int, protocol: int, ssl_verifyresult: int, scheme: string}|false)', curl_getinfo($handle, PHP_EOL));
19-
assertType('(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: array<int, string>, primary_port: int, local_ip: string, local_port: int, http_version: int, protocol: int, ssl_verifyresult: int, scheme: string}|false)', curl_getinfo($handle));
20-
assertType('(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: array<int, string>, primary_port: int, local_ip: string, local_port: int, http_version: int, protocol: int, ssl_verifyresult: int, scheme: string}|false)', curl_getinfo($handle, null));
17+
assertType('(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: array<int, array<string, string>>, primary_port: int, local_ip: string, local_port: int, http_version: int, protocol: int, ssl_verifyresult: int, scheme: string}|false)', curl_getinfo($handle, PHP_INT_MAX));
18+
assertType('(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: array<int, array<string, string>>, primary_port: int, local_ip: string, local_port: int, http_version: int, protocol: int, ssl_verifyresult: int, scheme: string}|false)', curl_getinfo($handle, PHP_EOL));
19+
assertType('(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: array<int, array<string, string>>, primary_port: int, local_ip: string, local_port: int, http_version: int, protocol: int, ssl_verifyresult: int, scheme: string}|false)', curl_getinfo($handle));
20+
assertType('(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: array<int, array<string, string>>, primary_port: int, local_ip: string, local_port: int, http_version: int, protocol: int, ssl_verifyresult: int, scheme: string}|false)', curl_getinfo($handle, null));
2121
assertType('string', curl_getinfo($handle, CURLINFO_EFFECTIVE_URL));
2222
assertType('string', curl_getinfo($handle, 1048577)); // CURLINFO_EFFECTIVE_URL int value without using constant
2323
assertType('false', curl_getinfo($handle, 12345678)); // Non constant non CURLINFO_* int value
@@ -56,7 +56,7 @@ public function bar()
5656
assertType('array<int, string>', curl_getinfo($handle, CURLINFO_COOKIELIST));
5757
assertType('string|false', curl_getinfo($handle, CURLINFO_FTP_ENTRY_PATH));
5858
assertType('float', curl_getinfo($handle, CURLINFO_APPCONNECT_TIME));
59-
assertType('array<int, array<int, string>>', curl_getinfo($handle, CURLINFO_CERTINFO));
59+
assertType('array<int, array<string, string>>', curl_getinfo($handle, CURLINFO_CERTINFO));
6060
assertType('int', curl_getinfo($handle, CURLINFO_CONDITION_UNMET));
6161
assertType('int', curl_getinfo($handle, CURLINFO_RTSP_CLIENT_CSEQ));
6262
assertType('int', curl_getinfo($handle, CURLINFO_RTSP_CSEQ_RECV));

0 commit comments

Comments
 (0)