@@ -66,42 +66,31 @@ public static function parse(string $value = null, int $flags = 0, array &$refer
66
66
return '' ;
67
67
}
68
68
69
- if (2 /* MB_OVERLOAD_STRING */ & (int ) ini_get ('mbstring.func_overload ' )) {
70
- $ mbEncoding = mb_internal_encoding ();
71
- mb_internal_encoding ('ASCII ' );
69
+ $ i = 0 ;
70
+ $ tag = self ::parseTag ($ value , $ i , $ flags );
71
+ switch ($ value [$ i ]) {
72
+ case '[ ' :
73
+ $ result = self ::parseSequence ($ value , $ flags , $ i , $ references );
74
+ ++$ i ;
75
+ break ;
76
+ case '{ ' :
77
+ $ result = self ::parseMapping ($ value , $ flags , $ i , $ references );
78
+ ++$ i ;
79
+ break ;
80
+ default :
81
+ $ result = self ::parseScalar ($ value , $ flags , null , $ i , null === $ tag , $ references );
72
82
}
73
83
74
- try {
75
- $ i = 0 ;
76
- $ tag = self ::parseTag ($ value , $ i , $ flags );
77
- switch ($ value [$ i ]) {
78
- case '[ ' :
79
- $ result = self ::parseSequence ($ value , $ flags , $ i , $ references );
80
- ++$ i ;
81
- break ;
82
- case '{ ' :
83
- $ result = self ::parseMapping ($ value , $ flags , $ i , $ references );
84
- ++$ i ;
85
- break ;
86
- default :
87
- $ result = self ::parseScalar ($ value , $ flags , null , $ i , null === $ tag , $ references );
88
- }
89
-
90
- // some comments are allowed at the end
91
- if (preg_replace ('/\s*#.*$/A ' , '' , substr ($ value , $ i ))) {
92
- throw new ParseException (sprintf ('Unexpected characters near "%s". ' , substr ($ value , $ i )), self ::$ parsedLineNumber + 1 , $ value , self ::$ parsedFilename );
93
- }
94
-
95
- if (null !== $ tag && '' !== $ tag ) {
96
- return new TaggedValue ($ tag , $ result );
97
- }
84
+ // some comments are allowed at the end
85
+ if (preg_replace ('/\s*#.*$/A ' , '' , substr ($ value , $ i ))) {
86
+ throw new ParseException (sprintf ('Unexpected characters near "%s". ' , substr ($ value , $ i )), self ::$ parsedLineNumber + 1 , $ value , self ::$ parsedFilename );
87
+ }
98
88
99
- return $ result ;
100
- } finally {
101
- if (isset ($ mbEncoding )) {
102
- mb_internal_encoding ($ mbEncoding );
103
- }
89
+ if (null !== $ tag && '' !== $ tag ) {
90
+ return new TaggedValue ($ tag , $ result );
104
91
}
92
+
93
+ return $ result ;
105
94
}
106
95
107
96
/**
0 commit comments