forked from kstefan/enum
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Milestone
Description
You can now define following Enum as you can see in AbstractEnumTest::testConstructWithMixed():
class EntityStatusEnum extends AbstractEnum
{
public const NEW_ENTITY = 'new';
public const MODIFIED_ENTITY = 2;
public const SAVED_ENTITY = 'saved';
}
This is fully supported and can cause some issues in integrations.
You can also set value to a null, but the Enum will behave very unpredictably with default value. You can see such an example in AbstractEnumTest ::testConstructWithNullAndMixed().
class EntityStatusMixedTypeWithNullEnum extends AbstractEnum
{
public const NEW_ENTITY = null;
public const MODIFIED_ENTITY = 2;
public const SAVED_ENTITY = 'saved';
public const DEFAULT_ENTITY_STATUS = 'default-value';
protected static $defaultValue = self::DEFAULT_ENTITY_STATUS;
}
The goal is to avoid:
- mixed values of Enums, which will bring even more stricter behavior from which a developer can benefit
- null values and default values must not be used anymore, because they cause confusion
Reactions are currently unavailable