@@ -71,7 +71,8 @@ testStrimwidth($utf16le, -3, 5, 'UTF-16LE');
7171// We'll count back 4 characters, then allow a width of ((4 * 2) - 2) = 6
7272// Since the output will not reach the END of the string, the trim marker
7373// 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 ' );
7576
7677echo "\n== EUC-JP == \n" ;
7778
@@ -103,22 +104,26 @@ testStrimwidth($euc_jp, 9, 5, 'EUC-JP');
103104
104105// Skip 15 characters, which leaves a total width of 42. Then trim string down
105106// 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 ' );
107109
108110// Take the last 30 characters, which have a width of 54. Trim string down to
109111// 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 ' );
111114
112115// Skip over 39 characters... but since string is only 39 characters long,
113116// it takes us to the end of the string, and output is empty
114117testStrimwidth ($ euc_jp , 39 , 10 , 'EUC-JP ' );
115118
116119// Take the last 10 characters, which have a width of 20. Trim string down to
117120// 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 ' );
119123
120124try {
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 ' ));
122127} catch (\ValueError $ e ) {
123128 echo $ e ->getMessage () . \PHP_EOL ;
124129}
@@ -133,7 +138,8 @@ try {
133138 echo $ e ->getMessage () . \PHP_EOL ;
134139}
135140try {
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 ' ));
137143} catch (\ValueError $ e ) {
138144 echo $ e ->getMessage () . \PHP_EOL ;
139145}
@@ -147,7 +153,8 @@ for ($from = -5; $from <= 5; $from++) {
147153 // This case is illegal and will throw an exception
148154 $ pass = false ;
149155 try {
150- mb_strimwidth ($ str , $ from , $ width , '... ' , 'ASCII ' );
156+ /* Shut up deprecation notice for now */
157+ @mb_strimwidth ($ str , $ from , $ width , '... ' , 'ASCII ' );
151158 } catch (\ValueError $ e ) {
152159 $ pass = true ;
153160 }
@@ -156,7 +163,8 @@ for ($from = -5; $from <= 5; $from++) {
156163 continue ;
157164 }
158165
159- $ result = mb_strimwidth ($ str , $ from , $ width , '... ' , 'ASCII ' );
166+ /* Shut up deprecation notice for now */
167+ $ result = @mb_strimwidth ($ str , $ from , $ width , '... ' , 'ASCII ' );
160168
161169 if ($ from < 0 && $ width < 0 && ($ width - $ from ) <= 3 ) {
162170 if ($ result !== '... ' )
@@ -211,7 +219,8 @@ testStrimwidth("日本語abc", -3, 10, 'UTF-8');
211219// Regression test; old implementation did not handle positive 'from' argument
212220// combined with negative 'width' argument correctly when portion being skipped
213221// 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 ' );
215224
216225?>
217226--EXPECT--
0 commit comments