From 5dab7e6cdf108aa1185da1ad4daa01d61dad9c80 Mon Sep 17 00:00:00 2001 From: "Zaid J. Barghouthi" Date: Mon, 27 Oct 2025 17:39:52 +0000 Subject: [PATCH 1/2] make types covariant --- src/Result.php | 4 ++-- src/Result/Err.php | 2 +- src/Result/Ok.php | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Result.php b/src/Result.php index 53728cf..b4aa6bb 100644 --- a/src/Result.php +++ b/src/Result.php @@ -18,10 +18,10 @@ /** * Describes a Result * - * @template T + * @template-covariant T * The Ok value * - * @template E + * @template-covariant E * The Err value */ abstract class Result diff --git a/src/Result/Err.php b/src/Result/Err.php index 1212f99..735774b 100644 --- a/src/Result/Err.php +++ b/src/Result/Err.php @@ -20,7 +20,7 @@ /** * Err * - * @template E + * @template-covariant E * The Err value * * @extends Result diff --git a/src/Result/Ok.php b/src/Result/Ok.php index 81305a2..4d0f0c0 100644 --- a/src/Result/Ok.php +++ b/src/Result/Ok.php @@ -17,12 +17,13 @@ use Prewk\Result; use Stringable; use Throwable; + use function is_string; /** * Ok * - * @template T + * @template-covariant T * The Ok value * * @extends Result From 0ddeee18aae3578c70865da2ce7e2ef1b11d2e2f Mon Sep 17 00:00:00 2001 From: "Zaid J. Barghouthi" Date: Mon, 27 Oct 2025 20:51:24 +0000 Subject: [PATCH 2/2] wip --- src/Result/Ok.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Result/Ok.php b/src/Result/Ok.php index 4d0f0c0..8e8e6b1 100644 --- a/src/Result/Ok.php +++ b/src/Result/Ok.php @@ -17,7 +17,6 @@ use Prewk\Result; use Stringable; use Throwable; - use function is_string; /**