Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit22b8490

Browse files
skafandrifabpot
authored andcommitted
#20921 [Config] Provide shorthand methods for ArrayNodeDefinition::pr…
1 parente98c068 commit22b8490

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+
publicfunctionvariablePrototype()
86+
{
87+
return$this->prototype('variable');
88+
}
89+
90+
/**
91+
* @return ScalarNodeDefinition
92+
*/
93+
publicfunctionscalarPrototype()
94+
{
95+
return$this->prototype('scalar');
96+
}
97+
98+
/**
99+
* @return BooleanNodeDefinition
100+
*/
101+
publicfunctionbooleanPrototype()
102+
{
103+
return$this->prototype('boolean');
104+
}
105+
106+
/**
107+
* @return IntegerNodeDefinition
108+
*/
109+
publicfunctionintegerPrototype()
110+
{
111+
return$this->prototype('integer');
112+
}
113+
114+
/**
115+
* @return FloatNodeDefinition
116+
*/
117+
publicfunctionfloatPrototype()
118+
{
119+
return$this->prototype('float');
120+
}
121+
122+
/**
123+
* @return ArrayNodeDefinition
124+
*/
125+
publicfunctionarrayPrototype()
126+
{
127+
return$this->prototype('array');
128+
}
129+
130+
/**
131+
* @return EnumNodeDefinition
132+
*/
133+
publicfunctionenumPrototype()
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+
publicfunctiontestPrototypeVariable()
231+
{
232+
$node =newArrayNodeDefinition('root');
233+
$this->assertEquals($node->prototype('variable'),$node->variablePrototype());
234+
}
235+
236+
publicfunctiontestPrototypeScalar()
237+
{
238+
$node =newArrayNodeDefinition('root');
239+
$this->assertEquals($node->prototype('scalar'),$node->scalarPrototype());
240+
}
241+
242+
publicfunctiontestPrototypeBoolean()
243+
{
244+
$node =newArrayNodeDefinition('root');
245+
$this->assertEquals($node->prototype('boolean'),$node->booleanPrototype());
246+
}
247+
248+
publicfunctiontestPrototypeInteger()
249+
{
250+
$node =newArrayNodeDefinition('root');
251+
$this->assertEquals($node->prototype('integer'),$node->integerPrototype());
252+
}
253+
254+
publicfunctiontestPrototypeFloat()
255+
{
256+
$node =newArrayNodeDefinition('root');
257+
$this->assertEquals($node->prototype('float'),$node->floatPrototype());
258+
}
259+
260+
publicfunctiontestPrototypeArray()
261+
{
262+
$node =newArrayNodeDefinition('root');
263+
$this->assertEquals($node->prototype('array'),$node->arrayPrototype());
264+
}
265+
266+
publicfunctiontestPrototypeEnum()
267+
{
268+
$node =newArrayNodeDefinition('root');
269+
$this->assertEquals($node->prototype('enum'),$node->enumPrototype());
270+
}
271+
230272
publicfunctiongetEnableableNodeFixtures()
231273
{
232274
returnarray(

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp