1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
require_once __DIR__.'/../vendor/autoload.php'; |
6
|
|
|
|
7
|
|
|
use function Scalp\Conversion\AnyToString; |
8
|
|
|
use function Scalp\PatternMatching\match; |
9
|
|
|
use function Scalp\PatternMatching\Any; |
|
|
|
|
10
|
|
|
use function Scalp\PatternMatching\Value; |
|
|
|
|
11
|
|
|
use function Scalp\PatternMatching\Type; |
|
|
|
|
12
|
|
|
use function Scalp\concat; |
|
|
|
|
13
|
|
|
use function Scalp\println; |
|
|
|
|
14
|
|
|
use function Scalp\Some; |
15
|
|
|
use function Scalp\Pair; |
|
|
|
|
16
|
|
|
use Scalp\None; |
17
|
|
|
use Scalp\Some; |
18
|
|
|
use Scalp\Tuple; |
19
|
|
|
|
20
|
|
|
function returnString(string $s): callable |
21
|
|
|
{ |
22
|
|
|
return function () use ($s): string { |
23
|
|
|
return $s; |
24
|
|
|
}; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
$res0 = match(42) |
28
|
|
|
->case(Any(), function (): string { return 'Anything'; }) |
29
|
|
|
->done(); |
30
|
|
|
|
31
|
|
|
println($res0); |
32
|
|
|
|
33
|
|
|
$res1 = match(Some(42)) |
34
|
|
|
->case(Any(), function (): string { return 'Anything'; }) |
35
|
|
|
->done(); |
36
|
|
|
|
37
|
|
|
println($res1); |
38
|
|
|
|
39
|
|
|
$res2 = match(42) |
40
|
|
|
->case(Value(13), function (): string { return 'Number 13'; }) |
41
|
|
|
->case(Value('42'), function (): string { return 'String "42"'; }) |
42
|
|
|
->case(Value(42), function (): string { return 'Number 42'; }) |
43
|
|
|
->case(Any(), function (): string { return 'Fallback'; }) |
44
|
|
|
->done(); |
45
|
|
|
|
46
|
|
|
println($res2); |
47
|
|
|
|
48
|
|
|
$res3 = match(Some(42)) |
49
|
|
|
->case(Value(Some(13)), function (): string { return 'Some 13'; }) |
50
|
|
|
->case(Value(Some(42)), function (): string { return 'Some 42'; }) |
51
|
|
|
->case(Any(), function (): string { return 'Fallback'; }) |
52
|
|
|
->done(); |
53
|
|
|
|
54
|
|
|
println($res3); |
55
|
|
|
|
56
|
|
|
$res4 = match(Some(42)) |
57
|
|
|
->case(Value(Some(13)), function (): string { return 'Some 13'; }) |
58
|
|
|
->case(Value(Some('42')), function (): string { return 'Some 42'; }) |
59
|
|
|
->case(Any(), function (): string { return 'Fallback'; }) |
60
|
|
|
->done(); |
61
|
|
|
|
62
|
|
|
println($res4); |
63
|
|
|
|
64
|
|
|
$res5 = match(42) |
65
|
|
|
->case(Type('string'), function (): string { return 'String'; }) |
|
|
|
|
66
|
|
|
->case(Type('integer'), function (): string { return 'Integer'; }) |
|
|
|
|
67
|
|
|
->case(Any(), function (): string { return 'Not integer'; }) |
68
|
|
|
->done(); |
69
|
|
|
|
70
|
|
|
println($res5); |
71
|
|
|
|
72
|
|
|
$res6 = match(Some(42)) |
73
|
|
|
->case(Type(None::class), function (): string { return 'None'; }) |
74
|
|
|
->case(Type(Some::class), function (): string { return 'Some'; }) |
75
|
|
|
->case(Any(), function (): string { return 'Neither'; }) |
76
|
|
|
->done(); |
77
|
|
|
|
78
|
|
|
println($res6); |
79
|
|
|
|
80
|
|
|
$res7 = match(Some(42)) |
81
|
|
|
->case(Type(Some::class, Value('42')), returnString('Inner value is string')) |
|
|
|
|
82
|
|
|
->case(Type(Some::class, Value(42)), returnString('Inner value is integer')) |
83
|
|
|
->case(Any(), returnString('Fallback')) |
84
|
|
|
->done(); |
85
|
|
|
|
86
|
|
|
println($res7); |
87
|
|
|
|
88
|
|
|
$res8 = match(Pair('2 * 7 = ', 14)) |
89
|
|
|
->case( |
90
|
|
|
Type(Tuple::class, Any()->bind(), Any()->bind()), |
91
|
|
|
function (string $question, int $answer): string { return concat('Solution: ', $question, AnyToString($answer)); } |
92
|
|
|
) |
93
|
|
|
->case(Any(), returnString('Fallback')) |
94
|
|
|
->done(); |
95
|
|
|
|
96
|
|
|
println($res8); |
97
|
|
|
|
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