Skip to content

Commit 6d3f3fd

Browse files
committed
Upgrade PHPStan to version 2
- phpstan/phpstan updated from 1.12.21 to 2.1.8 major See changes: phpstan/phpstan@1.12.21...2.1.8 Release notes: https://github.com/phpstan/phpstan/releases/tag/2.1.8 `list<T>` is now distinct from `T[]` aka `array<T>`.
1 parent a623314 commit 6d3f3fd

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"friendsofphp/php-cs-fixer": "^3.0",
1313
"php-parallel-lint/php-parallel-lint": "^1.0",
1414
"symfony/phpunit-bridge": "^6.2 || ^7.0",
15-
"phpstan/phpstan": "^1.12"
15+
"phpstan/phpstan": "^2.1"
1616
},
1717
"autoload": {
1818
"psr-4": { "Fossar\\GuzzleTranscoder\\": "src/" }

src/GuzzleTranscoder.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ private function createTranscoder(): TranscoderInterface {
5252
public function convert(ResponseInterface $response): ResponseInterface {
5353
$stream = $response->getBody();
5454

55-
/** @var array<string, string[]> */
55+
/** @var array<string, list<string>> */
5656
$headers = $response->getHeaders();
5757
$result = $this->convertResponse($headers, (string) $stream);
5858
if ($result !== null) {
@@ -77,6 +77,7 @@ public function convert(ResponseInterface $response): ResponseInterface {
7777
*/
7878
public function __invoke(callable $handler): callable {
7979
return function(RequestInterface $request, array $options) use ($handler): PromiseInterface {
80+
/** @var array<string, mixed> $options */
8081
$promise = $handler($request, $options);
8182

8283
return $promise->then(fn(ResponseInterface $response): ResponseInterface => $this->convert($response));
@@ -94,9 +95,9 @@ public function __invoke(callable $handler): callable {
9495
*
9596
* Otherwise an array containing the new headers and content is returned.
9697
*
97-
* @param array<string, string[]> $headers
98+
* @param array<string, list<string>> $headers
9899
*
99-
* @return ?array{headers: array<string, string[]>, content: string}
100+
* @return ?array{headers: array<string, list<string>>, content: string}
100101
*/
101102
public function convertResponse(array $headers, string $content): ?array {
102103
$headerDeclaredEncoding = null;

src/Utils.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class Utils {
7272
* [Basic=>null, realm=>'"foo\bar"']
7373
* ["</TheBook/chapter,2>" => null, "rel" => "pre,vious", "title*" => "UTF-8'de'letztes%20Kapitel" ], ["</TheBook/chapter4>" => null, "rel" => "next", "title*" => "UTF-8'de'n%c3%a4chstes%20Kapitel" ]
7474
*
75-
* @param string[]|string $headerValues
75+
* @param list<string>|string $headerValues
7676
*
7777
* @throws \Exception
7878
*

tests/GuzzleTranscoderTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public function testConvertResponse(): void {
214214
* Gets the headers from a HTTP response as one dimensional associative array
215215
* with header names as keys. The header values will not be parsed but saved as-is!
216216
*
217-
* @return array{headers: array<string, string[]>, body: string}
217+
* @return array{headers: array<string, list<string>>, body: string}
218218
*/
219219
private function splitHeadersAndContentFromHttpResponseString(string $responseString): array {
220220
$lines = explode("\n", $responseString);

tests/ReadmeTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public function readmeExamples(): iterable {
3636
foreach ($matches as $match) {
3737
$mockedSourceBody = file_get_contents(__DIR__ . '/resources/' . $match['response']);
3838
\assert($mockedSourceBody !== false); // For PHPStan.
39+
/** @var array<string, string> $mockedHeaders */
3940
$mockedHeaders = json_decode($match['headers'], true);
40-
\assert(\is_array($mockedHeaders)); // For PHPStan.
4141
$expectedBody = file_get_contents(__DIR__ . '/resources/' . $match['expected']);
4242
\assert($expectedBody !== false); // For PHPStan.
4343

0 commit comments

Comments
 (0)