Skip to content

Commit a1a4edc

Browse files
authored
Merge pull request #106 from nick-zh/php8-compatibility
php8 compatibility
2 parents 34ed870 + 40505f4 commit a1a4edc

File tree

8 files changed

+19
-19
lines changed

8 files changed

+19
-19
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "widmogrod/php-functional",
33
"description": "Functors, Applicative and Monads are fascinating concept. Purpose of this library is to explore them in OOP PHP world.",
44
"require": {
5-
"php": ">=7.1",
5+
"php": "^7.1|^8.0",
66
"functional-php/fantasy-land": "^1"
77
},
88
"require-dev": {

example/FreeBddStyleDSLTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use function Widmogrod\Functional\push_;
1414
use function Widmogrod\Monad\Free\foldFree;
1515
use function Widmogrod\Monad\Free\liftF;
16-
use function Widmogrod\Useful\match;
16+
use function Widmogrod\Useful\matchPatterns;
1717

1818
interface ScenarioF extends Functor
1919
{
@@ -162,7 +162,7 @@ function Given(string $desc, $state): Scenario
162162
*/
163163
function interpretScenario(callable $interpretAction, callable $interpretAssertion, ScenarioF $f)
164164
{
165-
return match([
165+
return matchPatterns([
166166
Given::class => function (Given $a): State {
167167
return State::of(function () use ($a) {
168168
return [$a->next, $a->state];

example/FreeCalculatorTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use function Widmogrod\Functional\bindM2;
1515
use function Widmogrod\Monad\Free\foldFree;
1616
use function Widmogrod\Monad\Free\liftF;
17-
use function Widmogrod\Useful\match;
17+
use function Widmogrod\Useful\matchPatterns;
1818

1919
/**
2020
* Exp a next
@@ -201,7 +201,7 @@ function square(MonadFree $a): MonadFree
201201
*/
202202
function interpretInt(ExpF $f)
203203
{
204-
return match([
204+
return matchPatterns([
205205
IntVal::class => function (int $x, callable $next): Identity {
206206
return Identity::of($x)->map($next);
207207
},
@@ -227,7 +227,7 @@ function interpretInt(ExpF $f)
227227
*/
228228
function interpretPrint(ExpF $f)
229229
{
230-
return match([
230+
return matchPatterns([
231231
IntVal::class => function (int $x, callable $next): Identity {
232232
return Identity::of(Stringg::of("$x"))->map($next);
233233
},
@@ -259,7 +259,7 @@ function interpretPrint(ExpF $f)
259259
*/
260260
function optimizeCalc(ExpF $f)
261261
{
262-
return match([
262+
return matchPatterns([
263263
IntVal::class => function ($x, callable $next) {
264264
return new IntVal($x, $next);
265265
},

example/FreeMonadTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use const Widmogrod\Monad\IO\pure;
1515
use const Widmogrod\Monad\State\value;
1616
use function Widmogrod\Functional\fromNil;
17-
use function Widmogrod\Useful\match;
17+
use function Widmogrod\Useful\matchPatterns;
1818

1919
interface TeletypeF extends Functor
2020
{
@@ -106,7 +106,7 @@ function exitSuccess_()
106106
// run :: TeletypeF -> IO ()
107107
function interpretIO(TeletypeF $r)
108108
{
109-
return match([
109+
return matchPatterns([
110110
PutStrLn::class => function (PutStrLn $a) {
111111
return IO\putStrLn($a->str)->map(function () use ($a) {
112112
return $a->next;
@@ -126,7 +126,7 @@ function interpretIO(TeletypeF $r)
126126
// runTest :: TeletypeF -> State MonadFree []
127127
function interpretState(TeletypeF $r)
128128
{
129-
return match([
129+
return matchPatterns([
130130
PutStrLn::class => function (PutStrLn $a) {
131131
return State::of(function (Listt $state) use ($a) {
132132
return [

example/FreeUnionTypeGeneratorTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use function Widmogrod\Functional\reduce;
1919
use function Widmogrod\Monad\Free\foldFree;
2020
use function Widmogrod\Monad\Free\liftF;
21-
use function Widmogrod\Useful\match;
21+
use function Widmogrod\Useful\matchPatterns;
2222

2323
/**
2424
* type UnionF _ next
@@ -263,7 +263,7 @@ public function __toString()
263263
*/
264264
function interpretTypesAndGenerate(UnionF $f): Identity
265265
{
266-
return match([
266+
return matchPatterns([
267267
Declare_::class => function (string $name, array $args, callable $next): Identity {
268268
$a = new GeneratorLazy();
269269
$a->declaration = [
@@ -293,7 +293,7 @@ public function test_example_1()
293293
{
294294
// $interpret :: UnionF -> Identity Free a
295295
$interpret = function (UnionF $f): Identity {
296-
return match([
296+
return matchPatterns([
297297
Declare_::class => function (string $name, array $args, callable $next): Identity {
298298
return Identity::of([
299299
'interface' => $name,

src/Monad/Control/Doo/interpretation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use function Widmogrod\Functional\sequenceM;
1616
use function Widmogrod\Monad\Free\foldFree;
1717
use function Widmogrod\Monad\Reader\runReader;
18-
use function Widmogrod\Useful\match;
18+
use function Widmogrod\Useful\matchPatterns;
1919

2020
/**
2121
* @var callable
@@ -32,7 +32,7 @@
3232
*/
3333
function interpretation(DooF $f)
3434
{
35-
return match([
35+
return matchPatterns([
3636
Let::class => function (string $name, Monad $m, MonadFree $next): Reader {
3737
return Reader::of(function (Registry $registry) use ($name, $m, $next) {
3838
return $m->bind(function ($v) use ($name, $next, $registry) {

src/Useful/match.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*
2727
* @return mixed
2828
*/
29-
function match(array $patterns, $value = null)
29+
function matchPatterns(array $patterns, $value = null)
3030
{
3131
return curryN(2, function (array $patterns, $value) {
3232
if (count($patterns) === 0) {

test/Useful/MatchTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
use Widmogrod\Useful\PatternMatcher;
88
use Widmogrod\Useful\PatternNotMatchedError;
9-
use function Widmogrod\Useful\match;
9+
use function Widmogrod\Useful\matchPatterns;
1010
use const Widmogrod\Functional\identity;
1111
use const Widmogrod\Useful\any;
1212

@@ -23,7 +23,7 @@ public function test_it_should_fail_on_not_matched_patterns(
2323
$this->expectException(PatternNotMatchedError::class);
2424
$this->expectExceptionMessage($expectedMessage);
2525

26-
match($patterns, $value);
26+
matchPatterns($patterns, $value);
2727
}
2828

2929
public function provideInvalidPatterns()
@@ -61,7 +61,7 @@ public function test_it_should_match_given_value(
6161
$value,
6262
$expected
6363
) {
64-
$result = match($patterns, $value);
64+
$result = matchPatterns($patterns, $value);
6565
$this->assertSame(
6666
$expected,
6767
$result

0 commit comments

Comments
 (0)