Skip to content

Commit e051412

Browse files
authored
Initialize enum array in EnumRegistry to avoid TypeError when empty (#54)
1 parent 8e56a65 commit e051412

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/EnumRegistry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ final class EnumRegistry
1515
/**
1616
* @var EnumInterface[]
1717
*/
18-
private $enums;
18+
private $enums = [];
1919

2020
/**
2121
* @param EnumInterface $enum

tests/Unit/EnumRegistryTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,13 @@ public function testGetInvalidException(): void
3333
$registry->get('type');
3434
}
3535

36-
public function testAddNominal(): void
36+
public function testEmpty(): void
37+
{
38+
$registry = new EnumRegistry();
39+
self::assertSame([], $registry->all());
40+
}
41+
42+
public function testNominal(): void
3743
{
3844
$translator = new Translator([]);
3945
$state = new StateEnum();

0 commit comments

Comments
 (0)