Skip to content

Commit ed93804

Browse files
minor #42119 [Yaml] Remove compat code for MB function overloading (derrabus)
This PR was merged into the 6.0 branch. Discussion ---------- [Yaml] Remove compat code for MB function overloading | Q | A | ------------- | --- | Branch? | 6.0 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | N/A | License | MIT | Doc PR | N/A MB string function overloading has been removed with PHP 8.0. I'd like to remove some code that was meant to handle active function overloading. Commits ------- 6028694781 [Yaml] Remove compat code for MB function overloading
2 parents 726e80e + 44d76be commit ed93804

File tree

2 files changed

+21
-42
lines changed

2 files changed

+21
-42
lines changed

Inline.php

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -66,42 +66,31 @@ public static function parse(string $value = null, int $flags = 0, array &$refer
6666
return '';
6767
}
6868

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);
7282
}
7383

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+
}
9888

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);
10491
}
92+
93+
return $result;
10594
}
10695

10796
/**

Parser.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,9 @@ public function parse(string $value, int $flags = 0): mixed
8282

8383
$this->refs = [];
8484

85-
$mbEncoding = null;
86-
87-
if (2 /* MB_OVERLOAD_STRING */ & (int) ini_get('mbstring.func_overload')) {
88-
$mbEncoding = mb_internal_encoding();
89-
mb_internal_encoding('UTF-8');
90-
}
91-
9285
try {
9386
$data = $this->doParse($value, $flags);
9487
} finally {
95-
if (null !== $mbEncoding) {
96-
mb_internal_encoding($mbEncoding);
97-
}
9888
$this->lines = [];
9989
$this->currentLine = '';
10090
$this->numberOfParsedLines = 0;

0 commit comments

Comments
 (0)