public static function Inline::parse in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/yaml/Inline.php \Symfony\Component\Yaml\Inline::parse()
Converts a YAML string to a PHP array.
Parameters
string $value A YAML string:
bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise:
bool $objectSupport true if object support is enabled, false otherwise:
bool $objectForMap true if maps should return a stdClass instead of array():
array $references Mapping of variable names to values:
Return value
array A PHP array representing the YAML string
Throws
15 calls to Inline::parse()
- InlineTest::testDump in vendor/
symfony/ yaml/ Tests/ InlineTest.php - @dataProvider getTestsForDump
- InlineTest::testHashStringsResemblingExponentialNumericsShouldNotBeChangedToINF in vendor/
symfony/ yaml/ Tests/ InlineTest.php - InlineTest::testParse in vendor/
symfony/ yaml/ Tests/ InlineTest.php - @dataProvider getTestsForParse
- InlineTest::testParseInvalidMappingKeyShouldThrowException in vendor/
symfony/ yaml/ Tests/ InlineTest.php - @expectedException \Symfony\Component\Yaml\Exception\ParseException
- InlineTest::testParseInvalidMappingShouldThrowException in vendor/
symfony/ yaml/ Tests/ InlineTest.php - @expectedException \Symfony\Component\Yaml\Exception\ParseException
File
- vendor/
symfony/ yaml/ Inline.php, line 43
Class
- Inline
- Inline implements a YAML parser/dumper for the YAML inline syntax.
Namespace
Symfony\Component\YamlCode
public static function parse($value, $exceptionOnInvalidType = false, $objectSupport = false, $objectForMap = false, $references = array()) {
self::$exceptionOnInvalidType = $exceptionOnInvalidType;
self::$objectSupport = $objectSupport;
self::$objectForMap = $objectForMap;
$value = trim($value);
if ('' === $value) {
return '';
}
if (function_exists('mb_internal_encoding') && (int) ini_get('mbstring.func_overload') & 2) {
$mbEncoding = mb_internal_encoding();
mb_internal_encoding('ASCII');
}
$i = 0;
switch ($value[0]) {
case '[':
$result = self::parseSequence($value, $i, $references);
++$i;
break;
case '{':
$result = self::parseMapping($value, $i, $references);
++$i;
break;
default:
$result = self::parseScalar($value, null, array(
'"',
"'",
), $i, true, $references);
}
// some comments are allowed at the end
if (preg_replace('/\\s+#.*$/A', '', substr($value, $i))) {
throw new ParseException(sprintf('Unexpected characters near "%s".', substr($value, $i)));
}
if (isset($mbEncoding)) {
mb_internal_encoding($mbEncoding);
}
return $result;
}