Skip to content

Commit 7b4662d

Browse files
committed
fixed psalm typing issues
1 parent 1e591c4 commit 7b4662d

File tree

4 files changed

+19
-20
lines changed

4 files changed

+19
-20
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM php:8.0-cli
1+
FROM php:7.4-cli
22
RUN apt-get update && apt-get install -y \
33
libfreetype6-dev \
44
libjpeg62-turbo-dev \

src/Types/CypherMap.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -180,22 +180,19 @@ public function values(): CypherList
180180
/**
181181
* Creates a new map using exclusive or on the keys.
182182
*
183-
* @param iterable<TValue> $map
183+
* @param iterable<array-key, TValue> $map
184184
*
185185
* @return CypherMap<TValue>
186186
*/
187187
public function xor(iterable $map): CypherMap
188188
{
189189
$tbr = $this->sequence;
190190

191-
/**
192-
* @var mixed $key
193-
*/
194191
foreach ($map as $key => $value) {
195192
if (array_key_exists($key, $this->sequence)) {
196-
unset($tbr[$key]);
193+
unset($tbr[(string) $key]);
197194
} else {
198-
$tbr[$key] = $value;
195+
$tbr[(string) $key] = $value;
199196
}
200197
}
201198

@@ -265,13 +262,13 @@ public function intersect(iterable $map): self
265262
*
266263
* @return CypherMap<TValue>
267264
*/
268-
public function diff($map): CypherMap
265+
public function diff(iterable $map): CypherMap
269266
{
270267
$tbr = $this->sequence;
271268

272269
/** @psalm-suppress UnusedForeachValue */
273270
foreach ($map as $key => $value) {
274-
unset($tbr[$key]);
271+
unset($tbr[(string) $key]);
275272
}
276273

277274
return new self($tbr);

tests/Unit/CypherListTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
final class CypherListTest extends TestCase
2424
{
25+
/** @var CypherList<string> */
2526
private CypherList $list;
2627

2728
public function setUp(): void
@@ -343,7 +344,7 @@ public function testSortedDefault(): void
343344

344345
public function testSortedCustom(): void
345346
{
346-
$sorted = $this->list->sorted(static fn (string $x, $y) => -1 * ($x <=> $y));
347+
$sorted = $this->list->sorted(static fn (string $x, string $y): int => -1 * ($x <=> $y));
347348

348349
self::assertEquals(new CypherList(['C', 'B', 'A']), $sorted);
349350
self::assertEquals(new CypherList(['A', 'B', 'C']), $this->list);

tests/Unit/CypherMapTest.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
final class CypherMapTest extends TestCase
2929
{
30+
/** @var CypherMap<string> */
3031
private CypherMap $map;
3132

3233
public function setUp(): void
@@ -341,11 +342,11 @@ public function testJoinEmpty(): void
341342

342343
public function testDiff(): void
343344
{
344-
$subtract = new CypherMap(['B' => null, 'Z' => 'z']);
345+
$subtract = new CypherMap(['B' => 'x', 'Z' => 'z']);
345346
$result = $this->map->diff($subtract);
346347

347348
self::assertEquals(new CypherMap(['A' => 'x', 'C' => 'z']), $result);
348-
self::assertEquals(new CypherMap(['B' => null, 'Z' => 'z']), $subtract);
349+
self::assertEquals(new CypherMap(['B' => 'x', 'Z' => 'z']), $subtract);
349350
self::assertEquals(new CypherMap(['A' => 'x', 'B' => 'y', 'C' => 'z']), $this->map);
350351
}
351352

@@ -356,31 +357,31 @@ public function testDiffEmpty(): void
356357

357358
public function testIntersect(): void
358359
{
359-
$intersect = new CypherMap(['B' => null, 'Z' => 'z']);
360+
$intersect = new CypherMap(['B' => 'x', 'Z' => 'z']);
360361
$result = $this->map->intersect($intersect);
361362

362363
self::assertEquals(new CypherMap(['B' => 'y']), $result);
363-
self::assertEquals(new CypherMap(['B' => null, 'Z' => 'z']), $intersect);
364+
self::assertEquals(new CypherMap(['B' => 'x', 'Z' => 'z']), $intersect);
364365
self::assertEquals(new CypherMap(['A' => 'x', 'B' => 'y', 'C' => 'z']), $this->map);
365366
}
366367

367368
public function testUnion(): void
368369
{
369-
$intersect = new CypherMap(['B' => null, 'Z' => 'z']);
370+
$intersect = new CypherMap(['B' => 'x', 'Z' => 'z']);
370371
$result = $this->map->union($intersect);
371372

372373
self::assertEquals(new CypherMap(['A' => 'x', 'B' => 'y', 'C' => 'z', 'Z' => 'z']), $result);
373-
self::assertEquals(new CypherMap(['B' => null, 'Z' => 'z']), $intersect);
374+
self::assertEquals(new CypherMap(['B' => 'x', 'Z' => 'z']), $intersect);
374375
self::assertEquals(new CypherMap(['A' => 'x', 'B' => 'y', 'C' => 'z']), $this->map);
375376
}
376377

377378
public function testXor(): void
378379
{
379-
$intersect = new CypherMap(['B' => null, 'Z' => 'z']);
380+
$intersect = new CypherMap(['B' => 'x', 'Z' => 'z']);
380381
$result = $this->map->xor($intersect);
381382

382383
self::assertEquals(new CypherMap(['A' => 'x', 'C' => 'z', 'Z' => 'z']), $result);
383-
self::assertEquals(new CypherMap(['B' => null, 'Z' => 'z']), $intersect);
384+
self::assertEquals(new CypherMap(['B' => 'x', 'Z' => 'z']), $intersect);
384385
self::assertEquals(new CypherMap(['A' => 'x', 'B' => 'y', 'C' => 'z']), $this->map);
385386
}
386387

@@ -435,7 +436,7 @@ public function testSortedDefault(): void
435436

436437
public function testSortedCustom(): void
437438
{
438-
$sorted = $this->map->sorted(static fn (string $x, $y) => -1 * ($x <=> $y));
439+
$sorted = $this->map->sorted(static fn (string $x, string $y): int => -1 * ($x <=> $y));
439440

440441
self::assertEquals(new CypherMap(['C' => 'z', 'B' => 'y', 'A' => 'x']), $sorted);
441442
self::assertEquals(new CypherMap(['A' => 'x', 'B' => 'y', 'C' => 'z']), $this->map);
@@ -449,7 +450,7 @@ public function testKSorted(): void
449450

450451
public function testKSortedCustom(): void
451452
{
452-
$sorted = $this->map->ksorted(static fn (string $x, $y) => -1 * ($x <=> $y));
453+
$sorted = $this->map->ksorted(static fn (string $x, string $y) => -1 * ($x <=> $y));
453454

454455
self::assertEquals(new CypherMap(['C' => 'z', 'B' => 'y', 'A' => 'x']), $sorted);
455456
self::assertEquals(new CypherMap(['A' => 'x', 'B' => 'y', 'C' => 'z']), $this->map);

0 commit comments

Comments
 (0)