diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index c78c811baa5a7..fee21eb34ecc2 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -33,6 +33,22 @@ class Inline private static $objectForMap = false; private static $constantSupport = false; + /** + * @param int $flags + * @param int|null $parsedLineNumber + */ + public static function initialize($flags, $parsedLineNumber = null) + { + self::$exceptionOnInvalidType = (bool) (Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE & $flags); + self::$objectSupport = (bool) (Yaml::PARSE_OBJECT & $flags); + self::$objectForMap = (bool) (Yaml::PARSE_OBJECT_FOR_MAP & $flags); + self::$constantSupport = (bool) (Yaml::PARSE_CONSTANT & $flags); + + if (null !== $parsedLineNumber) { + self::$parsedLineNumber = $parsedLineNumber; + } + } + /** * Converts a YAML string to a PHP value. * @@ -78,10 +94,7 @@ public static function parse($value, $flags = 0, $references = array()) } } - self::$exceptionOnInvalidType = (bool) (Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE & $flags); - self::$objectSupport = (bool) (Yaml::PARSE_OBJECT & $flags); - self::$objectForMap = (bool) (Yaml::PARSE_OBJECT_FOR_MAP & $flags); - self::$constantSupport = (bool) (Yaml::PARSE_CONSTANT & $flags); + self::initialize($flags); $value = trim($value); diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index b39512c869d14..042d9d186d273 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -222,10 +222,8 @@ private function doParse($value, $flags) } $context = 'mapping'; - // force correct settings - Inline::parse(null, $flags, $this->refs); + Inline::initialize($flags, $this->getRealCurrentLineNb()); try { - Inline::$parsedLineNumber = $this->getRealCurrentLineNb(); $i = 0; $evaluateKey = !(Yaml::PARSE_KEYS_AS_STRINGS & $flags);