From 94b6b6cb2a424c9782632ef388b42b2072eda3c9 Mon Sep 17 00:00:00 2001 From: Tihomir Tonov Date: Wed, 13 Aug 2025 13:00:52 +0300 Subject: [PATCH 1/3] Fix: Remove nullable type hints from callable parameters in Result class The callable parameters in Result methods were incorrectly marked as nullable (T=) when they should be required (T). This was causing PHPStan v1 to report errors about parameter mismatches. Since these callables are only invoked when there's an actual value present (Ok for map/andThen, Err for mapErr/orElse), the parameters should not be nullable. Fixes #42 --- src/Result.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Result.php b/src/Result.php index 47daae0..1f90df8 100644 --- a/src/Result.php +++ b/src/Result.php @@ -61,7 +61,7 @@ abstract public function err(): Option; * * @template U * - * @param callable(T=):U $mapper + * @param callable(T):U $mapper * @return Result */ abstract public function map(callable $mapper): self; @@ -72,7 +72,7 @@ abstract public function map(callable $mapper): self; * @template U * * @param U $default - * @param callable(T=):U $f + * @param callable(T):U $f * * @return U */ @@ -83,8 +83,8 @@ abstract public function mapOr($default, callable $f): mixed; * * @template U * - * @param callable(E=):U $default - * @param callable(T=):U $f + * @param callable(E):U $default + * @param callable(T):U $f * * @return U */ @@ -95,7 +95,7 @@ abstract public function mapOrElse(callable $default, callable $f): mixed; * * @template F * - * @param callable(E=):F $op + * @param callable(E):F $op * @return Result */ abstract public function mapErr(callable $op): self; @@ -103,7 +103,7 @@ abstract public function mapErr(callable $op): self; /** * Calls a function with a reference to the contained value if Ok. * - * @param callable(T=):void $f + * @param callable(T):void $f * * @return Result */ @@ -112,7 +112,7 @@ abstract public function inspect(callable $f): self; /** * Calls a function with a reference to the contained value if Err. * - * @param callable(E=):void $f + * @param callable(E):void $f * * @return Result */ @@ -173,7 +173,7 @@ abstract public function and(self $res): self; * * @template U * - * @param callable(T=):Result $op + * @param callable(T):Result $op * @return Result */ abstract public function andThen(callable $op): self; @@ -193,7 +193,7 @@ abstract public function or(self $res): self; * * @template F * - * @param callable(E=):Result $op + * @param callable(E):Result $op * @return Result */ abstract public function orElse(callable $op): self; @@ -209,7 +209,7 @@ abstract public function unwrapOr($optb): mixed; /** * Unwraps a result, yielding the content of an Ok. If the value is an Err then it calls op with its value. * - * @param callable(E=):T $op + * @param callable(E):T $op * @return T */ abstract public function unwrapOrElse(callable $op): mixed; From 2f3cd76e5f6650e13ed417dab17a37ba1fd9625c Mon Sep 17 00:00:00 2001 From: Tihomir Tonov Date: Tue, 19 Aug 2025 14:44:26 +0300 Subject: [PATCH 2/3] Apply PHPDoc improvements from PR review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated Result class method signatures as suggested by @tminich: - andThen(): Added template F, changed callable to Result and return to Result - orElse(): Added template U, changed callable to Result and return to Result - unwrapOr(): Added template U, changed return type to T|U - unwrapOrElse(): Added template U, changed return type to T|U These changes provide more flexible and accurate type annotations. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- src/Result.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/Result.php b/src/Result.php index 1f90df8..53728cf 100644 --- a/src/Result.php +++ b/src/Result.php @@ -172,9 +172,10 @@ abstract public function and(self $res): self; * Calls op if the result is Ok, otherwise returns the Err value of self. * * @template U + * @template F * - * @param callable(T):Result $op - * @return Result + * @param callable(T):Result $op + * @return Result */ abstract public function andThen(callable $op): self; @@ -191,26 +192,31 @@ abstract public function or(self $res): self; /** * Calls op if the result is Err, otherwise returns the Ok value of self. * + * @template U * @template F * - * @param callable(E):Result $op - * @return Result + * @param callable(E):Result $op + * @return Result */ abstract public function orElse(callable $op): self; /** * Unwraps a result, yielding the content of an Ok. Else, it returns optb. * - * @param T $optb - * @return T + * @template U + * + * @param U $optb + * @return T|U */ abstract public function unwrapOr($optb): mixed; /** * Unwraps a result, yielding the content of an Ok. If the value is an Err then it calls op with its value. * - * @param callable(E):T $op - * @return T + * @template U + * + * @param callable(E):U $op + * @return T|U */ abstract public function unwrapOrElse(callable $op): mixed; } From e704a8b7af782df00fc7807c5dcd0515aded4325 Mon Sep 17 00:00:00 2001 From: Tihomir Tonov Date: Tue, 19 Aug 2025 17:58:18 +0300 Subject: [PATCH 3/3] Fix deprecated GitHub Actions cache version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated actions/cache from v4.0.2 to v4 to resolve CI failures. The specific version was causing automatic failures due to deprecation. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 85478f9..0c15e8d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -94,7 +94,7 @@ jobs: run: "composer normalize --ansi --dry-run" - name: "Cache cache directory for easy-coding-standard/easy-coding-standard" - uses: "actions/cache@v4.0.2" + uses: "actions/cache@v4" with: path: ".build/ecs" key: "php-${{ matrix.php-version }}-ecs-${{ github.ref_name }}"