1 | <?php |
||
2 | declare(strict_types = 1); |
||
3 | |||
4 | namespace Properties\Innmind\Immutable\Monoid; |
||
5 | |||
6 | use Innmind\BlackBox\{ |
||
7 | Set, |
||
8 | Property, |
||
9 | }; |
||
10 | use PHPUnit\Framework\Assert; |
||
11 | |||
12 | /** |
||
13 | * @template T |
||
14 | */ |
||
15 | final class Identity implements Property |
||
16 | { |
||
17 | /** @var T */ |
||
0 ignored issues
–
show
|
|||
18 | private mixed $value; |
||
19 | /** @var callable(T, T): bool */ |
||
20 | private $equals; |
||
21 | |||
22 | /** |
||
23 | * @param T $value |
||
24 | * @param callable(T, T): bool $equals |
||
25 | */ |
||
26 | public function __construct(mixed $value, callable $equals) |
||
27 | { |
||
28 | $this->value = $value; |
||
29 | $this->equals = $equals; |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * @template A |
||
34 | * |
||
35 | * @param Set<A> $values |
||
36 | * @param callable(A, A): bool $equals |
||
37 | * |
||
38 | * @return Set<self<A>> |
||
39 | */ |
||
40 | public static function any(Set $values, callable $equals): Set |
||
41 | { |
||
42 | return Set\Decorate::immutable( |
||
43 | static fn($value) => new self($value, $equals), |
||
44 | $values, |
||
45 | ); |
||
46 | } |
||
47 | |||
48 | public function name(): string |
||
49 | { |
||
50 | return 'Identity value has no effect on the combined value'; |
||
51 | } |
||
52 | |||
53 | public function applicableTo(object $monoid): bool |
||
54 | { |
||
55 | return true; |
||
56 | } |
||
57 | |||
58 | public function ensureHeldBy(object $monoid): object |
||
59 | { |
||
60 | Assert::assertTrue(($this->equals)( |
||
61 | $monoid->identity(), |
||
62 | $monoid->identity(), |
||
63 | )); |
||
64 | Assert::assertTrue(($this->equals)( |
||
65 | $this->value, |
||
66 | $monoid->combine($monoid->identity(), $this->value), |
||
67 | )); |
||
68 | Assert::assertTrue(($this->equals)( |
||
69 | $this->value, |
||
70 | $monoid->combine($this->value, $monoid->identity()), |
||
71 | )); |
||
72 | // make sure the identiy is not altered after using a concrete value |
||
73 | Assert::assertTrue(($this->equals)( |
||
74 | $monoid->identity(), |
||
75 | $monoid->identity(), |
||
76 | )); |
||
77 | |||
78 | return $monoid; |
||
79 | } |
||
80 | } |
||
81 |
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