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;
    }
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;
    }
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 ; }
Converts a YAML string to a PHP array.

@param string  $value                  A YAML string
@param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise
@param Boolean $objectSupport          true if object support is enabled, false otherwise

@return array A PHP array representing the YAML string

@throws ParseException
Converts a YAML string to a PHP array .