Skip to content

Commit

Permalink
Initialize enum array in EnumRegistry to avoid TypeError when empty (#54
Browse files Browse the repository at this point in the history
)
  • Loading branch information
yann-eugone authored Mar 28, 2022
1 parent 8e56a65 commit e051412
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/EnumRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class EnumRegistry
/**
* @var EnumInterface[]
*/
private $enums;
private $enums = [];

/**
* @param EnumInterface $enum
Expand Down
8 changes: 7 additions & 1 deletion tests/Unit/EnumRegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@ public function testGetInvalidException(): void
$registry->get('type');
}

public function testAddNominal(): void
public function testEmpty(): void
{
$registry = new EnumRegistry();
self::assertSame([], $registry->all());
}

public function testNominal(): void
{
$translator = new Translator([]);
$state = new StateEnum();
Expand Down

0 comments on commit e051412

Please sign in to comment.