8000 feature #7194 Added docs for Yaml::PARSE_CONSTANT (javiereguiluz) · a-ast/symfony-docs@f415141 · GitHub
[go: up one dir, main page]

Skip to content

Commit f415141

Browse files
committed
feature symfony#7194 Added docs for Yaml::PARSE_CONSTANT (javiereguiluz)
This PR was squashed before being merged into the 3.2 branch (closes symfony#7194). Discussion ---------- Added docs for Yaml::PARSE_CONSTANT This fixes symfony#7178. Commits ------- fe7f5c5 Added docs for Yaml::PARSE_CONSTANT
2 parents b06a83a + fe7f5c5 commit f415141

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

components/yaml.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,17 @@ flag::
293293
// Line
294294
// String
295295

296+
Parsing PHP Constants
297+
~~~~~~~~~~~~~~~~~~~~~
298+
299+
By default, the YAML parser treats the PHP constants included in the contents as
300+
regular strings. Use the ``PARSE_CONSTANT`` flag and the special ``!php/const:``
301+
syntax to parse them as proper PHP constants::
302+
303+
$yaml = '{ foo: PHP_INT_SIZE, bar: !php/const:PHP_INT_SIZE }';
304+
$parameters = Yaml::parse($yaml, Yaml::PARSE_CONSTANT);
305+
// $parameters = array('foo' => 'PHP_INT_SIZE', 'bar' => 8);
306+
296307
Syntax Validation
297308
~~~~~~~~~~~~~~~~~
298309

0 commit comments

Comments
 (0)
0