protected static function parseSequence($sequence, &$i = 0)
  {
    $output = array();
    $len = strlen($sequence);
    $i += 1;

    // [foo, bar, ...]
    while ($i < $len) {
      switch ($sequence[$i]) {
        case '[':
          // nested sequence
          $output[] = self::parseSequence($sequence, $i);
          break;
        case '{':
          // nested mapping
          $output[] = self::parseMapping($sequence, $i);
          break;
        case ']':
          return $output;
        case ',':
        case ' ':
          break;
        default:
          $isQuoted = in_array($sequence[$i], array('"', "'"));
          $value = self::parseScalar($sequence, array(',', ']'), array('"', "'"), $i);

          if (!$isQuoted && false !== strpos($value, ': ')) {
            // embedded mapping?
            try {
              $value = self::parseMapping('{'.$value.'}');
            } catch (InvalidArgumentException $e) {
              // no, it's not
            }
          }

          $output[] = $value;

          --$i;
      }

      ++$i;
    }

    throw new InvalidArgumentException(sprintf('Malformed inline YAML string %s', $sequence));
  }
protected static function parseSequence($sequence, &$i = 0)
  {
    $output = array();
    $len = strlen($sequence);
    $i += 1;

    // [foo, bar, ...]
    while ($i < $len) {
      switch ($sequence[$i]) {
        case '[':
          // nested sequence
          $output[] = self::parseSequence($sequence, $i);
          break;
        case '{':
          // nested mapping
          $output[] = self::parseMapping($sequence, $i);
          break;
        case ']':
          return $output;
        case ',':
        case ' ':
          break;
        default:
          $isQuoted = in_array($sequence[$i], array('"', "'"));
          $value = self::parseScalar($sequence, array(',', ']'), array('"', "'"), $i);

          if (!$isQuoted && false !== strpos($value, ': ')) {
            // embedded mapping?
            try {
              $value = self::parseMapping('{'.$value.'}');
            } catch (InvalidArgumentException $e) {
              // no, it's not
            }
          }

          $output[] = $value;

          --$i;
      }

      ++$i;
    }

    throw new InvalidArgumentException(sprintf('Malformed inline YAML string %s', $sequence));
  }
protected static function parseSequence ( $ sequence , & $ i = 0 ) { $ output = array ( ) ; $ len = strlen ( $ sequence ) ; $ i += 1 ; // [foo, bar, ...] while ( $ i < $ len ) { switch ( $ sequence [ $ i ] ) { case '[' : // nested sequence $ output [ ] = self :: parseSequence ( $ sequence , $ i ) ; break ; case '{' : // nested mapping $ output [ ] = self :: parseMapping ( $ sequence , $ i ) ; break ; case ']' : return $ output ; case ',' : case ' ' : break ; default : $ isQuoted = in_array ( $ sequence [ $ i ] , array ( '"' , "'" ) ) ; $ value = self :: parseScalar ( $ sequence , array ( ',' , ']' ) , array ( '"' , "'" ) , $ i ) ; if ( ! $ isQuoted && false !== strpos ( $ value , ': ' ) ) { // embedded mapping? try { $ value = self :: parseMapping ( '{' . $ value . '}' ) ; } catch ( InvalidArgumentException $ e ) { // no, it's not } } $ output [ ] = $ value ; -- $ i ; } ++ $ i ; } throw new InvalidArgumentException ( sprintf ( 'Malformed inline YAML string %s' , $ sequence ) ) ; }
Parses a sequence to a YAML string.

@param string  $sequence
@param integer $i

@return string A YAML string
Parses a sequence to a YAML string .