1 | <?php |
||
2 | declare(strict_types = 1); |
||
3 | |||
4 | namespace Innmind\Immutable; |
||
5 | |||
6 | use Innmind\Immutable\Either\{ |
||
7 | Implementation, |
||
8 | Left, |
||
9 | Right, |
||
10 | }; |
||
11 | |||
12 | /** |
||
13 | * @template L |
||
14 | * @template R |
||
15 | * @psalm-immutable |
||
16 | */ |
||
17 | final class Either |
||
18 | { |
||
19 | /** @var Implementation<L, R> */ |
||
20 | private Implementation $either; |
||
21 | |||
22 | /** |
||
23 | * @param Implementation<L, R> $either |
||
24 | */ |
||
25 | private function __construct(Implementation $either) |
||
26 | { |
||
27 | $this->either = $either; |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * @template A |
||
32 | * @template B |
||
33 | * @psalm-pure |
||
34 | * |
||
35 | * @param A $value |
||
36 | * |
||
37 | * @return self<A, B> |
||
38 | */ |
||
39 | public static function left($value): self |
||
40 | { |
||
41 | return new self(new Left($value)); |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * @template A |
||
46 | * @template B |
||
47 | * @psalm-pure |
||
48 | * |
||
49 | * @param B $value |
||
0 ignored issues
–
show
|
|||
50 | * |
||
51 | * @return self<A, B> |
||
52 | */ |
||
53 | public static function right($value): self |
||
54 | { |
||
55 | return new self(new Right($value)); |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * @template T |
||
60 | * |
||
61 | * @param callable(R): T $map |
||
62 | * |
||
63 | * @return self<L, T> |
||
64 | */ |
||
65 | public function map(callable $map): self |
||
66 | { |
||
67 | return new self($this->either->map($map)); |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * @template A |
||
72 | * @template B |
||
73 | * |
||
74 | * @param callable(R): Either<A, B> $map |
||
75 | * |
||
76 | * @return Either<L|A, B> |
||
77 | */ |
||
78 | public function flatMap(callable $map): self |
||
79 | { |
||
80 | return $this->either->flatMap($map); |
||
81 | } |
||
82 | |||
83 | /** |
||
84 | * @template T |
||
85 | * |
||
86 | * @param callable(L): T $map |
||
87 | * |
||
88 | * @return self<T, R> |
||
89 | */ |
||
90 | public function leftMap(callable $map): self |
||
91 | { |
||
92 | return new self($this->either->leftMap($map)); |
||
93 | } |
||
94 | |||
95 | /** |
||
96 | * @template T |
||
97 | * |
||
98 | * @param callable(R): T $right |
||
99 | * @param callable(L): T $left |
||
100 | * |
||
101 | * @return T |
||
0 ignored issues
–
show
The type
Innmind\Immutable\T was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
102 | */ |
||
103 | public function match(callable $right, callable $left) |
||
104 | { |
||
105 | return $this->either->match($right, $left); |
||
106 | } |
||
107 | |||
108 | /** |
||
109 | * @template A |
||
110 | * @template B |
||
111 | * |
||
112 | * @param callable(L): Either<A, B> $otherwise |
||
113 | * |
||
114 | * @return Either<A, R|B> |
||
115 | */ |
||
116 | public function otherwise(callable $otherwise): self |
||
117 | { |
||
118 | return $this->either->otherwise($otherwise); |
||
119 | } |
||
120 | |||
121 | /** |
||
122 | * @template A |
||
123 | * |
||
124 | * @param callable(R): bool $predicate |
||
125 | * @param callable(): A $otherwise |
||
126 | * |
||
127 | * @return self<L|A, R> |
||
128 | */ |
||
129 | public function filter(callable $predicate, callable $otherwise): self |
||
130 | { |
||
131 | return new self($this->either->filter($predicate, $otherwise)); |
||
132 | } |
||
133 | |||
134 | /** |
||
135 | * @return Maybe<R> |
||
136 | */ |
||
137 | public function maybe(): Maybe |
||
138 | { |
||
139 | return $this->either->maybe(); |
||
140 | } |
||
141 | } |
||
142 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths