fix PHP const mapping keys using the inline notation
This commit is contained in:
parent
d1e31a4fe0
commit
45461c73bf
@ -504,6 +504,11 @@ class Inline
|
|||||||
$isKeyQuoted = \in_array($mapping[$i], ['"', "'"], true);
|
$isKeyQuoted = \in_array($mapping[$i], ['"', "'"], true);
|
||||||
$key = self::parseScalar($mapping, $flags, [':', ' '], $i, false, [], true);
|
$key = self::parseScalar($mapping, $flags, [':', ' '], $i, false, [], true);
|
||||||
|
|
||||||
|
if ('!php/const' === $key) {
|
||||||
|
$key .= self::parseScalar($mapping, $flags, [':', ' '], $i, false, [], true);
|
||||||
|
$key = self::evaluateScalar($key, $flags);
|
||||||
|
}
|
||||||
|
|
||||||
if (':' !== $key && false === $i = strpos($mapping, ':', $i)) {
|
if (':' !== $key && false === $i = strpos($mapping, ':', $i)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,7 @@ class InlineTest extends TestCase
|
|||||||
['!php/const PHP_INT_MAX', PHP_INT_MAX],
|
['!php/const PHP_INT_MAX', PHP_INT_MAX],
|
||||||
['[!php/const PHP_INT_MAX]', [PHP_INT_MAX]],
|
['[!php/const PHP_INT_MAX]', [PHP_INT_MAX]],
|
||||||
['{ foo: !php/const PHP_INT_MAX }', ['foo' => PHP_INT_MAX]],
|
['{ foo: !php/const PHP_INT_MAX }', ['foo' => PHP_INT_MAX]],
|
||||||
|
['{ !php/const PHP_INT_MAX: foo }', [PHP_INT_MAX => 'foo']],
|
||||||
['!php/const NULL', null],
|
['!php/const NULL', null],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -93,6 +94,7 @@ class InlineTest extends TestCase
|
|||||||
['!php/const:PHP_INT_MAX', PHP_INT_MAX],
|
['!php/const:PHP_INT_MAX', PHP_INT_MAX],
|
||||||
['[!php/const:PHP_INT_MAX]', [PHP_INT_MAX]],
|
['[!php/const:PHP_INT_MAX]', [PHP_INT_MAX]],
|
||||||
['{ foo: !php/const:PHP_INT_MAX }', ['foo' => PHP_INT_MAX]],
|
['{ foo: !php/const:PHP_INT_MAX }', ['foo' => PHP_INT_MAX]],
|
||||||
|
['{ !php/const:PHP_INT_MAX: foo }', [PHP_INT_MAX => 'foo']],
|
||||||
['!php/const:NULL', null],
|
['!php/const:NULL', null],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user