Skip to content

Commit a20402b

Browse files
authored
Merge pull request #33 from wiz-develop/endou-mame/issue32
2 parents 44659e3 + 0c28a3f commit a20402b

26 files changed

+210
-66
lines changed

composer.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@
3030
"wiz-develop/php-cs-fixer-config": "^8.3",
3131
"phpstan/phpstan": "^1.12",
3232
"phpunit/php-code-coverage": "^11.0",
33-
"phpunit/phpunit": "^11.3"
33+
"phpunit/phpunit": "^11.3",
34+
"phpstan/extension-installer": "^1.4",
35+
"phpstan/phpstan-strict-rules": "^1.6"
36+
},
37+
"config": {
38+
"allow-plugins": {
39+
"phpstan/extension-installer": true
40+
}
3441
}
35-
}
42+
}

composer.lock

Lines changed: 100 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpstan.neon.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ parameters:
44
level: max
55
paths:
66
- src
7+
- tests
78
typeAliases:
89
BasicTypes: 'int|string|bool|null|float|array|iterable|callable|resource|object'

src/Option.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function and(self $right): self;
103103
* @param Closure(T): Option<U> $right
104104
* @return Option<U>
105105
*/
106-
public function andThen(Closure $right): self;
106+
public function andThen(Closure $right): self; /** @phpstan-ignore method.childParameterType */
107107

108108
/**
109109
* @see https://doc.rust-lang.org/std/option/enum.Option.html#method.or

src/Option/None.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ public static function unit(mixed $value): self
3333
/**
3434
* @return $this
3535
*/
36+
/**
37+
* @phpstan-ignore method.childParameterType
38+
*/
3639
#[Override]
3740
public function andThen(Closure $right): self
3841
{

src/Option/Some.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ public static function unit(mixed $value): self
4141
* @param Closure(T): Option<U> $right
4242
* @return Option<U>
4343
*/
44+
/**
45+
* @phpstan-ignore method.childParameterType
46+
*/
4447
#[Override]
4548
public function andThen(Closure $right): Option
4649
{

src/Result.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public function and(self $right): self;
117117
* @param Closure(T): Result<U, F> $right
118118
* @return (F is BasicTypes ? Result<U, E|F> : Result<U, E>)
119119
*/
120-
public function andThen(Closure $right): self;
120+
public function andThen(Closure $right): self; /** @phpstan-ignore method.childParameterType */
121121

122122
/**
123123
* @see https://doc.rust-lang.org/std/result/enum.Result.html#method.or

src/Result/Err.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static function unit(mixed $value): self
4242
}
4343

4444
/**
45-
* @return $this
45+
* @phpstan-ignore method.childParameterType, missingType.generics
4646
*/
4747
#[Override]
4848
public function andThen(Closure $right): self

src/Result/Ok.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,13 @@ public static function unit(mixed $value): self
4646
* @param Closure(T) :Result<U, F> $right
4747
* @return Result<U, F>
4848
*/
49+
/**
50+
* @phpstan-ignore method.childParameterType
51+
*/
4952
#[Override]
5053
public function andThen(Closure $right): Result
5154
{
55+
// @phpstan-ignore return.type
5256
return $right($this->value);
5357
}
5458

src/Result/functions.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,18 @@ function transpose(Result $result): Option
9292
}
9393

9494
/**
95-
* @return Result<bool, non-empty-list<mixed>>
95+
* @template T
96+
* @template E
97+
* @param (Result<T, E>|Result) ...$results
98+
* @return Result<bool, non-empty-list<E>>
9699
*/
97-
/** @phpstan-ignore-next-line */
98-
function combine(Result ...$results): Result
100+
function combine(Result ...$results): Result // @phpstan-ignore-line
99101
{
100102
$errs = array_filter($results, static fn (Result $result) => $result->isErr());
101103
if (count($errs) > 0) {
104+
// @phpstan-ignore return.type
102105
return Result\err(array_values(array_map(static fn (Result $result) => $result->unwrapErr(), $errs)));
103106
}
104107

105-
return Result\ok(true);
108+
return Result\ok();
106109
}

0 commit comments

Comments
 (0)