-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Allow to define Enum nodes with 1 single element #15433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,8 +25,8 @@ class EnumNode extends ScalarNode | |
public function __construct($name, NodeInterface $parent = null, array $values = array()) | ||
{ | ||
$values = array_unique($values); | ||
if (count($values) <= 1) { | ||
throw new \InvalidArgumentException('$values must contain at least two distinct elements.'); | ||
if (empty($values)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would keep a validation to forbid empty arrays (which does not make sense as it makes the config unusable) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree. Done in javiereguiluz@e75a983 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know. What is the usual Symfony practice? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer |
||
throw new \InvalidArgumentException('$values must contain at least one element.'); | ||
} | ||
|
||
parent::__construct($name, $parent); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed t 8000 o describe this comment to others. Learn more.
the UPGRADE file is about showing required/recommended changes because of BC breaks of deprecations.
this is just adding a new feature in a BC way, so a line in the changelog would be enough. Adding it in the UPGRADE file just makes the file less focused