Skip to content

Commit c9af337

Browse files
PHPStan tweaks
1 parent 6cd4f01 commit c9af337

File tree

4 files changed

+34
-17
lines changed

4 files changed

+34
-17
lines changed

phpstan.neon.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ parameters:
99
- '#Method Dotenv\\Repository\\AbstractRepository::offset[a-zA-Z\(\)\$ ]* typehint specified.#'
1010
- '#Method Dotenv\\Loader\\Lines::getCharPairs\(\) should return array\(array\(string, string\|null\)\) but returns array\<int, mixed\>.#'
1111
- '#Unable to resolve the template type S in call to method PhpOption\\Option<mixed>::flatMap\(\)#'
12+
- '#Method Dotenv\\Loader\\Parser::processChar\(\) should return Dotenv\\Result\\Result<array<int, bool\|int\|string>, string> but returns Dotenv\\Result\\Result<array<int, [a-z\|\,]+>, mixed>.#'

src/Result/Error.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ private function __construct($value)
3232
/**
3333
* Create a new error value.
3434
*
35-
* @param E $value
35+
* @template F
36+
*
37+
* @param F $value
3638
*
37-
* @return \Dotenv\Result\Result<T,E>
39+
* @return \Dotenv\Result\Result<T,F>
3840
*/
3941
public static function create($value)
4042
{
@@ -54,9 +56,11 @@ public function success()
5456
/**
5557
* Map over the success value.
5658
*
57-
* @param callable $f
59+
* @template S
5860
*
59-
* @return \Dotenv\Result\Result<T,E>
61+
* @param callable(T): S $f
62+
*
63+
* @return \Dotenv\Result\Result<S,E>
6064
*/
6165
public function mapSuccess(callable $f)
6266
{
@@ -76,9 +80,11 @@ public function error()
7680
/**
7781
* Map over the error value.
7882
*
79-
* @param callable $f
83+
* @template F
84+
*
85+
* @param callable(E): F $f
8086
*
81-
* @return \Dotenv\Result\Result<T,E>
87+
* @return \Dotenv\Result\Result<T,F>
8288
*/
8389
public function mapError(callable $f)
8490
{

src/Result/Result.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ public function getSuccess()
3030
/**
3131
* Map over the success value.
3232
*
33-
* @param callable $f
33+
* @template S
3434
*
35-
* @return \Dotenv\Result\Result<T,E>
35+
* @param callable(T): S $f
36+
*
37+
* @return \Dotenv\Result\Result<S,E>
3638
*/
3739
abstract public function mapSuccess(callable $f);
3840

@@ -58,9 +60,11 @@ public function getError()
5860
/**
5961
* Map over the error value.
6062
*
61-
* @param callable $f
63+
* @template F
64+
*
65+
* @param callable(E): F $f
6266
*
63-
* @return \Dotenv\Result\Result<T,E>
67+
* @return \Dotenv\Result\Result<T,F>
6468
*/
6569
abstract public function mapError(callable $f);
6670
}

src/Result/Success.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ private function __construct($value)
3030
}
3131

3232
/**
33-
* Create a new success value.
33+
* Create a new error value.
3434
*
35-
* @param T $value
35+
* @template S
36+
*
37+
* @param S $value
3638
*
37-
* @return \Dotenv\Result\Result<T,E>
39+
* @return \Dotenv\Result\Result<S,E>
3840
*/
3941
public static function create($value)
4042
{
@@ -54,9 +56,11 @@ public function success()
5456
/**
5557
* Map over the success value.
5658
*
57-
* @param callable $f
59+
* @template S
5860
*
59-
* @return \Dotenv\Result\Result<T,E>
61+
* @param callable(T): S $f
62+
*
63+
* @return \Dotenv\Result\Result<S,E>
6064
*/
6165
public function mapSuccess(callable $f)
6266
{
@@ -76,9 +80,11 @@ public function error()
7680
/**
7781
* Map over the error value.
7882
*
79-
* @param callable $f
83+
* @template F
84+
*
85+
* @param callable(E): F $f
8086
*
81-
* @return \Dotenv\Result\Result<T,E>
87+
* @return \Dotenv\Result\Result<T,F>
8288
*/
8389
public function mapError(callable $f)
8490
{

0 commit comments

Comments
 (0)