Skip to content

Commit 7fce581

Browse files
committed
qa: patch psalm issues which came up after upgrade
Signed-off-by: Maximilian Bösing <[email protected]>
1 parent 9f62c92 commit 7fce581

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

src/Array_.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ public function first()
5353
throw new OutOfBoundsException('There are no values available.');
5454
}
5555

56-
return reset($this->data);
56+
$data = $this->data;
57+
58+
return reset($data);
5759
}
5860

5961
public function last()
@@ -62,7 +64,9 @@ public function last()
6264
throw new OutOfBoundsException('There are no values available.');
6365
}
6466

65-
return end($this->data);
67+
$data = $this->data;
68+
69+
return end($data);
6670
}
6771

6872
public function isEmpty(): bool

src/Map.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public function intersect(MapInterface $other, callable|null $valueComparator =
201201
*/
202202
private function intersection(MapInterface $other, callable|null $valueComparator, callable|null $keyComparator): array
203203
{
204-
if ($valueComparator && $keyComparator) {
204+
if ($valueComparator !== null && $keyComparator !== null) {
205205
/**
206206
* @psalm-var array<TKey,TValue> $intersection
207207
* @psalm-suppress ImpureFunctionCall Upstream projects have to ensure that they do not manipulate the
@@ -217,7 +217,7 @@ private function intersection(MapInterface $other, callable|null $valueComparato
217217
return $intersection;
218218
}
219219

220-
if ($keyComparator) {
220+
if ($keyComparator !== null) {
221221
/**
222222
* @psalm-var array<TKey,TValue> $intersection
223223
* @psalm-suppress ImpureFunctionCall Upstream projects have to ensure that they do not manipulate the
@@ -228,7 +228,7 @@ private function intersection(MapInterface $other, callable|null $valueComparato
228228
return $intersection;
229229
}
230230

231-
if (! $valueComparator) {
231+
if ($valueComparator === null) {
232232
$valueComparator = $this->valueComparator();
233233
}
234234

src/OrderedList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ public function unify(
240240
try {
241241
$unique = $unified->get($identifier);
242242

243-
if ($callback) {
243+
if ($callback !== null) {
244244
/**
245245
* @psalm-suppress ImpureFunctionCall Upstream projects have to ensure that they do not manipulate the
246246
* value here.

tests/GenericOrderedListTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@
2121
use function array_fill;
2222
use function array_map;
2323
use function array_reverse;
24-
use function assert;
2524
use function chr;
2625
use function in_array;
27-
use function is_int;
2826
use function json_encode;
2927
use function md5;
3028
use function mt_rand;
@@ -562,7 +560,6 @@ public function testCallbackOnDeduplicationIsOnlyCalledForDuplicates(): void
562560

563561
$list->unify(null, function (int $duplicate, int $number) use (&$callbackCalled): int {
564562
self::assertEquals($duplicate, $number);
565-
assert(is_int($callbackCalled));
566563
$callbackCalled++;
567564

568565
return $number;
@@ -1250,6 +1247,7 @@ public function testForAllIsExecutedForAllEntries(): void
12501247
]);
12511248

12521249
$callable = new CallableObject(['bar', 0], ['baz', 1], ['ooq', 2]);
1250+
/** @psalm-suppress PossiblyInvalidArgument */
12531251
$list->forAll($callable)->execute();
12541252
}
12551253

@@ -1410,7 +1408,6 @@ public function testWillFindIndexOfFirstMatchingItem(): void
14101408
1000,
14111409
]);
14121410

1413-
/** @psalm-suppress TypeDoesNotContainType Might be a psalm bug */
14141411
self::assertSame(1, $list->findFirstMatchingIndex(fn (int $value) => $value % 10 === 0));
14151412
}
14161413

0 commit comments

Comments
 (0)