Skip to content

Commit 98cfa72

Browse files
committed
Fix psalm regression
1 parent dcd309e commit 98cfa72

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

tests/Runtime/Classes/Either/EitherTest.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,22 @@ public function testCreation(): void
4545

4646
public function testMap(): void
4747
{
48-
$right = Either::right(1)
48+
/** @var Either<int, int> $right */
49+
$right = Either::right(1);
50+
51+
$mappedRight = $right
4952
->map(fn(int $s) => $s + 1)
5053
->map(fn(int $s) => $s + 1);
5154

52-
$left = Either::left(1)
55+
/** @var Either<int, int> $left */
56+
$left = Either::left(1);
57+
58+
$mappedLeft = $left
5359
->map(fn(int $s) => $s + 1)
5460
->map(fn(int $s) => $s + 1);
5561

56-
$this->assertEquals(3, $right->get());
57-
$this->assertEquals(1, $left->get());
62+
$this->assertEquals(3, $mappedRight->get());
63+
$this->assertEquals(1, $mappedLeft->get());
5864
}
5965

6066
public function testMapN(): void
@@ -280,12 +286,18 @@ public function testTryWithFallback(): void
280286

281287
public function testFold(): void
282288
{
283-
$foldRight = Either::right(1)->fold(
289+
/** @var Either<string, int> $right */
290+
$right = Either::right(1);
291+
292+
$foldRight = $right->fold(
284293
fn() => 0,
285294
fn(int $some) => $some + 1,
286295
);
287296

288-
$foldLeft = Either::left('err')->fold(
297+
/** @var Either<string, int> $left */
298+
$left = Either::left('err');
299+
300+
$foldLeft = $left->fold(
289301
fn() => 0,
290302
fn(int $some) => $some + 1,
291303
);

tests/Runtime/Classes/Option/OptionTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,18 @@ public function testTry(): void
122122

123123
public function testFold(): void
124124
{
125-
$foldSome = Option::some(1)->fold(
125+
/** @var Option<int> $some */
126+
$some = Option::some(1);
127+
128+
$foldSome = $some->fold(
126129
fn() => 0,
127130
fn(int $some) => $some + 1,
128131
);
129132

130-
$foldNone = Option::none()->fold(
133+
/** @var Option<int> $none */
134+
$none = Option::none();
135+
136+
$foldNone = $none->fold(
131137
fn() => 0,
132138
fn(int $some) => $some + 1,
133139
);

0 commit comments

Comments
 (0)