Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Yaml] add inline parser context initializer #24060

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions 21 src/Symfony/Component/Yaml/Inline.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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);

Expand Down
4 changes: 1 addition & 3 deletions 4 src/Symfony/Component/Yaml/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.