Skip to content

Commit a7d20bf

Browse files
Merge branch '4.4'
* 4.4: fix merge
1 parent 222cd1a commit a7d20bf

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

AbstractUnicodeString.php

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,34 +81,29 @@ public function ascii(array $rules = []): self
8181
$s = $str->string;
8282
$str->string = '';
8383

84-
if (!$rules) {
85-
$rules[] = '[:nonspacing mark:] remove';
86-
}
87-
88-
array_unshift($rules, 'nfd');
89-
9084
if (\function_exists('transliterator_transliterate')) {
85+
array_unshift($rules, 'nfd');
9186
$rules[] = 'any-latin/bgn';
9287
$rules[] = 'nfkd';
93-
$rules[] = '[:nonspacing mark:] remove';
88+
} else {
89+
array_unshift($rules, 'nfkd');
9490
}
9591

92+
$rules[] = '[:nonspacing mark:] remove';
93+
9694
while (\strlen($s) - 1 > $i = strspn($s, self::ASCII)) {
9795
if (0 < --$i) {
9896
$str->string .= substr($s, 0, $i);
9997
$s = substr($s, $i);
10098
}
10199

102-
if ($rules && !$rule = array_shift($rules)) {
100+
if (!$rule = array_shift($rules)) {
103101
$rules = []; // An empty rule interrupts the next ones
104102
}
105103

106-
if ($rules && $rule) {
107-
if ($rule instanceof \Transliterator) {
108-
$s = $rule->transliterate($s);
109-
continue;
110-
}
111-
104+
if ($rule instanceof \Transliterator) {
105+
$s = $rule->transliterate($s);
106+
} elseif ($rule) {
112107
if ('nfd' === $rule = strtolower($rule)) {
113108
normalizer_is_normalized($s, self::NFD) ?: $s = normalizer_normalize($s, self::NFD);
114109
} elseif ('nfkd' === $rule) {

0 commit comments

Comments
 (0)