@@ -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 | 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 | |
@@ -19,60 +19,60 @@ discard block |
||
19 | 19 | |
20 | 20 | function returnString(string $s): callable |
21 | 21 | { |
22 | - return function () use ($s): string { |
|
22 | + return function() use ($s): string { |
|
23 | 23 | return $s; |
24 | 24 | }; |
25 | 25 | } |
26 | 26 | |
27 | 27 | $res0 = match(42) |
28 | - ->case(Any(), function (): string { return 'Anything'; }) |
|
28 | + ->case(Any(), function(): string { return 'Anything'; }) |
|
29 | 29 | ->done(); |
30 | 30 | |
31 | 31 | println($res0); |
32 | 32 | |
33 | 33 | $res1 = match(Some(42)) |
34 | - ->case(Any(), function (): string { return 'Anything'; }) |
|
34 | + ->case(Any(), function(): string { return 'Anything'; }) |
|
35 | 35 | ->done(); |
36 | 36 | |
37 | 37 | println($res1); |
38 | 38 | |
39 | 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'; }) |
|
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 | 44 | ->done(); |
45 | 45 | |
46 | 46 | println($res2); |
47 | 47 | |
48 | 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'; }) |
|
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 | 52 | ->done(); |
53 | 53 | |
54 | 54 | println($res3); |
55 | 55 | |
56 | 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'; }) |
|
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 | 60 | ->done(); |
61 | 61 | |
62 | 62 | println($res4); |
63 | 63 | |
64 | 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'; }) |
|
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 | 68 | ->done(); |
69 | 69 | |
70 | 70 | println($res5); |
71 | 71 | |
72 | 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'; }) |
|
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 | 76 | ->done(); |
77 | 77 | |
78 | 78 | println($res6); |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | $res8 = match(Pair('2 * 7 = ', 14)) |
89 | 89 | ->case( |
90 | 90 | Type(Tuple::class, Any()->bind(), Any()->bind()), |
91 | - function (string $question, int $answer): string { return concat('Solution: ', $question, AnyToString($answer)); } |
|
91 | + function(string $question, int $answer): string { return concat('Solution: ', $question, AnyToString($answer)); } |
|
92 | 92 | ) |
93 | 93 | ->case(Any(), returnString('Fallback')) |
94 | 94 | ->done(); |
@@ -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; |
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 |