@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Scalp\PatternMatching\Pattern; |
6 | 6 |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Scalp\PatternMatching\Pattern; |
6 | 6 |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Scalp\PatternMatching\Pattern; |
6 | 6 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Scalp\PatternMatching\Exception; |
6 | 6 | |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | final class PatternMatchingSubjectNotFound extends \RuntimeException |
10 | 10 | { |
11 | - public static function for($x): PatternMatchingSubjectNotFound |
|
11 | + public static function for ($x): PatternMatchingSubjectNotFound |
|
12 | 12 | { |
13 | 13 | return new self('Pattern matching subject "'.AnyToString($x).'" is not defined in this match expression".'); |
14 | 14 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Scalp\PatternMatching\Exception; |
6 | 6 |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | require_once __DIR__.'/../vendor/autoload.php'; |
6 | 6 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Scalp\PatternMatching\Pattern; |
6 | 6 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | ->filter(papply(isInstanceOfType, __, $this->type)); |
38 | 38 | |
39 | 39 | if ($typeMatch->isEmpty() || empty($this->patterns)) { |
40 | - return $typeMatch->flatMap(function (): Option { return Some([]); }); |
|
40 | + return $typeMatch->flatMap(function(): Option { return Some([]); }); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** @var TryCatch $caseClass */ |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | ); |
50 | 50 | |
51 | 51 | return $caseClass |
52 | - ->map(function (CaseClass $cc): array { return $cc->deconstruct(); }) |
|
52 | + ->map(function(CaseClass $cc): array { return $cc->deconstruct(); }) |
|
53 | 53 | ->map(papply(\Closure::fromCallable([$this, 'applyConstructorArgumentsPatterns']), type($x), __, $this->patterns)) |
54 | 54 | ->get(); |
55 | 55 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | require_once __DIR__.'/../vendor/autoload.php'; |
6 | 6 | |
@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | function tupleName(Tuple $tuple): string |
14 | 14 | { |
15 | 15 | return match($tuple) |
16 | - ->case(Type(Tuple::class, Any()), function () { return 'Singleton'; }) |
|
17 | - ->case(Type(Tuple::class, Any(), Any()), function () { return 'Pair'; }) |
|
18 | - ->case(Type(Tuple::class, Any(), Any(), Any()), function () { return 'Triple'; }) |
|
19 | - ->case(Type(Tuple::class), function () { return 'Other tuple'; }) |
|
16 | + ->case(Type(Tuple::class, Any()), function() { return 'Singleton'; }) |
|
17 | + ->case(Type(Tuple::class, Any(), Any()), function() { return 'Pair'; }) |
|
18 | + ->case(Type(Tuple::class, Any(), Any(), Any()), function() { return 'Triple'; }) |
|
19 | + ->case(Type(Tuple::class), function() { return 'Other tuple'; }) |
|
20 | 20 | ->done(); |
21 | 21 | } |
22 | 22 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | require_once __DIR__.'/../vendor/autoload.php'; |
6 | 6 | |
@@ -18,60 +18,60 @@ discard block |
||
18 | 18 | |
19 | 19 | function returnString(string $s): callable |
20 | 20 | { |
21 | - return function () use ($s): string { |
|
21 | + return function() use ($s): string { |
|
22 | 22 | return $s; |
23 | 23 | }; |
24 | 24 | } |
25 | 25 | |
26 | 26 | $res0 = match(42) |
27 | - ->case(Any(), function (): string { return 'Anything'; }) |
|
27 | + ->case(Any(), function(): string { return 'Anything'; }) |
|
28 | 28 | ->done(); |
29 | 29 | |
30 | 30 | println($res0); |
31 | 31 | |
32 | 32 | $res1 = match(Some(42)) |
33 | - ->case(Any(), function (): string { return 'Anything'; }) |
|
33 | + ->case(Any(), function(): string { return 'Anything'; }) |
|
34 | 34 | ->done(); |
35 | 35 | |
36 | 36 | println($res1); |
37 | 37 | |
38 | 38 | $res2 = match(42) |
39 | - ->case(Value(13), function (): string { return 'Number 13'; }) |
|
40 | - ->case(Value('42'), function (): string { return 'String "42"'; }) |
|
41 | - ->case(Value(42), function (): string { return 'Number 42'; }) |
|
42 | - ->case(Any(), function (): string { return 'Fallback'; }) |
|
39 | + ->case(Value(13), function(): string { return 'Number 13'; }) |
|
40 | + ->case(Value('42'), function(): string { return 'String "42"'; }) |
|
41 | + ->case(Value(42), function(): string { return 'Number 42'; }) |
|
42 | + ->case(Any(), function(): string { return 'Fallback'; }) |
|
43 | 43 | ->done(); |
44 | 44 | |
45 | 45 | println($res2); |
46 | 46 | |
47 | 47 | $res3 = match(Some(42)) |
48 | - ->case(Value(Some(13)), function (): string { return 'Some 13'; }) |
|
49 | - ->case(Value(Some(42)), function (): string { return 'Some 42'; }) |
|
50 | - ->case(Any(), function (): string { return 'Fallback'; }) |
|
48 | + ->case(Value(Some(13)), function(): string { return 'Some 13'; }) |
|
49 | + ->case(Value(Some(42)), function(): string { return 'Some 42'; }) |
|
50 | + ->case(Any(), function(): string { return 'Fallback'; }) |
|
51 | 51 | ->done(); |
52 | 52 | |
53 | 53 | println($res3); |
54 | 54 | |
55 | 55 | $res4 = match(Some(42)) |
56 | - ->case(Value(Some(13)), function (): string { return 'Some 13'; }) |
|
57 | - ->case(Value(Some('42')), function (): string { return 'Some 42'; }) |
|
58 | - ->case(Any(), function (): string { return 'Fallback'; }) |
|
56 | + ->case(Value(Some(13)), function(): string { return 'Some 13'; }) |
|
57 | + ->case(Value(Some('42')), function(): string { return 'Some 42'; }) |
|
58 | + ->case(Any(), function(): string { return 'Fallback'; }) |
|
59 | 59 | ->done(); |
60 | 60 | |
61 | 61 | println($res4); |
62 | 62 | |
63 | 63 | $res5 = match(42) |
64 | - ->case(Type('string'), function (): string { return 'String'; }) |
|
65 | - ->case(Type('integer'), function (): string { return 'Integer'; }) |
|
66 | - ->case(Any(), function (): string { return 'Not integer'; }) |
|
64 | + ->case(Type('string'), function(): string { return 'String'; }) |
|
65 | + ->case(Type('integer'), function(): string { return 'Integer'; }) |
|
66 | + ->case(Any(), function(): string { return 'Not integer'; }) |
|
67 | 67 | ->done(); |
68 | 68 | |
69 | 69 | println($res5); |
70 | 70 | |
71 | 71 | $res6 = match(Some(42)) |
72 | - ->case(Type(None::class), function (): string { return 'None'; }) |
|
73 | - ->case(Type(Some::class), function (): string { return 'Some'; }) |
|
74 | - ->case(Any(), function (): string { return 'Neither'; }) |
|
72 | + ->case(Type(None::class), function(): string { return 'None'; }) |
|
73 | + ->case(Type(Some::class), function(): string { return 'Some'; }) |
|
74 | + ->case(Any(), function(): string { return 'Neither'; }) |
|
75 | 75 | ->done(); |
76 | 76 | |
77 | 77 | println($res6); |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $res8 = match(new Tuple('2 * 7 = ', 14)) |
88 | 88 | ->case( |
89 | 89 | Type(Tuple::class, Any()->bind(), Any()->bind()), |
90 | - function (string $question, int $answer): string { return concat('Solution: ', $question, AnyToString($answer)); } |
|
90 | + function(string $question, int $answer): string { return concat('Solution: ', $question, AnyToString($answer)); } |
|
91 | 91 | ) |
92 | 92 | ->case(Any(), returnString('Fallback')) |
93 | 93 | ->done(); |