From 5a0125768489682b8bd3763a9657711b2c105032 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 28 Nov 2016 17:47:41 +0100 Subject: [PATCH 1/2] Added docs for Yaml::PARSE_CONSTANT --- components/yaml.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/components/yaml.rst b/components/yaml.rst index a04ad7afe35..5dc0c0deac3 100644 --- a/components/yaml.rst +++ b/components/yaml.rst @@ -293,6 +293,17 @@ flag:: // Line // String +Parsing PHP Constants +~~~~~~~~~~~~~~~~~~~~~ + +By default the YAML parser treats the PHP constants included in the contents as +regular strings. Use the ``PARSE_CONSTANT`` flag and the special ``!php/const:`` +syntax to parse them as proper PHP constants:: + + $yaml = '{ foo: PHP_INT_SIZE, bar: !php/const:PHP_INT_SIZE }'; + $parameters = Yaml::parse($yaml, Yaml::PARSE_CONSTANT); + // $parameters = array('foo' => 'PHP_INT_SIZE', 'bar' => 8); + Syntax Validation ~~~~~~~~~~~~~~~~~ From 06f344aad224292fafbd7da522ab9f4e80de747b Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 29 Nov 2016 10:10:10 +0100 Subject: [PATCH 2/2] Added a comma --- components/yaml.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/yaml.rst b/components/yaml.rst index 5dc0c0deac3..b7ceec4e25a 100644 --- a/components/yaml.rst +++ b/components/yaml.rst @@ -296,7 +296,7 @@ flag:: Parsing PHP Constants ~~~~~~~~~~~~~~~~~~~~~ -By default the YAML parser treats the PHP constants included in the contents as +By default, the YAML parser treats the PHP constants included in the contents as regular strings. Use the ``PARSE_CONSTANT`` flag and the special ``!php/const:`` syntax to parse them as proper PHP constants::