8000 bug #35318 [Yaml] fix PHP const mapping keys using the inline notatio… · symfony/symfony@db3134e · GitHub
[go: up one dir, main page]

Skip to content

Commit db3134e

Browse files
committed
bug #35318 [Yaml] fix PHP const mapping keys using the inline notation (xabbuh)
This PR was merged into the 3.4 branch. Discussion ---------- [Yaml] fix PHP const mapping keys using the inline notation | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #35179 | License | MIT | Doc PR | Commits ------- 45461c7 fix PHP const mapping keys using the inline notation
2 parents 764c91b + 45461c7 commit db3134e

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/Symfony/Component/Yaml/Inline.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,11 @@ private static function parseMapping($mapping, $flags, &$i = 0, $references = []
504504
$isKeyQuoted = \in_array($mapping[$i], ['"', "'"], true);
505505
$key = self::parseScalar($mapping, $flags, [':', ' '], $i, false, [], true);
506506

507+
if ('!php/const' === $key) {
508+
$key .= self::parseScalar($mapping, $flags, [':', ' '], $i, false, [], true);
509+
$key = self::evaluateScalar($key, $flags);
510+
}
511+
507512
if (':' !== $key && false === $i = strpos($mapping, ':', $i)) {
508513
break;
509514
}

src/Symfony/Component/Yaml/Tests/InlineTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public function getTestsForParsePhpConstants()
5858
['!php/const PHP_INT_MAX', PHP_INT_MAX],
5959
['[!php/const PHP_INT_MAX]', [PHP_INT_MAX]],
6060
['{ foo: !php/const PHP_INT_MAX }', ['foo' => PHP_INT_MAX]],
61+
['{ !php/const PHP_INT_MAX: foo }', [PHP_INT_MAX => 'foo']],
6162
['!php/const NULL', null],
6263
];
6364
}
@@ -93,6 +94,7 @@ public function getTestsForParseLegacyPhpConstants()
9394
['!php/const:PHP_INT_MAX', PHP_INT_MAX],
9495
['[!php/const:PHP_INT_MAX]', [PHP_INT_MAX]],
9596
['{ foo: !php/const:PHP_INT_MAX }', ['foo' => PHP_INT_MAX]],
97+
['{ !php/const:PHP_INT_MAX: foo }', [PHP_INT_MAX => 'foo']],
9698
['!php/const:NULL', null],
9799
];
98100
}

0 commit comments

Comments
 (0)
0