Closed
Description
Hi,
The enum node definition for the symfony config component is great.. but i cant specify only 1 option:
InvalidArgumentException in EnumNodeDefinition.php line 35:
->values() must be called with at least two distinct values.
Why is this limited? I.e. an enum with 1 option would still be an enum, imho.
We use some class property for the available values, so we have a single point of entrance where we can comment out an available value, ie;
static private $values = ['a', 'b'];
// ...
->enumNode('foo')
->values(self::$values)
->defaultValue(reset(self::$values))
->end()
This way removing the available value 'b' enforces you to refactor the enum node to a scalar node with custom validation (in_array that is), almost like the enum type does ;-)