Skip to content

Commit 9753670

Browse files
authored
Merge pull request #76 from widmogrod/feature/strict_types
declare(strict_types=1)
2 parents 94dbc2d + d7cf4f0 commit 9753670

File tree

129 files changed

+382
-133
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+382
-133
lines changed

.php_cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,6 @@ return PhpCsFixer\Config::create()
4646
'header_comment' => false,
4747
'linebreak_after_opening_tag' => true,
4848
'array_syntax' => ['syntax' => 'short'],
49+
'declare_strict_types' => true,
4950
])
5051
->setFinder($finder);

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"scripts": {
2121
"test": "phpunit --no-coverage",
2222
"testc": "phpunit --coverage-clover ./clover.xml",
23-
"fix-code": "php-cs-fixer fix",
24-
"check-code": "php-cs-fixer fix --verbose --diff --dry-run"
23+
"fix-code": "php-cs-fixer fix --allow-risky=yes",
24+
"check-code": "php-cs-fixer fix --verbose --diff --dry-run --allow-risky=yes"
2525
},
2626
"autoload": {
2727
"psr-4": {

example/ApplicativeFunctorTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace example;
46

5-
use function Widmogrod\Functional\fromIterable;
67
use Widmogrod\Primitive\Listt;
8+
use function Widmogrod\Functional\fromIterable;
79

810
class ApplicativeFunctorTest extends \PHPUnit\Framework\TestCase
911
{

example/ApplicatorLiftTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace example;
46

57
use Widmogrod\Functional as f;

example/ComplexErrorDrivenDevelopmentTest.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<?php
22

3+
declare(strict_types=1);
34
require_once 'vendor/autoload.php';
45

5-
use Widmogrod\Monad\Either as E;
66
use Widmogrod\Functional as f;
7+
use Widmogrod\Monad\Either as E;
78

89
function validateName(array $request)
910
{
@@ -108,34 +109,34 @@ public function provideData()
108109
return [
109110
'success case' => [
110111
'$request' => [
111-
'name' => 'Jone Doe',
112+
'name' => 'Jone Doe',
112113
'email' => 'test@example.com'
113114
],
114-
'$isError' => false,
115+
'$isError' => false,
115116
'$expected' => ['status' => 200],
116117
],
117118
'username to short' => [
118119
'$request' => [
119-
'name' => '',
120+
'name' => '',
120121
'email' => 'test@example.com'
121122
],
122-
'$isError' => true,
123+
'$isError' => true,
123124
'$expected' => ['error' => 'Request name is empty'],
124125
],
125126
'username to long' => [
126127
'$request' => [
127-
'name' => 'asd asdasdlaks askl djalskd jalskdjaslkdjasldjadsa asd',
128+
'name' => 'asd asdasdlaks askl djalskd jalskdjaslkdjasldjadsa asd',
128129
'email' => 'test@example.com'
129130
],
130-
'$isError' => true,
131+
'$isError' => true,
131132
'$expected' => ['error' => 'Request name is to long'],
132133
],
133134
'email empty' => [
134135
'$request' => [
135-
'name' => 'Jone Doe',
136+
'name' => 'Jone Doe',
136137
'email' => ''
137138
],
138-
'$isError' => true,
139+
'$isError' => true,
139140
'$expected' => ['error' => 'Request e-mail is empty'],
140141
],
141142
];

example/EitherMonadTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace example;
46

57
use Widmogrod\Functional as f;

example/ExampleOfTraversableTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace example;
46

57
use Widmogrod\Functional as f;

example/FreeBddStyleDSLTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace example;
46

57
use Widmogrod\FantasyLand\Functor;

example/FreeMonadTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace example2;
46

57
use Widmogrod\FantasyLand\Functor;
68
use Widmogrod\Functional as f;
7-
use function Widmogrod\Functional\fromNil;
89
use Widmogrod\Monad\Free as ff;
910
use Widmogrod\Monad\Free\MonadFree;
1011
use Widmogrod\Monad\IO;
1112
use Widmogrod\Monad\State;
13+
use Widmogrod\Primitive\Listt;
1214
use const Widmogrod\Monad\IO\pure;
1315
use const Widmogrod\Monad\State\value;
14-
use Widmogrod\Primitive\Listt;
16+
use function Widmogrod\Functional\fromNil;
1517
use function Widmogrod\Useful\match;
1618

1719
interface TeletypeF extends Functor
@@ -212,7 +214,7 @@ public function provideEchoImplementation()
212214
{
213215
return [
214216
'echo implementation via explicit chaining (bind)' => [echo_chaining_()],
215-
'echo implementation via function composition' => [echo_composition_()],
217+
'echo implementation via function composition' => [echo_composition_()],
216218
];
217219
}
218220
}

example/FunctorCollectionTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace example;
46

57
use function Widmogrod\Functional\fromIterable;

example/ListComprehensionWithMonadTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace example;
46

57
use function Widmogrod\Functional\fromIterable;

example/MaybeMonadAndCollectionTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace example;
46

7+
use Widmogrod\Functional as f;
58
use Widmogrod\Monad\Maybe;
6-
use function Widmogrod\Monad\Maybe\just;
79
use const Widmogrod\Monad\Maybe\maybeNull;
10+
use function Widmogrod\Monad\Maybe\just;
811
use function Widmogrod\Monad\Maybe\nothing;
9-
use Widmogrod\Functional as f;
1012

1113
class MaybeMonadAndCollectionTest extends \PHPUnit\Framework\TestCase
1214
{
@@ -23,7 +25,7 @@ public function test_it_should_extract_elements_which_exists($data)
2325
});
2426

2527
$listOfFirstImages = f\pipeline(
26-
f\fromValue,
28+
f\fromValue,
2729
f\map(maybeNull),
2830
f\map(f\bind($get('meta'))),
2931
f\map(f\bind($get('images'))),

example/MaybeMonoidTest.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
use Widmogrod\Functional as f;
46
use Widmogrod\Monad\Maybe\Just;
57
use Widmogrod\Monad\Maybe\Maybe;
6-
use Widmogrod\Primitive\Listt;
78
use Widmogrod\Primitive\Stringg;
89
use const Widmogrod\Monad\Maybe\maybeNull;
910
use function Widmogrod\Functional\map;
@@ -81,18 +82,18 @@ public function provideData()
8182
return [
8283
'array with null values' => [
8384
'$data' => [
84-
'firstName' => 'First',
85+
'firstName' => 'First',
8586
'middleName' => null,
86-
'lastName' => 'Last'
87+
'lastName' => 'Last'
8788
],
8889
'$expected' => ['First', 'Last'],
8990
'$asString' => 'FirstLast',
9091
],
9192
'array with strings' => [
9293
'$data' => [
93-
'firstName' => 'First',
94+
'firstName' => 'First',
9495
'middleName' => 'Middle',
95-
'lastName' => 'Last'
96+
'lastName' => 'Last'
9697
],
9798
'$expected' => ['First', 'Middle', 'Last'],
9899
'$asString' => 'FirstMiddleLast',

example/ReaderMonadTest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace example;
46

57
use Widmogrod\Monad\Reader as R;
@@ -12,8 +14,8 @@ function hello($name)
1214
function ask($content)
1315
{
1416
return R::of(function ($name) use ($content) {
15-
return $content.
16-
($name == 'World' ? '' : ' How are you ?');
17+
return $content .
18+
($name == 'World' ? '' : ' How are you ?');
1719
});
1820
}
1921

@@ -22,8 +24,8 @@ class ReaderMonadTest extends \PHPUnit\Framework\TestCase
2224
public function test_it_should_pass_the_name_around()
2325
{
2426
$r = R\reader('example\hello')
25-
->bind('example\ask')
26-
->map('strtoupper');
27+
->bind('example\ask')
28+
->map('strtoupper');
2729

2830
$this->assertEquals(
2931
'HELLO WORLD!',

example/StateMonadTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace example;
46

5-
use Widmogrod\Monad\State as S;
67
use Widmogrod\Monad\Maybe;
8+
use Widmogrod\Monad\State as S;
79

810
/**
911
* Caching is an example state that you could have in your application.

example/WriterMonadTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace example;
46

5-
use Widmogrod\Monad\Writer as W;
67
use Widmogrod\Functional as f;
8+
use Widmogrod\Monad\Writer as W;
79
use Widmogrod\Primitive\Stringg as S;
810

911
class WriterMonadTest extends \PHPUnit\Framework\TestCase

src/Common/PointedTrait.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Widmogrod\Common;
46

57
trait PointedTrait

src/Common/ValueOfInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Widmogrod\Common;
46

57
interface ValueOfInterface

src/Common/ValueOfTrait.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Widmogrod\Common;
46

57
trait ValueOfTrait

src/FantasyLand/Applicative.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Widmogrod\FantasyLand;
46

57
interface Applicative extends

src/FantasyLand/Apply.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Widmogrod\FantasyLand;
46

57
interface Apply extends Functor

src/FantasyLand/Chain.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Widmogrod\FantasyLand;
46

57
interface Chain extends Apply

src/FantasyLand/Comonad.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Widmogrod\FantasyLand;
46

57
interface Comonad extends

src/FantasyLand/Extend.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Widmogrod\FantasyLand;
46

57
interface Extend

src/FantasyLand/Foldable.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Widmogrod\FantasyLand;
46

57
interface Foldable
68
{
79
/**
810
* reduce :: (b -> a -> b) -> b -> b
911
*
10-
* @param callable $function Binary function ($accumulator, $value)
11-
* @param mixed $accumulator Value to witch reduce
12+
* @param callable $function Binary function ($accumulator, $value)
13+
* @param mixed $accumulator Value to witch reduce
1214
*
1315
* @return mixed Same type as $accumulator
1416
*/

src/FantasyLand/Functor.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Widmogrod\FantasyLand;
46

57
interface Functor

src/FantasyLand/Monad.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Widmogrod\FantasyLand;
46

57
interface Monad extends

src/FantasyLand/Monoid.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Widmogrod\FantasyLand;
46

57
interface Monoid extends Semigroup

src/FantasyLand/Pointed.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Widmogrod\FantasyLand;
46

57
interface Pointed

0 commit comments

Comments
 (0)