@@ -78,17 +78,17 @@ public function setAt(int $idx, string $char): self
7878 {
7979 $ char = $ this ->inputConv ($ char );
8080 if (\strlen ($ char ) > 4 ) {
81- $ char = \ substr ($ char , 0 , 4 );
81+ $ char = substr ($ char , 0 , 4 );
8282 }
8383
8484 $ spacesPrepend = $ idx - $ this ->strlen ();
8585 // set index (out of bound)
8686 if ($ spacesPrepend > 0 ) {
87- $ this ->str .= $ this ->inputConv (\ str_repeat (' ' , $ spacesPrepend )) . $ char ;
87+ $ this ->str .= $ this ->inputConv (str_repeat (' ' , $ spacesPrepend )) . $ char ;
8888 }
8989 // set index (in bound)
9090 else {
91- $ this ->str = \ substr_replace ($ this ->str , $ char , $ idx << 2 , 4 );
91+ $ this ->str = substr_replace ($ this ->str , $ char , $ idx << 2 , 4 );
9292 }
9393
9494 return $ this ;
@@ -114,12 +114,12 @@ public function getRaw(): string
114114
115115 public function getAt (int $ idx ): string
116116 {
117- return $ this ->outputConv (\ substr ($ this ->str , $ idx << 2 , 4 ));
117+ return $ this ->outputConv (substr ($ this ->str , $ idx << 2 , 4 ));
118118 }
119119
120120 public function getAtRaw (int $ idx ): string
121121 {
122- return \ substr ($ this ->str , $ idx << 2 , 4 );
122+ return substr ($ this ->str , $ idx << 2 , 4 );
123123 }
124124
125125 public function toArray (): array
@@ -133,7 +133,7 @@ public function toArraySplit(string $regex, int $limit = -1, $flags = 0): array
133133 return [];
134134 }
135135
136- return \ preg_split ($ regex , $ this ->get (), $ limit , $ flags );
136+ return preg_split ($ regex , $ this ->get (), $ limit , $ flags );
137137 }
138138
139139 public function toArrayRaw (): array
@@ -142,22 +142,22 @@ public function toArrayRaw(): array
142142 return [];
143143 }
144144
145- return \ str_split ($ this ->str , 4 );
145+ return str_split ($ this ->str , 4 );
146146 }
147147
148148 public static function strToChars (string $ str ): array
149149 {
150- return \ preg_split ('//uS ' , $ str , -1 , \PREG_SPLIT_NO_EMPTY ) ?: [];
150+ return preg_split ('//uS ' , $ str , -1 , \PREG_SPLIT_NO_EMPTY ) ?: [];
151151 }
152152
153- ///////////////////////////////////
153+ // /////////////////////////////////
154154 // string manipulation functions //
155- ///////////////////////////////////
155+ // /////////////////////////////////
156156
157157 public function stripos (string $ needle , int $ offset = 0 )
158158 {
159159 $ needle = $ this ->inputConv ($ needle );
160- $ pos = \ stripos ($ this ->str , $ needle , $ offset << 2 );
160+ $ pos = stripos ($ this ->str , $ needle , $ offset << 2 );
161161
162162 return \is_bool ($ pos ) ? $ pos : $ pos >> 2 ;
163163 }
@@ -170,7 +170,7 @@ public function strlen(): int
170170 public function strpos (string $ needle , int $ offset = 0 )
171171 {
172172 $ needle = $ this ->inputConv ($ needle );
173- $ pos = \ strpos ($ this ->str , $ needle , $ offset << 2 );
173+ $ pos = strpos ($ this ->str , $ needle , $ offset << 2 );
174174
175175 return \is_bool ($ pos ) ? $ pos : $ pos >> 2 ;
176176 }
@@ -179,8 +179,8 @@ public function substr(int $start = 0, ?int $length = null): string
179179 {
180180 return $ this ->outputConv (
181181 isset ($ length )
182- ? \ substr ($ this ->str , $ start << 2 , $ length << 2 )
183- : \ substr ($ this ->str , $ start << 2 )
182+ ? substr ($ this ->str , $ start << 2 , $ length << 2 )
183+ : substr ($ this ->str , $ start << 2 ),
184184 );
185185 }
186186
@@ -190,55 +190,55 @@ public function substr_replace(string $replacement, int $start = 0, ?int $length
190190
191191 return $ this ->outputConv (
192192 isset ($ length )
193- ? \ substr_replace ($ this ->str , $ replacement , $ start << 2 , $ length << 2 )
194- : \ substr_replace ($ this ->str , $ replacement , $ start << 2 )
193+ ? substr_replace ($ this ->str , $ replacement , $ start << 2 , $ length << 2 )
194+ : substr_replace ($ this ->str , $ replacement , $ start << 2 ),
195195 );
196196 }
197197
198198 public function strtolower (): string
199199 {
200- return \ strtolower ($ this ->get ());
200+ return strtolower ($ this ->get ());
201201 }
202202
203203 public function strtoupper (): string
204204 {
205- return \ strtoupper ($ this ->get ());
205+ return strtoupper ($ this ->get ());
206206 }
207207
208- ////////////////////////////////
208+ // //////////////////////////////
209209 // non-manipulative functions //
210- ////////////////////////////////
210+ // //////////////////////////////
211211
212212 public function has (string $ needle ): bool
213213 {
214214 $ needle = $ this ->inputConv ($ needle );
215215
216- return \strpos ($ this ->str , $ needle ) !== false ;
216+ return str_contains ($ this ->str , $ needle );
217217 }
218218
219219 public function startsWith (string $ needle ): bool
220220 {
221221 $ needle = $ this ->inputConv ($ needle );
222222
223- return $ needle === \ substr ($ this ->str , 0 , \strlen ($ needle ));
223+ return $ needle === substr ($ this ->str , 0 , \strlen ($ needle ));
224224 }
225225
226226 public function endsWith (string $ needle ): bool
227227 {
228228 $ needle = $ this ->inputConv ($ needle );
229229 $ length = \strlen ($ needle );
230230
231- return $ length === 0 ? true : $ needle === \ substr ($ this ->str , -$ length );
231+ return $ length === 0 ? true : $ needle === substr ($ this ->str , -$ length );
232232 }
233233
234- /////////////////////////////////////////////
234+ // ///////////////////////////////////////////
235235 // those functions will not return a value //
236- /////////////////////////////////////////////
236+ // ///////////////////////////////////////////
237237
238238 public function str_insert_i (string $ insert , int $ position ): self
239239 {
240240 $ insert = $ this ->inputConv ($ insert );
241- $ this ->str = \ substr_replace ($ this ->str , $ insert , $ position << 2 , 0 );
241+ $ this ->str = substr_replace ($ this ->str , $ insert , $ position << 2 , 0 );
242242
243243 return $ this ;
244244 }
@@ -252,15 +252,15 @@ public function str_enclose_i(array $closures, int $start = 0, ?int $length = nu
252252 unset($ closure );
253253
254254 if (\count ($ closures ) < 2 ) {
255- $ closures [0 ] = $ closures [1 ] = \ reset ($ closures );
255+ $ closures [0 ] = $ closures [1 ] = reset ($ closures );
256256 }
257257
258258 if (isset ($ length )) {
259- $ replacement = $ closures [0 ] . \ substr ($ this ->str , $ start << 2 , $ length << 2 ) . $ closures [1 ];
260- $ this ->str = \ substr_replace ($ this ->str , $ replacement , $ start << 2 , $ length << 2 );
259+ $ replacement = $ closures [0 ] . substr ($ this ->str , $ start << 2 , $ length << 2 ) . $ closures [1 ];
260+ $ this ->str = substr_replace ($ this ->str , $ replacement , $ start << 2 , $ length << 2 );
261261 } else {
262- $ replacement = $ closures [0 ] . \ substr ($ this ->str , $ start << 2 ) . $ closures [1 ];
263- $ this ->str = \ substr_replace ($ this ->str , $ replacement , $ start << 2 );
262+ $ replacement = $ closures [0 ] . substr ($ this ->str , $ start << 2 ) . $ closures [1 ];
263+ $ this ->str = substr_replace ($ this ->str , $ replacement , $ start << 2 );
264264 }
265265
266266 return $ this ;
@@ -270,7 +270,7 @@ public function str_replace_i(string $search, string $replace): self
270270 {
271271 $ search = $ this ->inputConv ($ search );
272272 $ replace = $ this ->inputConv ($ replace );
273- $ this ->str = \ str_replace ($ search , $ replace , $ this ->str );
273+ $ this ->str = str_replace ($ search , $ replace , $ this ->str );
274274
275275 return $ this ;
276276 }
@@ -280,16 +280,16 @@ public function substr_replace_i(string $replacement, int $start = 0, ?int $leng
280280 $ replacement = $ this ->inputConv ($ replacement );
281281 $ this ->str = (
282282 isset ($ length )
283- ? \ substr_replace ($ this ->str , $ replacement , $ start << 2 , $ length << 2 )
284- : \ substr_replace ($ this ->str , $ replacement , $ start << 2 )
283+ ? substr_replace ($ this ->str , $ replacement , $ start << 2 , $ length << 2 )
284+ : substr_replace ($ this ->str , $ replacement , $ start << 2 )
285285 );
286286
287287 return $ this ;
288288 }
289289
290- /////////////////
290+ // ///////////////
291291 // ArrayObject //
292- /////////////////
292+ // ///////////////
293293
294294 public function offsetSet (mixed $ idx , mixed $ char ): void
295295 {
@@ -316,9 +316,9 @@ public function count(): int
316316 return $ this ->strlen ();
317317 }
318318
319- ////////////////////
319+ // //////////////////
320320 // misc functions //
321- ////////////////////
321+ // //////////////////
322322
323323 /**
324324 * Gets the utf 32 header.
@@ -328,9 +328,9 @@ public function count(): int
328328 protected static function getUtf32Header (): string
329329 {
330330 // just use any string to get the endian header, here we use "A"
331- $ tmp = \ iconv ('UTF-8 ' , 'UTF-32 ' , 'A ' );
331+ $ tmp = iconv ('UTF-8 ' , 'UTF-32 ' , 'A ' );
332332 // some distributions like "php alpine" docker image won't generate the header
333- return $ tmp && \strlen ($ tmp ) > 4 ? \ substr ($ tmp , 0 , 4 ) : '' ;
333+ return $ tmp && \strlen ($ tmp ) > 4 ? substr ($ tmp , 0 , 4 ) : '' ;
334334 }
335335
336336 /**
@@ -344,7 +344,7 @@ protected function outputConv(string $str): string
344344 return '' ;
345345 }
346346
347- return \ iconv ('UTF-32 ' , $ this ->encoding , static ::$ utf32Header . $ str );
347+ return iconv ('UTF-32 ' , $ this ->encoding , static ::$ utf32Header . $ str );
348348 }
349349
350350 /**
@@ -358,6 +358,6 @@ protected function inputConv(string $str): string
358358 return '' ;
359359 }
360360
361- return \ substr (\ iconv ($ this ->encoding , 'UTF-32 ' , $ str ), \strlen (static ::$ utf32Header ));
361+ return substr (iconv ($ this ->encoding , 'UTF-32 ' , $ str ), \strlen (static ::$ utf32Header ));
362362 }
363363}
0 commit comments