Innmind /
Immutable
| 1 | <?php |
||
| 2 | declare(strict_types = 1); |
||
| 3 | |||
| 4 | namespace Innmind\Immutable; |
||
| 5 | |||
| 6 | use Innmind\Immutable\Maybe\{ |
||
| 7 | Implementation, |
||
| 8 | Just, |
||
| 9 | Nothing, |
||
| 10 | }; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @template T |
||
| 14 | * @psalm-immutable |
||
| 15 | */ |
||
| 16 | final class Maybe |
||
| 17 | { |
||
| 18 | /** @var Implementation<T> */ |
||
| 19 | private Implementation $maybe; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @param Implementation<T> $maybe |
||
| 23 | */ |
||
| 24 | private function __construct(Implementation $maybe) |
||
| 25 | { |
||
| 26 | $this->maybe = $maybe; |
||
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @template V |
||
| 31 | * @psalm-pure |
||
| 32 | * |
||
| 33 | * @param V $value |
||
|
0 ignored issues
–
show
|
|||
| 34 | * |
||
| 35 | * @return self<V> |
||
| 36 | */ |
||
| 37 | public static function just($value): self |
||
| 38 | { |
||
| 39 | return new self(new Just($value)); |
||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @psalm-pure |
||
| 44 | */ |
||
| 45 | public static function nothing(): self |
||
| 46 | { |
||
| 47 | return new self(new Nothing); |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @template V |
||
| 52 | * @psalm-pure |
||
| 53 | * |
||
| 54 | * @param V|null $value |
||
| 55 | * |
||
| 56 | * @return self<V> |
||
| 57 | */ |
||
| 58 | public static function of($value): self |
||
| 59 | { |
||
| 60 | if (\is_null($value)) { |
||
| 61 | return self::nothing(); |
||
| 62 | } |
||
| 63 | |||
| 64 | return self::just($value); |
||
| 65 | } |
||
| 66 | |||
| 67 | /** |
||
| 68 | * The comprehension is called only when all values exist |
||
| 69 | * |
||
| 70 | * @psalm-pure |
||
| 71 | * @no-named-arguments |
||
| 72 | */ |
||
| 73 | public static function all(self $first, self ...$rest): Maybe\Comprehension |
||
| 74 | { |
||
| 75 | return Maybe\Comprehension::of($first, ...$rest); |
||
| 76 | } |
||
| 77 | |||
| 78 | /** |
||
| 79 | * @template V |
||
| 80 | * |
||
| 81 | * @param callable(T): V $map |
||
| 82 | * |
||
| 83 | * @return self<V> |
||
| 84 | */ |
||
| 85 | public function map(callable $map): self |
||
| 86 | { |
||
| 87 | return new self($this->maybe->map($map)); |
||
| 88 | } |
||
| 89 | |||
| 90 | /** |
||
| 91 | * @template V |
||
| 92 | * |
||
| 93 | * @param callable(T): Maybe<V> $map |
||
| 94 | * |
||
| 95 | * @return Maybe<V> |
||
| 96 | */ |
||
| 97 | public function flatMap(callable $map): self |
||
| 98 | { |
||
| 99 | return $this->maybe->flatMap($map); |
||
| 100 | } |
||
| 101 | |||
| 102 | /** |
||
| 103 | * @template V |
||
| 104 | * |
||
| 105 | * @param callable(T): V $just |
||
| 106 | * @param callable(): V $nothing |
||
| 107 | * |
||
| 108 | * @return V |
||
| 109 | */ |
||
| 110 | public function match(callable $just, callable $nothing) |
||
| 111 | { |
||
| 112 | return $this->maybe->match($just, $nothing); |
||
| 113 | } |
||
| 114 | |||
| 115 | /** |
||
| 116 | * @template V |
||
| 117 | * |
||
| 118 | * @param callable(): Maybe<V> $otherwise |
||
| 119 | * |
||
| 120 | * @return Maybe<T|V> |
||
| 121 | */ |
||
| 122 | public function otherwise(callable $otherwise): self |
||
| 123 | { |
||
| 124 | return $this->maybe->otherwise($otherwise); |
||
| 125 | } |
||
| 126 | |||
| 127 | /** |
||
| 128 | * @param callable(T): bool $predicate |
||
| 129 | * |
||
| 130 | * @return self<T> |
||
| 131 | */ |
||
| 132 | public function filter(callable $predicate): self |
||
| 133 | { |
||
| 134 | return new self($this->maybe->filter($predicate)); |
||
| 135 | } |
||
| 136 | } |
||
| 137 |
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