public static function Inline::parse in Loft Data Grids 7.2
Same name and namespace in other branches
- 6.2 vendor/symfony/yaml/Symfony/Component/Yaml/Inline.php \Symfony\Component\Yaml\Inline::parse()
Converts a YAML string to a PHP value.
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
mixed A PHP value
Throws
25 calls to Inline::parse()
- InlineTest::testBooleanMappingKeysAreConvertedToStrings in vendor/
symfony/ yaml/ Tests/ InlineTest.php - InlineTest::testDump in vendor/
symfony/ yaml/ Tests/ InlineTest.php - @dataProvider getTestsForDump
- InlineTest::testHashStringsResemblingExponentialNumericsShouldNotBeChangedToINF in vendor/
symfony/ yaml/ Tests/ InlineTest.php - InlineTest::testNotSupportedMissingValue in vendor/
symfony/ yaml/ Tests/ InlineTest.php - @expectedException \Symfony\Component\Yaml\Exception\ParseException @expectedExceptionMessage Malformed inline YAML string: {this, is not, supported}.
- InlineTest::testParse in vendor/
symfony/ yaml/ Tests/ InlineTest.php - @dataProvider getTestsForParse
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 (2 & (int) ini_get('mbstring.func_overload')) {
$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;
}