Skip to content

Commit aa46bc2

Browse files
committed
fix PHP const mapping keys using the inline notation
1 parent ef67314 commit aa46bc2

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

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
}

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)