Skip to content

Commit

Permalink
PHPStan tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamCampbell committed Dec 13, 2019
1 parent 6cd4f01 commit c9af337
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 17 deletions.
1 change: 1 addition & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ parameters:
- '#Method Dotenv\\Repository\\AbstractRepository::offset[a-zA-Z\(\)\$ ]* typehint specified.#'
- '#Method Dotenv\\Loader\\Lines::getCharPairs\(\) should return array\(array\(string, string\|null\)\) but returns array\<int, mixed\>.#'
- '#Unable to resolve the template type S in call to method PhpOption\\Option<mixed>::flatMap\(\)#'
- '#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>.#'
18 changes: 12 additions & 6 deletions src/Result/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ private function __construct($value)
/**
* Create a new error value.
*
* @param E $value
* @template F
*
* @param F $value
*
* @return \Dotenv\Result\Result<T,E>
* @return \Dotenv\Result\Result<T,F>
*/
public static function create($value)
{
Expand All @@ -54,9 +56,11 @@ public function success()
/**
* Map over the success value.
*
* @param callable $f
* @template S
*
* @return \Dotenv\Result\Result<T,E>
* @param callable(T): S $f
*
* @return \Dotenv\Result\Result<S,E>
*/
public function mapSuccess(callable $f)
{
Expand All @@ -76,9 +80,11 @@ public function error()
/**
* Map over the error value.
*
* @param callable $f
* @template F
*
* @param callable(E): F $f
*
* @return \Dotenv\Result\Result<T,E>
* @return \Dotenv\Result\Result<T,F>
*/
public function mapError(callable $f)
{
Expand Down
12 changes: 8 additions & 4 deletions src/Result/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ public function getSuccess()
/**
* Map over the success value.
*
* @param callable $f
* @template S
*
* @return \Dotenv\Result\Result<T,E>
* @param callable(T): S $f
*
* @return \Dotenv\Result\Result<S,E>
*/
abstract public function mapSuccess(callable $f);

Expand All @@ -58,9 +60,11 @@ public function getError()
/**
* Map over the error value.
*
* @param callable $f
* @template F
*
* @param callable(E): F $f
*
* @return \Dotenv\Result\Result<T,E>
* @return \Dotenv\Result\Result<T,F>
*/
abstract public function mapError(callable $f);
}
20 changes: 13 additions & 7 deletions src/Result/Success.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ private function __construct($value)
}

/**
* Create a new success value.
* Create a new error value.
*
* @param T $value
* @template S
*
* @param S $value
*
* @return \Dotenv\Result\Result<T,E>
* @return \Dotenv\Result\Result<S,E>
*/
public static function create($value)
{
Expand All @@ -54,9 +56,11 @@ public function success()
/**
* Map over the success value.
*
* @param callable $f
* @template S
*
* @return \Dotenv\Result\Result<T,E>
* @param callable(T): S $f
*
* @return \Dotenv\Result\Result<S,E>
*/
public function mapSuccess(callable $f)
{
Expand All @@ -76,9 +80,11 @@ public function error()
/**
* Map over the error value.
*
* @param callable $f
* @template F
*
* @param callable(E): F $f
*
* @return \Dotenv\Result\Result<T,E>
* @return \Dotenv\Result\Result<T,F>
*/
public function mapError(callable $f)
{
Expand Down

0 comments on commit c9af337

Please sign in to comment.