public static function Inline::parse

Converts a YAML string to a PHP array.

Parameters

string $value A YAML string:

Return value

array A PHP array representing the YAML string

8 calls to Inline::parse()
InlineTest::testDump in drupal/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/InlineTest.php
InlineTest::testHashStringsResemblingExponentialNumericsShouldNotBeChangedToINF in drupal/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/InlineTest.php
InlineTest::testParse in drupal/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/InlineTest.php
InlineTest::testParseInvalidMappingKeyShouldThrowException in drupal/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/InlineTest.php
@expectedException \Symfony\Component\Yaml\Exception\ParseException
InlineTest::testParseScalarWithIncorrectlyDoubleQuotedStringShouldThrowException in drupal/core/vendor/symfony/yaml/Symfony/Component/Yaml/Tests/InlineTest.php
@expectedException \Symfony\Component\Yaml\Exception\ParseException

... See full list

File

drupal/core/vendor/symfony/yaml/Symfony/Component/Yaml/Inline.php, line 32

Class

Inline
Inline implements a YAML parser/dumper for the YAML inline syntax.

Namespace

Symfony\Component\Yaml

Code

public static function parse($value) {
  $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');
  }
  switch ($value[0]) {
    case '[':
      $result = self::parseSequence($value);
      break;
    case '{':
      $result = self::parseMapping($value);
      break;
    default:
      $i = 0;
      $result = self::parseScalar($value, null, array(
        '"',
        "'",
      ), $i);

      // some comment can end the scalar
      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;
}