8000 feature #20923 #20921 [Config] Provide shorthand methods for ArrayNod… · symfony/symfony@d221a4e · GitHub
[go: up one dir, main page]

Skip to content

Commit d221a4e

Browse files
committed
feature #20923 #20921 [Config] Provide shorthand methods for ArrayNodeDefinition::pr… (skafandri)
This PR was squashed before being merged into the 3.3-dev branch (closes #20923). Discussion ---------- #20921 [Config] Provide shorthand methods for ArrayNodeDefinition::pr… | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #20921 | License | MIT Commits ------- 22b8490 #20921 [Config] Provide shorthand methods for ArrayNodeDefinition::pr…
2 parents 3c4e65f + 22b8490 commit d221a4e

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed

src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,62 @@ public function prototype($type)
7979
return $this->prototype = $this->getNodeBuilder()->node(null, $type)->setParent($this);
8080
}
8181

82+
/**
83+
* @return VariableNodeDefinition
84+
*/
85+
public function variablePrototype()
86+
{
87+
return $this->prototype('variable');
88+
}
89+
90+
/**
91+
* @return ScalarNodeDefinition
92+
*/
93+
public function scalarPrototype()
94+
{
95+
return $this->prototype('scalar');
96+
}
97+
98+
/**
99+
* @return BooleanNodeDefinition
100+
*/
101+
public function booleanPrototype()
102+
{
103+
return $this->prototype('boolean');
104+
}
105+
106+
/**
107+
* @return IntegerNodeDefinition
108+
*/
109+
public function integerPrototype()
110+
{
111+
return $this->prototype('integer');
112+
}
113+
114+
/**
115+
* @return FloatNodeDefinition
116+
*/
117+
public function floatPrototype()
118+
{
119+
return $this->prototype('float');
120+
}
121+
122+
/**
123+
* @return ArrayNodeDefinition
124+
*/
125+
public function arrayPrototype()
126+
{
127+
return $this->prototype(& 10000 #39;array');
128+
}
129+
130+
/**
131+
* @return EnumNodeDefinition
132+
*/
133+
public function enumPrototype()
134+
{
135+
return $this->prototype('enum');
136+
}
137+
82138
/**
83139
* Adds the default value if the node is not set in the configuration.
84140
*

src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,48 @@ public function testNormalizeKeys()
227227
$this->assertFalse($this->getField($node, 'normalizeKeys'));
228228
}
229229

230+
public function testPrototypeVariable()
231+
{
232+
$node = new ArrayNodeDefinition('root');
233+
$this->assertEquals($node->prototype('variable'), $node->variablePrototype());
234+
}
235+
236+
public function testPrototypeScalar()
237+
{
238+
$node = new ArrayNodeDefinition('root');
239+
$this->assertEquals($node->prototype('scalar'), $node->scalarPrototype());
240+
}
241+
242+
public function testPrototypeBoolean()
243+
{
244+
$node = new ArrayNodeDefinition('root');
245+
$this->assertEquals($node->prototype('boolean'), $node->booleanPrototype());
246+
}
247+
248+
public function testPrototypeInteger()
249+
{
250+
$node = new ArrayNodeDefinition('root');
251+
$this->assertEquals($node->prototype('integer'), $node->integerPrototype());
252+
}
253+
254+
public function testPrototypeFloat()
255+
{
256+
$node = new ArrayNodeDefinition('root');
257+
$this->assertEquals($node->prototype('float'), $node->floatPrototype());
258+
}
259+
260+
public function testPrototypeArray()
261+
{
262+
$node = new ArrayNodeDefinition('root');
263+
$this->assertEquals($node->prototype('array'), $node->arrayPrototype());
264+
}
265+
266+
public function testPrototypeEnum()
267+
{
268+
$node = new ArrayNodeDefinition('root');
269+
$this->assertEquals($node->prototype('enum'), $node->enumPrototype());
270+
}
271+
230272
public function getEnableableNodeFixtures()
231273
{
232274
return array(

0 commit comments

Comments
 (0)
0