Skip to content

Commit 8874d02

Browse files
committed
Improve PHPStan reporting
1 parent da5601c commit 8874d02

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

phpstan.neon

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,4 @@ parameters:
77
paths:
88
- src
99
ignoreErrors:
10-
- message: '#Method Bakame\\Http\\StructuredFields\\Parameters::merge\(\) has parameter \$others with no value type specified in iterable type iterable.#'
11-
path: src/Parameters.php
12-
- message: '#Method Bakame\\Http\\StructuredFields\\Dictionary::merge\(\) has parameter \$others with no value type specified in iterable type iterable.#'
13-
path: src/Dictionary.php
1410
reportUnmatchedIgnoredErrors: true

src/Dictionary.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ public function pair(int $index): array
203203
return $pair;
204204
}
205205
}
206+
206207
// @codeCoverageIgnoreStart
207208
throw InvalidOffset::dueToIndexNotFound($index);
208209
// @codeCoverageIgnoreEnd
@@ -284,7 +285,7 @@ public function prepend(string $key, InnerList|Item|ByteSequence|Token|bool|int|
284285
/**
285286
* Merge multiple instances.
286287
*
287-
* iterable<array-key, InnerList|Item|Token|ByteSequence|float|int|bool|string> ...$others
288+
* @param iterable<array-key, InnerList|Item|Token|ByteSequence|float|int|bool|string> ...$others
288289
*/
289290
public function merge(iterable ...$others): void
290291
{

src/Parameters.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,12 @@ public function pair(int $index): array
255255
throw InvalidOffset::dueToIndexNotFound($index);
256256
}
257257

258-
foreach ($this->toPairs() as $k => $pair) {
259-
if ($k === $offset) {
260-
return $pair;
258+
$i = 0;
259+
foreach ($this->members as $key => $member) {
260+
if ($i === $offset) {
261+
return [$key, $this->validateMember($member)];
261262
}
263+
++$i;
262264
}
263265

264266
// @codeCoverageIgnoreStart
@@ -348,7 +350,7 @@ public function prepend(string $key, Item|ByteSequence|Token|bool|int|float|stri
348350
/**
349351
* Merge multiple instances.
350352
*
351-
* iterable<array-key, Item|Token|ByteSequence|float|int|bool|string> ...$others
353+
* @param iterable<array-key, Item|Token|ByteSequence|float|int|bool|string> ...$others
352354
*/
353355
public function merge(iterable ...$others): void
354356
{

src/Parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ private static function parseItemOrInnerList(string $httpValue): array
132132
if ('(' === $httpValue[0]) {
133133
[$innerList, $offset] = self::parseInnerListValue($httpValue);
134134

135-
return [InnerList::fromList($innerList[0], $innerList[1]), $offset];
135+
return [InnerList::fromList(...$innerList), $offset];
136136
}
137137

138138
[$value, $offset] = self::parseBareItem($httpValue);

0 commit comments

Comments
 (0)