From 8c89d805ef83d73dad9b5a160d7b4a36b4f7fa40 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Thu, 22 Jan 2026 12:22:19 +0100 Subject: [PATCH 1/2] TrinaryLogic: detect logic errors --- src/TrinaryLogic.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/TrinaryLogic.php b/src/TrinaryLogic.php index 81db0e1159..fe08c0aa69 100644 --- a/src/TrinaryLogic.php +++ b/src/TrinaryLogic.php @@ -53,16 +53,28 @@ private static function create(int $value): self return self::$registry[$value]; } + /** + * @phpstan-assert-if-true =false $this->no() + * @phpstan-assert-if-true =false $this->maybe() + */ public function yes(): bool { return $this->value === self::YES; } + /** + * @phpstan-assert-if-true =false $this->no() + * @phpstan-assert-if-true =false $this->yes() + */ public function maybe(): bool { return $this->value === self::MAYBE; } + /** + * @phpstan-assert-if-true =false $this->maybe() + * @phpstan-assert-if-true =false $this->yes() + */ public function no(): bool { return $this->value === self::NO; From c6aa3e8a3c6a03150a346e1c0f1ed46021ec07d2 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Thu, 22 Jan 2026 12:29:07 +0100 Subject: [PATCH 2/2] cover more trinary-like classes --- src/Type/AcceptsResult.php | 12 ++++++++++++ src/Type/IsSuperTypeOfResult.php | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/Type/AcceptsResult.php b/src/Type/AcceptsResult.php index 2358285f16..36a3b598cf 100644 --- a/src/Type/AcceptsResult.php +++ b/src/Type/AcceptsResult.php @@ -26,16 +26,28 @@ public function __construct( { } + /** + * @phpstan-assert-if-true =false $this->no() + * @phpstan-assert-if-true =false $this->maybe() + */ public function yes(): bool { return $this->result->yes(); } + /** + * @phpstan-assert-if-true =false $this->no() + * @phpstan-assert-if-true =false $this->yes() + */ public function maybe(): bool { return $this->result->maybe(); } + /** + * @phpstan-assert-if-true =false $this->maybe() + * @phpstan-assert-if-true =false $this->yes() + */ public function no(): bool { return $this->result->no(); diff --git a/src/Type/IsSuperTypeOfResult.php b/src/Type/IsSuperTypeOfResult.php index c1decae155..7fddea5c04 100644 --- a/src/Type/IsSuperTypeOfResult.php +++ b/src/Type/IsSuperTypeOfResult.php @@ -26,16 +26,28 @@ public function __construct( { } + /** + * @phpstan-assert-if-true =false $this->no() + * @phpstan-assert-if-true =false $this->maybe() + */ public function yes(): bool { return $this->result->yes(); } + /** + * @phpstan-assert-if-true =false $this->no() + * @phpstan-assert-if-true =false $this->yes() + */ public function maybe(): bool { return $this->result->maybe(); } + /** + * @phpstan-assert-if-true =false $this->maybe() + * @phpstan-assert-if-true =false $this->yes() + */ public function no(): bool { return $this->result->no();