@@ -71,7 +71,8 @@ testStrimwidth($utf16le, -3, 5, 'UTF-16LE');
71
71
// We'll count back 4 characters, then allow a width of ((4 * 2) - 2) = 6
72
72
// Since the output will not reach the END of the string, the trim marker
73
73
// will have to be added, and will consume a width of 3
74
- testStrimwidth ($ utf16le , -4 , -2 , 'UTF-16LE ' );
74
+ // We also suppress the deprecation for negative width as of PHP 8.3
75
+ @testStrimwidth ($ utf16le , -4 , -2 , 'UTF-16LE ' );
75
76
76
77
echo "\n== EUC-JP == \n" ;
77
78
@@ -103,22 +104,26 @@ testStrimwidth($euc_jp, 9, 5, 'EUC-JP');
103
104
104
105
// Skip 15 characters, which leaves a total width of 42. Then trim string down
105
106
// to 5 less than that, which is a width of 37.
106
- testStrimwidth ($ euc_jp , 15 , -5 , 'EUC-JP ' );
107
+ // We also suppress the deprecation for negative width as of PHP 8.3
108
+ @testStrimwidth ($ euc_jp , 15 , -5 , 'EUC-JP ' );
107
109
108
110
// Take the last 30 characters, which have a width of 54. Trim string down to
109
111
// 25 less than that, which is 29.
110
- testStrimwidth ($ euc_jp , -30 , -25 , 'EUC-JP ' );
112
+ // We also suppress the deprecation for negative width as of PHP 8.3
113
+ @testStrimwidth ($ euc_jp , -30 , -25 , 'EUC-JP ' );
111
114
112
115
// Skip over 39 characters... but since string is only 39 characters long,
113
116
// it takes us to the end of the string, and output is empty
114
117
testStrimwidth ($ euc_jp , 39 , 10 , 'EUC-JP ' );
115
118
116
119
// Take the last 10 characters, which have a width of 20. Trim string down to
117
120
// 12 less than that, which is a width of 8.
118
- testStrimwidth ($ euc_jp , -10 , -12 , 'EUC-JP ' );
121
+ // We also suppress the deprecation for negative width as of PHP 8.3
122
+ @testStrimwidth ($ euc_jp , -10 , -12 , 'EUC-JP ' );
119
123
120
124
try {
121
- var_dump (mb_strimwidth ($ euc_jp , 0 , -100 ,'... ' ,'EUC-JP ' ));
125
+ // We also suppress the deprecation for negative width as of PHP 8.3
126
+ var_dump (@mb_strimwidth ($ euc_jp , 0 , -100 ,'... ' ,'EUC-JP ' ));
122
127
} catch (\ValueError $ e ) {
123
128
echo $ e ->getMessage () . \PHP_EOL ;
124
129
}
@@ -133,7 +138,8 @@ try {
133
138
echo $ e ->getMessage () . \PHP_EOL ;
134
139
}
135
140
try {
136
- var_dump (mb_strimwidth ($ euc_jp , -10 , -21 ,'... ' ,'EUC-JP ' ));
141
+ // We also suppress the deprecation for negative width as of PHP 8.3
142
+ var_dump (@mb_strimwidth ($ euc_jp , -10 , -21 ,'... ' ,'EUC-JP ' ));
137
143
} catch (\ValueError $ e ) {
138
144
echo $ e ->getMessage () . \PHP_EOL ;
139
145
}
@@ -147,7 +153,8 @@ for ($from = -5; $from <= 5; $from++) {
147
153
// This case is illegal and will throw an exception
148
154
$ pass = false ;
149
155
try {
150
- mb_strimwidth ($ str , $ from , $ width , '... ' , 'ASCII ' );
156
+ /* Shut up deprecation notice for now */
157
+ @mb_strimwidth ($ str , $ from , $ width , '... ' , 'ASCII ' );
151
158
} catch (\ValueError $ e ) {
152
159
$ pass = true ;
153
160
}
@@ -156,7 +163,8 @@ for ($from = -5; $from <= 5; $from++) {
156
163
continue ;
157
164
}
158
165
159
- $ result = mb_strimwidth ($ str , $ from , $ width , '... ' , 'ASCII ' );
166
+ /* Shut up deprecation notice for now */
167
+ $ result = @mb_strimwidth ($ str , $ from , $ width , '... ' , 'ASCII ' );
160
168
161
169
if ($ from < 0 && $ width < 0 && ($ width - $ from ) <= 3 ) {
162
170
if ($ result !== '... ' )
@@ -211,7 +219,8 @@ testStrimwidth("日本語abc", -3, 10, 'UTF-8');
211
219
// Regression test; old implementation did not handle positive 'from' argument
212
220
// combined with negative 'width' argument correctly when portion being skipped
213
221
// over included fullwidth characters
214
- testStrimwidth ("日本語abcdef " , 3 , -1 , 'UTF-8 ' );
222
+ // We also suppress the deprecation for negative width as of PHP 8.3
223
+ @testStrimwidth ("日本語abcdef " , 3 , -1 , 'UTF-8 ' );
215
224
216
225
?>
217
226
--EXPECT--
0 commit comments