Skip to content

Commit 6f6ca72

Browse files
authored
Merge pull request #38 from Innmind/fix-psalm-errors
Fix psalm errors
2 parents 35a9eba + 93bd94a commit 6f6ca72

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+435
-2
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
}
3131
},
3232
"require-dev": {
33-
"innmind/static-analysis": "~1.1",
33+
"innmind/static-analysis": "^1.2.1",
3434
"innmind/black-box": "^5.5.1",
3535
"innmind/coding-standard": "~2.0"
3636
},

src/Accumulate.php

+5
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public function __construct(\Generator $generator)
3131
/**
3232
* @return S
3333
*/
34+
#[\Override]
3435
public function current(): mixed
3536
{
3637
/** @psalm-suppress InaccessibleProperty */
@@ -45,6 +46,7 @@ public function current(): mixed
4546
/**
4647
* @return int<0, max>|null
4748
*/
49+
#[\Override]
4850
public function key(): ?int
4951
{
5052
/** @psalm-suppress InaccessibleProperty */
@@ -55,6 +57,7 @@ public function key(): ?int
5557
return \key($this->values);
5658
}
5759

60+
#[\Override]
5861
public function next(): void
5962
{
6063
/** @psalm-suppress InaccessibleProperty */
@@ -68,6 +71,7 @@ public function next(): void
6871
}
6972
}
7073

74+
#[\Override]
7175
public function rewind(): void
7276
{
7377
/** @psalm-suppress InaccessibleProperty */
@@ -76,6 +80,7 @@ public function rewind(): void
7680
\reset($this->values);
7781
}
7882

83+
#[\Override]
7984
public function valid(): bool
8085
{
8186
/** @psalm-suppress InaccessibleProperty */

src/Attempt/Defer.php

+7
Original file line numberDiff line numberDiff line change
@@ -30,39 +30,45 @@ public function __construct(callable $deferred)
3030
$this->deferred = $deferred;
3131
}
3232

33+
#[\Override]
3334
public function map(callable $map): self
3435
{
3536
$captured = $this->capture();
3637

3738
return new self(static fn() => self::detonate($captured)->map($map));
3839
}
3940

41+
#[\Override]
4042
public function flatMap(callable $map): Attempt
4143
{
4244
$captured = $this->capture();
4345

4446
return Attempt::defer(static fn() => self::detonate($captured)->flatMap($map));
4547
}
4648

49+
#[\Override]
4750
public function match(callable $result, callable $error)
4851
{
4952
return $this->unwrap()->match($result, $error);
5053
}
5154

55+
#[\Override]
5256
public function recover(callable $recover): Attempt
5357
{
5458
$captured = $this->capture();
5559

5660
return Attempt::defer(static fn() => self::detonate($captured)->recover($recover));
5761
}
5862

63+
#[\Override]
5964
public function maybe(): Maybe
6065
{
6166
$captured = $this->capture();
6267

6368
return Maybe::defer(static fn() => self::detonate($captured)->maybe());
6469
}
6570

