public static function Inline::parse in Translation template extractor 6.3
Same name and namespace in other branches
- 7.3 vendor/Symfony/Component/Yaml/Inline.php \Symfony\Component\Yaml\Inline::parse()
- 7.2 vendor/Symfony/Component/Yaml/Inline.php \Symfony\Component\Yaml\Inline::parse()
Converts a YAML string to a PHP array.
Parameters
string $value A YAML string:
Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise:
Boolean $objectSupport true if object support is enabled, false otherwise:
Return value
array A PHP array representing the YAML string
Throws
10 calls to Inline::parse()
- InlineTest::testDump in vendor/
Symfony/ Component/ Yaml/ Tests/ InlineTest.php - InlineTest::testHashStringsResemblingExponentialNumericsShouldNotBeChangedToINF in vendor/
Symfony/ Component/ Yaml/ Tests/ InlineTest.php - InlineTest::testParse in vendor/
Symfony/ Component/ Yaml/ Tests/ InlineTest.php - InlineTest::testParseInvalidMappingKeyShouldThrowException in vendor/
Symfony/ Component/ Yaml/ Tests/ InlineTest.php - @expectedException \Symfony\Component\Yaml\Exception\ParseException
- InlineTest::testParseInvalidMappingShouldThrowException in vendor/
Symfony/ Component/ Yaml/ Tests/ InlineTest.php - @expectedException \Symfony\Component\Yaml\Exception\ParseException
File
- vendor/
Symfony/ Component/ Yaml/ Inline.php, line 39
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) {
self::$exceptionOnInvalidType = $exceptionOnInvalidType;
self::$objectSupport = $objectSupport;
$value = trim($value);
if (0 == strlen($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);
++$i;
break;
case '{':
$result = self::parseMapping($value, $i);
++$i;
break;
default:
$result = self::parseScalar($value, null, array(
'"',
"'",
), $i);
}
// 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;
}