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

Appearance settings

Commit a2ad4fa

Browse filesBrowse files
committed
fix handling float-like key attribute values
1 parent 3ee310f commit a2ad4fa
Copy full SHA for a2ad4fa

File tree

Expand file treeCollapse file tree

2 files changed

+30
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+30
-0
lines changed

‎src/Symfony/Component/Config/Definition/PrototypedArrayNode.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Definition/PrototypedArrayNode.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,10 @@ protected function normalizeValue($value)
237237
} elseif (isset($v[$this->keyAttribute])) {
238238
$k = $v[$this->keyAttribute];
239239

240+
if (\is_float($k)) {
241+
$k = var_export($k, true);
242+
}
243+
240244
// remove the key attribute when required
241245
if ($this->removeKeyAttribute) {
242246
unset($v[$this->keyAttribute]);

‎src/Symfony/Component/Config/Tests/Definition/NormalizationTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Tests/Definition/NormalizationTest.php
+26Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,32 @@ public function testAssociativeArrayPreserveKeys()
201201
$this->assertNormalized($tree, $data, $data);
202202
}
203203

204+
public function testFloatLikeValueAsMapKeyAttribute()
205+
{
206+
$tree = (new TreeBuilder('root'))
207+
->getRootNode()
208+
->useAttributeAsKey('number')
209+
->arrayPrototype()
210+
->children()
211+
->scalarNode('foo')->end()
212+
->end()
213+
->end()
214+
->end()
215+
->buildTree()
216+
;
217+
218+
$this->assertNormalized($tree, [
219+
[
220+
'number' => 3.0,
221+
'foo' => 'bar',
222+
],
223+
], [
224+
'3.0' => [
225+
'foo' => 'bar',
226+
],
227+
]);
228+
}
229+
204230
public static function assertNormalized(NodeInterface $tree, $denormalized, $normalized)
205231
{
206232
self::assertSame($normalized, $tree->normalize($denormalized));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.