From 859fb9a03cb5c6f47fda29fc84bbb91f5b8d42fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Sat, 7 Jun 2025 01:03:01 +0200 Subject: [PATCH] from(int|string), tryFrom(int|string) --- src/From.php | 4 ++-- tests/PHPStan/InvokableCases/InvokableCasesTestCase.php | 2 ++ tests/PHPStan/InvokableCasesTest.php | 2 ++ tests/Pest.php | 2 ++ tests/Pest/ComparableTest.php | 2 ++ tests/Pest/FromTest.php | 2 ++ tests/Pest/InvokableCasesTest.php | 2 ++ tests/Pest/MetadataTest.php | 2 ++ tests/Pest/NamesTest.php | 2 ++ tests/Pest/OptionsTest.php | 2 ++ tests/Pest/TraitTest.php | 2 ++ tests/Pest/ValuesTest.php | 2 ++ tests/TestCase.php | 2 ++ 13 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/From.php b/src/From.php index 07f7c94..8d75946 100644 --- a/src/From.php +++ b/src/From.php @@ -15,7 +15,7 @@ trait From * * @throws ValueError */ - public static function from(string $case): static + public static function from(int|string $case): static { return static::fromName($case); } @@ -25,7 +25,7 @@ trait From * * This will not override the `tryFrom()` method on BackedEnums */ - public static function tryFrom(string $case): ?static + public static function tryFrom(int|string $case): ?static { return static::tryFromName($case); } diff --git a/tests/PHPStan/InvokableCases/InvokableCasesTestCase.php b/tests/PHPStan/InvokableCases/InvokableCasesTestCase.php index ae04874..1b45773 100644 --- a/tests/PHPStan/InvokableCases/InvokableCasesTestCase.php +++ b/tests/PHPStan/InvokableCases/InvokableCasesTestCase.php @@ -1,5 +1,7 @@ is(Status::PENDING))->toBeTrue(); expect(Status::PENDING->is(Status::DONE))->toBeFalse(); diff --git a/tests/Pest/FromTest.php b/tests/Pest/FromTest.php index af9605a..229e510 100644 --- a/tests/Pest/FromTest.php +++ b/tests/Pest/FromTest.php @@ -1,5 +1,7 @@ expect(Status::from(0)) ->toBe(Status::PENDING); diff --git a/tests/Pest/InvokableCasesTest.php b/tests/Pest/InvokableCasesTest.php index 6dd5b8a..bd50805 100644 --- a/tests/Pest/InvokableCasesTest.php +++ b/tests/Pest/InvokableCasesTest.php @@ -1,5 +1,7 @@ color())->toBe('indigo'); expect(Role::GUEST->color())->toBe('gray'); diff --git a/tests/Pest/NamesTest.php b/tests/Pest/NamesTest.php index ec39e3f..4c51e88 100644 --- a/tests/Pest/NamesTest.php +++ b/tests/Pest/NamesTest.php @@ -1,5 +1,7 @@ expect(Status::names()) ->toBe(['PENDING', 'DONE']); diff --git a/tests/Pest/OptionsTest.php b/tests/Pest/OptionsTest.php index dda6086..e1220ed 100644 --- a/tests/Pest/OptionsTest.php +++ b/tests/Pest/OptionsTest.php @@ -1,5 +1,7 @@ expect(Status::options())->toBe([ 'PENDING' => 0, diff --git a/tests/Pest/TraitTest.php b/tests/Pest/TraitTest.php index 43730aa..6bbcae5 100644 --- a/tests/Pest/TraitTest.php +++ b/tests/Pest/TraitTest.php @@ -1,5 +1,7 @@ expect(Status::values()) ->toBe([0, 1]); diff --git a/tests/TestCase.php b/tests/TestCase.php index bb466c9..3edb27c 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -1,5 +1,7 @@