Skip to content

Commit

Permalink
Issue #1: Add PSALM type declarations.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Jan 22, 2020
1 parent a31a4a6 commit 365a726
Show file tree
Hide file tree
Showing 25 changed files with 196 additions and 26 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"phpspec/phpspec": "^5.1.2 || ^6.1.1",
"phpstan/phpstan": "^0.12.5",
"phpstan/phpstan-strict-rules": "^0.12",
"scrutinizer/ocular": "^1.6"
"scrutinizer/ocular": "^1.6",
"vimeo/psalm": "^3.8"
},
"config": {
"sort-packages": true
Expand Down
1 change: 1 addition & 0 deletions grumphp.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ imports:
parameters:
process_timeout: 600
extra_tasks:
psalm: ~
phpspec:
verbose: true
metadata:
Expand Down
15 changes: 15 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<psalm
totallyTyped="false"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
</psalm>
8 changes: 8 additions & 0 deletions src/Combinator/A.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

/**
* Class A.
*
* @psalm-template XType
* @psalm-template ResultType
*/
final class A extends Combinator
{
Expand All @@ -24,6 +27,9 @@ final class A extends Combinator
/**
* A constructor.
*
* @psalm-param callable(XType) : ResultType $f
* @psalm-param XType $x
*
* @param callable $f
* @param mixed $x
*/
Expand All @@ -34,6 +40,8 @@ public function __construct(callable $f, $x)
}

/**
* @psalm-return ResultType
*
* @return mixed
*/
public function __invoke()
Expand Down
10 changes: 9 additions & 1 deletion src/Combinator/B.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

/**
* Class B.
*
* @psalm-template GOutput
* @psalm-template XType
* @psalm-template ResultType
*/
final class B extends Combinator
{
Expand All @@ -29,6 +33,10 @@ final class B extends Combinator
/**
* B constructor.
*
* @psalm-param callable(GOutput) : ResultType $f
* @psalm-param callable(XType) : GOutput $g
* @psalm-param XType $x
*
* @param callable $f
* @param callable $g
* @param mixed $x
Expand All @@ -41,7 +49,7 @@ public function __construct(callable $f, callable $g, $x)
}

/**
* @return mixed
* @psalm-return ResultType
*/
public function __invoke()
{
Expand Down
9 changes: 8 additions & 1 deletion src/Combinator/C.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

/**
* Class C.
*
* @psalm-template XType
* @psalm-template ResultType
*/
final class C extends Combinator
{
Expand All @@ -29,6 +32,10 @@ final class C extends Combinator
/**
* C constructor.
*
* @psalm-param callable(XType) : ResultType $f
* @psalm-param XType $x
* @psalm-param XType $y
*
* @param callable $f
* @param mixed $x
* @param mixed $y
Expand All @@ -41,7 +48,7 @@ public function __construct(callable $f, $x, $y)
}

/**
* @return mixed
* @psalm-return ResultType
*/
public function __invoke()
{
Expand Down
10 changes: 9 additions & 1 deletion src/Combinator/D.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

/**
* Class D.
*
* @psalm-template XType
* @psalm-template ResultType
*/
final class D extends Combinator
{
Expand All @@ -34,6 +37,11 @@ final class D extends Combinator
/**
* D constructor.
*
* @psalm-param callable(XType) : ResultType $f
* @psalm-param callable(XType) : ResultType $g
* @psalm-param XType $x
* @psalm-param XType $y
*
* @param callable $f
* @param callable $g
* @param mixed $x
Expand All @@ -48,7 +56,7 @@ public function __construct(callable $f, $x, callable $g, $y)
}

/**
* @return mixed
* @psalm-return ResultType
*/
public function __invoke()
{
Expand Down
11 changes: 10 additions & 1 deletion src/Combinator/E.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

/**
* Class E.
*
* @psalm-template XType
* @psalm-template ResultType
*/
final class E extends Combinator
{
Expand Down Expand Up @@ -39,6 +42,12 @@ final class E extends Combinator
/**
* E constructor.
*
* @psalm-param callable(XType) : ResultType $f
* @psalm-param XType $x
* @psalm-param callable(XType) : ResultType $g
* @psalm-param XType $y
* @psalm-param XType $z
*
* @param callable $f
* @param mixed $x
* @param callable $g
Expand All @@ -55,7 +64,7 @@ public function __construct(callable $f, $x, callable $g, $y, $z)
}

/**
* @return mixed
* @psalm-return ResultType
*/
public function __invoke()
{
Expand Down
11 changes: 9 additions & 2 deletions src/Combinator/F.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

/**
* Class F.
*
* @psalm-template XType
* @psalm-template ResultType
*/
final class F extends Combinator
{
Expand All @@ -22,13 +25,17 @@ final class F extends Combinator
private $x;

/**
* @var callable
* @var mixed
*/
private $y;

/**
* F constructor.
*
* @psalm-param XType $x
* @psalm-param XType $y
* @psalm-param callable(XType) : ResultType $f
*
* @param mixed $x
* @param mixed $y
* @param callable $f
Expand All @@ -41,7 +48,7 @@ public function __construct($x, $y, callable $f)
}

/**
* @return mixed
* @psalm-return ResultType
*/
public function __invoke()
{
Expand Down
12 changes: 10 additions & 2 deletions src/Combinator/G.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

/**
* Class G.
*
* @psalm-template XType
* @psalm-template ResultType
*/
final class G extends Combinator
{
Expand All @@ -27,13 +30,18 @@ final class G extends Combinator
private $x;

/**
* @var callable
* @var mixed
*/
private $y;

/**
* G constructor.
*
* @psalm-param callable(XType) : callable $f
* @psalm-param callable(XType) : ResultType $g
* @psalm-param XType $x
* @psalm-param XType $y
*
* @param callable $f
* @param callable $g
* @param mixed $x
Expand All @@ -48,7 +56,7 @@ public function __construct(callable $f, callable $g, $x, $y)
}

/**
* @return mixed
* @psalm-return ResultType
*/
public function __invoke()
{
Expand Down
11 changes: 9 additions & 2 deletions src/Combinator/H.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

/**
* Class H.
*
* @psalm-template XType
* @psalm-template ResultType
*/
final class H extends Combinator
{
Expand All @@ -17,7 +20,7 @@ final class H extends Combinator
private $f;

/**
* @var callable
* @var mixed
*/
private $x;

Expand All @@ -29,6 +32,10 @@ final class H extends Combinator
/**
* H constructor.
*
* @psalm-param callable(XType) : callable $f
* @psalm-param XType $x
* @psalm-param XType $y
*
* @param callable $f
* @param mixed $x
* @param mixed $y
Expand All @@ -41,7 +48,7 @@ public function __construct(callable $f, $x, $y)
}

/**
* @return mixed
* @psalm-return ResultType
*/
public function __invoke()
{
Expand Down
7 changes: 6 additions & 1 deletion src/Combinator/I.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

/**
* Class I.
*
* @psalm-template XType
* @psalm-template ResultType
*/
final class I extends Combinator
{
Expand All @@ -19,6 +22,8 @@ final class I extends Combinator
/**
* I constructor.
*
* @psalm-param XType $x
*
* @param mixed $x
*/
public function __construct($x)
Expand All @@ -27,7 +32,7 @@ public function __construct($x)
}

/**
* @return mixed
* @psalm-return XType
*/
public function __invoke()
{
Expand Down
12 changes: 10 additions & 2 deletions src/Combinator/J.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

/**
* Class J.
*
* @psalm-template XType
* @psalm-template ResultType
*/
final class J extends Combinator
{
Expand All @@ -17,7 +20,7 @@ final class J extends Combinator
private $f;

/**
* @var callable
* @var mixed
*/
private $x;

Expand All @@ -34,6 +37,11 @@ final class J extends Combinator
/**
* J constructor.
*
* @psalm-param callable(XType) : callable $f
* @psalm-param XType $x
* @psalm-param XType $y
* @psalm-param XType $z
*
* @param callable $f
* @param mixed $x
* @param mixed $y
Expand All @@ -48,7 +56,7 @@ public function __construct(callable $f, $x, $y, $z)
}

/**
* @return mixed
* @psalm-return ResultType
*/
public function __invoke()
{
Expand Down
8 changes: 7 additions & 1 deletion src/Combinator/K.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

/**
* Class K.
*
* @psalm-template XType
* @psalm-template ResultType
*/
final class K extends Combinator
{
Expand All @@ -24,6 +27,9 @@ final class K extends Combinator
/**
* K constructor.
*
* @psalm-param XType $x
* @psalm-param XType $y
*
* @param mixed $x
* @param mixed $y
*/
Expand All @@ -34,7 +40,7 @@ public function __construct($x, $y)
}

/**
* @return mixed
* @psalm-return XType
*/
public function __invoke()
{
Expand Down
Loading

0 comments on commit 365a726

Please sign in to comment.