From 25f544c4517f608ba80548a006f8b64666aeeacb Mon Sep 17 00:00:00 2001 From: Mark <14284867+xHeaven@users.noreply.github.com> Date: Sun, 29 Dec 2024 07:43:15 +0100 Subject: [PATCH 1/2] Use proper type for is and isNot methods --- src/Comparable.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Comparable.php b/src/Comparable.php index c655912..903edb4 100644 --- a/src/Comparable.php +++ b/src/Comparable.php @@ -7,15 +7,16 @@ use Exception; use Iterator; use IteratorAggregate; +use UnitEnum; trait Comparable { - public function is(mixed $enum): bool + public function is(UnitEnum $enum): bool { return $this === $enum; } - public function isNot(mixed $enum): bool + public function isNot(UnitEnum $enum): bool { return ! $this->is($enum); } From 2911c55b84415639800c1fa339fc816686aff152 Mon Sep 17 00:00:00 2001 From: Mark <14284867+xHeaven@users.noreply.github.com> Date: Sun, 29 Dec 2024 07:43:38 +0100 Subject: [PATCH 2/2] Remove failing tests as they are not necessary anymore --- tests/Pest/ComparableTest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/Pest/ComparableTest.php b/tests/Pest/ComparableTest.php index 11c980f..93c5dcc 100644 --- a/tests/Pest/ComparableTest.php +++ b/tests/Pest/ComparableTest.php @@ -6,7 +6,6 @@ expect(Role::ADMIN->is(Role::ADMIN))->toBeTrue(); expect(Role::ADMIN->is(Role::GUEST))->toBeFalse(); - expect(Role::ADMIN->is('admin'))->toBeFalse(); }); it('the isNot method checks for inequality', function () { @@ -16,7 +15,6 @@ expect(Role::ADMIN->isNot(Role::GUEST))->toBeTrue(); expect(Role::ADMIN->isNot(Role::ADMIN))->toBeFalse(); - expect(Role::ADMIN->isNot('admin'))->toBeTrue(); }); it('the in method checks for presence in an array', function () {