You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
You can now define following Enum as you can see in
AbstractEnumTest::testConstructWithMixed()
: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()
.The goal is to avoid:
The text was updated successfully, but these errors were encountered: