Skip to content

Commit 92af136

Browse files
Merge pull request #790 from spatie/revert-776-main
Revert "Add Support for Predefined Enum Collections in DataObject Initialization"
2 parents c5bcc48 + 8ade75a commit 92af136

File tree

2 files changed

+1
-17
lines changed

2 files changed

+1
-17
lines changed

src/Casts/EnumCast.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ protected function castValue(
3838

3939
/** @var class-string<\BackedEnum> $type */
4040
try {
41-
return $value instanceof $type && $value === $type::from($value->value) ? $value : $type::from($value);
41+
return $type::from($value);
4242
} catch (Throwable $e) {
4343
throw CannotCastEnum::create($type, $value);
4444
}

tests/Casts/EnumCastTest.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,3 @@
7171
)
7272
->toEqual(Uncastable::create());
7373
});
74-
75-
76-
it('it can create data when enum is already casted', function () {
77-
$class = new class () {
78-
public DummyBackedEnum $enum;
79-
};
80-
81-
expect(
82-
$this->caster->cast(
83-
FakeDataStructureFactory::property($class, 'enum'),
84-
DummyBackedEnum::FOO,
85-
[],
86-
CreationContextFactory::createFromConfig($class::class)->get()
87-
)
88-
)->toEqual(DummyBackedEnum::FOO);
89-
});

0 commit comments

Comments
 (0)