71+
#[\Override]
6672
public function either(): Either
6773
{
6874
$captured = $this->capture();
@@ -73,6 +79,7 @@ public function either(): Either
7379
/**
7480
* @return Attempt<R1>
7581
*/
82+
#[\Override]
7683
public function memoize(): Attempt
7784
{
7885
return $this->unwrap();

src/Attempt/Error.php

+7
Original file line numberDiff line numberDiff line change
@@ -29,34 +29,40 @@ public function __construct(
2929
*
3030
* @return self<T>
3131
*/
32+
#[\Override]
3233
public function map(callable $map): self
3334
{
3435
/** @var self<T> */
3536
return $this;
3637
}
3738

39+
#[\Override]
3840
public function flatMap(callable $map): Attempt
3941
{
4042
return Attempt::error($this->value);
4143
}
4244

45+
#[\Override]
4346
public function match(callable $result, callable $error)
4447
{
4548
/** @psalm-suppress ImpureFunctionCall */
4649
return $error($this->value);
4750
}
4851

52+
#[\Override]
4953
public function recover(callable $recover): Attempt
5054
{
5155
/** @psalm-suppress ImpureFunctionCall */
5256
return $recover($this->value);
5357
}
5458

59+
#[\Override]
5560
public function maybe(): Maybe
5661
{
5762
return Maybe::nothing();
5863
}
5964

65+
#[\Override]
6066
public function either(): Either
6167
{
6268
return Either::left($this->value);
@@ -65,6 +71,7 @@ public function either(): Either
6571
/**
6672
* @return Attempt<R1>
6773
*/
74+
#[\Override]
6875
public function memoize(): Attempt
6976
{
7077
return Attempt::error($this->value);

src/Attempt/Result.php

+7
Original file line numberDiff line numberDiff line change
@@ -25,34 +25,40 @@ public function __construct(
2525
) {
2626
}
2727

28+
#[\Override]
2829
public function map(callable $map): self
2930
{
3031
/** @psalm-suppress ImpureFunctionCall */
3132
return new self($map($this->value));
3233
}
3334

35+
#[\Override]
3436
public function flatMap(callable $map): Attempt
3537
{
3638
/** @psalm-suppress ImpureFunctionCall */
3739
return $map($this->value);
3840
}
3941

42+
#[\Override]
4043
public function match(callable $result, callable $error)
4144
{
4245
/** @psalm-suppress ImpureFunctionCall */
4346
return $result($this->value);
4447
}
4548

49+
#[\Override]
4650
public function recover(callable $recover): Attempt
4751
{
4852
return Attempt::result($this->value);
4953
}
5054

55+
#[\Override]
5156
public function maybe(): Maybe
5257
{
5358
return Maybe::just($this->value);
5459
}
5560

61+
#[\Override]
5662
public function either(): Either
5763
{
5864
return Either::right($this->value);
@@ -61,6 +67,7 @@ public function either(): Either
6167
/**
6268
* @return Attempt<R1>
6369
*/
70+
#[\Override]
6471
public function memoize(): Attempt
6572
{
6673
return Attempt::result($this->value);

src/Either/Defer.php

+10
Original file line numberDiff line numberDiff line change
@@ -30,46 +30,53 @@ public function __construct($deferred)
3030
$this->deferred = $deferred;
3131
}
3232

33+
#[\Override]
3334
public function map(callable $map): self
3435
{
3536
$captured = $this->capture();
3637

3738
return new self(static fn() => self::detonate($captured)->map($map));
3839
}
3940

41+
#[\Override]
4042
public function flatMap(callable $map): Either
4143
{
4244
$captured = $this->capture();
4345

4446
return Either::defer(static fn() => self::detonate($captured)->flatMap($map));
4547
}
4648

49+
#[\Override]
4750
public function leftMap(callable $map): self
4851
{
4952
$captured = $this->capture();
5053

5154
return new self(static fn() => self::detonate($captured)->leftMap($map));
5255
}
5356

57+
#[\Override]
5458
public function match(callable $right, callable $left)
5559
{
5660
return $this->unwrap()->match($right, $left);
5761
}
5862

63+
#[\Override]
5964
public function otherwise(callable $otherwise): Either
6065
{
6166
$captured = $this->capture();
6267

6368
return Either::defer(static fn() => self::detonate($captured)->otherwise($otherwise));
6469
}
6570

71+
#[\Override]
6672
public function filter(callable $predicate, callable $otherwise): Implementation
6773
{
6874
$captured = $this->capture();
6975

7076
return new self(static fn() => self::detonate($captured)->filter($predicate, $otherwise));
7177
}
7278

79+
#[\Override]
7380
public function maybe(): Maybe
7481
{
7582
$captured = $this->capture();
@@ -80,18 +87,21 @@ public function maybe(): Maybe
8087
/**
8188
* @return Either<L1, R1>
8289
*/
90+
#[\Override]
8391
public function memoize(): Either
8492
{
8593
return $this->unwrap();
8694
}
8795

96+
#[\Override]
8897
public function flip(): self
8998
{
9099
$captured = $this->capture();
91100

92101
return new self(static fn() => self::detonate($captured)->flip());
93102
}
94103

104+
#[\Override]
95105
public function eitherWay(callable $right, callable $left): Either
96106
{
97107
$captured = $this->capture();

src/Either/Left.php

+10
Original file line numberDiff line numberDiff line change
@@ -35,40 +35,47 @@ public function __construct($value)
3535
*
3636
* @return self<L1, T>
3737
*/
38+
#[\Override]
3839
public function map(callable $map): self
3940
{
4041
/** @var self<L1, T> */
4142
return $this;
4243
}
4344

45+
#[\Override]
4446
public function flatMap(callable $map): Either
4547
{
4648
return Either::left($this->value);
4749
}
4850

51+
#[\Override]
4952
public function leftMap(callable $map): self
5053
{
5154
/** @psalm-suppress ImpureFunctionCall */
5255
return new self($map($this->value));
5356
}
5457

58+
#[\Override]
5559
public function match(callable $right, callable $left)
5660
{
5761
/** @psalm-suppress ImpureFunctionCall */
5862
return $left($this->value);
5963
}
6064

65+
#[\Override]
6166
public function otherwise(callable $otherwise): Either
6267
{
6368
/** @psalm-suppress ImpureFunctionCall */
6469
return $otherwise($this->value);
6570
}
6671

72+
#[\Override]
6773
public function filter(callable $predicate, callable $otherwise): self
6874
{
6975
return $this;
7076
}
7177

78+
#[\Override]
7279
public function maybe(): Maybe
7380
{
7481
return Maybe::nothing();
@@ -77,16 +84,19 @@ public function maybe(): Maybe
7784
/**
7885
* @return Either<L1, R1>
7986
*/
87+
#[\Override]
8088
public function memoize(): Either
8189
{
8290
return Either::left($this->value);
8391
}
8492

93+
#[\Override]
8594
public function flip(): Implementation
8695
{
8796
return new Right($this->value);
8897
}
8998

99+
#[\Override]
90100
public function eitherWay(callable $right, callable $left): Either
91101
{
92102
/** @psalm-suppress ImpureFunctionCall */

0 commit comments

Comments
 (0)