-
-
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
Conversation
javiereguiluz
commented
Aug 2, 2015
Q | A |
---|---|
Bug fix? | no |
New feature? | yes |
BC breaks? | yes |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | #15402 |
License | MIT |
Doc PR | - |
@@ -24,13 +24,8 @@ class EnumNode extends ScalarNode | |||
|
|||
public function __construct($name, NodeInterface $parent = null, array $values = array()) | |||
{ | |||
$values = array_unique($values); | |||
if (count($values) <= 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. Done in javiereguiluz@e75a983
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Why not 0 === count($values)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer empty
here
@javiereguiluz Can you add a note in the UPGRADE file? |
Thank you @javiereguiluz. |
@@ -399,3 +399,23 @@ FrameworkBundle | |||
session: | |||
cookie_httponly: false | |||
``` | |||
|
|||
Config | |||
------ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to 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
…buh) This PR was merged into the 2.8 branch. Discussion ---------- [Config] move feature description to changelog file | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #15433 | License | MIT | Doc PR | Commits ------- e1818bd move feature description to changelog file
@javiereguiluz: This actually fixes the issue in the |
@ogizanagi :'( thanks for reporting this error. I've created a new issue to fix it: #17774 |
…es with one element (ogizanagi) This PR was merged into the 2.8 branch. Discussion ---------- [Config] Fix EnumNodeDefinition to allow building enum nodes with one element | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #15433, #17774 | License | MIT | Doc PR | - Commits ------- e9111e4 [Config] Fix EnumNodeDefinition to allow building enum nodes with one element