@@ -81,7 +81,7 @@ public static function canonicalize(string $path): string
8181
8282 // Replace "~" with user's home directory.
8383 if ('~ ' === $ path [0 ]) {
84- $ path = self ::getHomeDirectory ().mb_substr ($ path , 1 );
84+ $ path = self ::getHomeDirectory ().substr ($ path , 1 );
8585 }
8686
8787 $ path = self ::normalize ($ path );
@@ -151,14 +151,14 @@ public static function getDirectory(string $path): string
151151 $ path = self ::canonicalize ($ path );
152152
153153 // Maintain scheme
154- if (false !== ( $ schemeSeparatorPosition = mb_strpos ($ path , ':// ' ) )) {
155- $ scheme = mb_substr ($ path , 0 , $ schemeSeparatorPosition + 3 );
156- $ path = mb_substr ($ path , $ schemeSeparatorPosition + 3 );
154+ if (false !== $ schemeSeparatorPosition = strpos ($ path , ':// ' )) {
155+ $ scheme = substr ($ path , 0 , $ schemeSeparatorPosition + 3 );
156+ $ path = substr ($ path , $ schemeSeparatorPosition + 3 );
157157 } else {
158158 $ scheme = '' ;
159159 }
160160
161- if (false === ( $ dirSeparatorPosition = strrpos ($ path , '/ ' ) )) {
161+ if (false === $ dirSeparatorPosition = strrpos ($ path , '/ ' )) {
162162 return '' ;
163163 }
164164
@@ -169,10 +169,10 @@ public static function getDirectory(string $path): string
169169
170170 // Directory equals Windows root "C:/"
171171 if (2 === $ dirSeparatorPosition && ctype_alpha ($ path [0 ]) && ': ' === $ path [1 ]) {
172- return $ scheme .mb_substr ($ path , 0 , 3 );
172+ return $ scheme .substr ($ path , 0 , 3 );
173173 }
174174
175- return $ scheme .mb_substr ($ path , 0 , $ dirSeparatorPosition );
175+ return $ scheme .substr ($ path , 0 , $ dirSeparatorPosition );
176176 }
177177
178178 /**
@@ -219,7 +219,7 @@ public static function getRoot(string $path): string
219219 }
220220
221221 // Maintain scheme
222- if (false !== ( $ schemeSeparatorPosition = strpos ($ path , ':// ' ) )) {
222+ if (false !== $ schemeSeparatorPosition = strpos ($ path , ':// ' )) {
223223 $ scheme = substr ($ path , 0 , $ schemeSeparatorPosition + 3 );
224224 $ path = substr ($ path , $ schemeSeparatorPosition + 3 );
225225 } else {
@@ -233,7 +233,7 @@ public static function getRoot(string $path): string
233233 return $ scheme .'/ ' ;
234234 }
235235
236- $ length = mb_strlen ($ path );
236+ $ length = \strlen ($ path );
237237
238238 // Windows root
239239 if ($ length > 1 && ': ' === $ path [1 ] && ctype_alpha ($ firstCharacter )) {
@@ -349,16 +349,16 @@ public static function changeExtension(string $path, string $extension): string
349349 $ extension = ltrim ($ extension , '. ' );
350350
351351 // No extension for paths
352- if ('/ ' === mb_substr ($ path , -1 )) {
352+ if ('/ ' === substr ($ path , -1 )) {
353353 return $ path ;
354354 }
355355
356356 // No actual extension in path
357357 if (empty ($ actualExtension )) {
358- return $ path .('. ' === mb_substr ($ path , -1 ) ? '' : '. ' ).$ extension ;
358+ return $ path .('. ' === substr ($ path , -1 ) ? '' : '. ' ).$ extension ;
359359 }
360360
361- return mb_substr ($ path , 0 , -mb_strlen ($ actualExtension )).$ extension ;
361+ return substr ($ path , 0 , -\strlen ($ actualExtension )).$ extension ;
362362 }
363363
364364 public static function isAbsolute (string $ path ): bool
@@ -368,8 +368,8 @@ public static function isAbsolute(string $path): bool
368368 }
369369
370370 // Strip scheme
371- if (false !== ( $ schemeSeparatorPosition = mb_strpos ($ path , ':// ' ) )) {
372- $ path = mb_substr ($ path , $ schemeSeparatorPosition + 3 );
371+ if (false !== $ schemeSeparatorPosition = strpos ($ path , ':// ' )) {
372+ $ path = substr ($ path , $ schemeSeparatorPosition + 3 );
373373 }
374374
375375 $ firstCharacter = $ path [0 ];
@@ -380,9 +380,9 @@ public static function isAbsolute(string $path): bool
380380 }
381381
382382 // Windows root
383- if (mb_strlen ($ path ) > 1 && ctype_alpha ($ firstCharacter ) && ': ' === $ path [1 ]) {
383+ if (\strlen ($ path ) > 1 && ctype_alpha ($ firstCharacter ) && ': ' === $ path [1 ]) {
384384 // Special case: "C:"
385- if (2 === mb_strlen ($ path )) {
385+ if (2 === \strlen ($ path )) {
386386 return true ;
387387 }
388388
@@ -451,9 +451,9 @@ public static function makeAbsolute(string $path, string $basePath): string
451451 return self ::canonicalize ($ path );
452452 }
453453
454- if (false !== ( $ schemeSeparatorPosition = mb_strpos ($ basePath , ':// ' ) )) {
455- $ scheme = mb_substr ($ basePath , 0 , $ schemeSeparatorPosition + 3 );
456- $ basePath = mb_substr ($ basePath , $ schemeSeparatorPosition + 3 );
454+ if (false !== $ schemeSeparatorPosition = strpos ($ basePath , ':// ' )) {
455+ $ scheme = substr ($ basePath , 0 , $ schemeSeparatorPosition + 3 );
456+ $ basePath = substr ($ basePath , $ schemeSeparatorPosition + 3 );
457457 } else {
458458 $ scheme = '' ;
459459 }
@@ -671,7 +671,7 @@ public static function join(string ...$paths): string
671671 }
672672
673673 // Only add slash if previous part didn't end with '/' or '\'
674- if (!\in_array (mb_substr ($ finalPath , -1 ), ['/ ' , '\\' ])) {
674+ if (!\in_array (substr ($ finalPath , -1 ), ['/ ' , '\\' ])) {
675675 $ finalPath .= '/ ' ;
676676 }
677677
@@ -776,28 +776,28 @@ private static function split(string $path): array
776776 }
777777
778778 // Remember scheme as part of the root, if any
779- if (false !== ( $ schemeSeparatorPosition = mb_strpos ($ path , ':// ' ) )) {
780- $ root = mb_substr ($ path , 0 , $ schemeSeparatorPosition + 3 );
781- $ path = mb_substr ($ path , $ schemeSeparatorPosition + 3 );
779+ if (false !== $ schemeSeparatorPosition = strpos ($ path , ':// ' )) {
780+ $ root = substr ($ path , 0 , $ schemeSeparatorPosition + 3 );
781+ $ path = substr ($ path , $ schemeSeparatorPosition + 3 );
782782 } else {
783783 $ root = '' ;
784784 }
785785
786- $ length = mb_strlen ($ path );
786+ $ length = \strlen ($ path );
787787
788788 // Remove and remember root directory
789789 if (str_starts_with ($ path , '/ ' )) {
790790 $ root .= '/ ' ;
791- $ path = $ length > 1 ? mb_substr ($ path , 1 ) : '' ;
791+ $ path = $ length > 1 ? substr ($ path , 1 ) : '' ;
792792 } elseif ($ length > 1 && ctype_alpha ($ path [0 ]) && ': ' === $ path [1 ]) {
793793 if (2 === $ length ) {
794794 // Windows special case: "C:"
795795 $ root .= $ path .'/ ' ;
796796 $ path = '' ;
797797 } elseif ('/ ' === $ path [2 ]) {
798798 // Windows normal case: "C:/"..
799- $ root .= mb_substr ($ path , 0 , 3 );
800- $ path = $ length > 3 ? mb_substr ($ path , 3 ) : '' ;
799+ $ root .= substr ($ path , 0 , 3 );
800+ $ path = $ length > 3 ? substr ($ path , 3 ) : '' ;
801801 }
802802 }
803803
@@ -806,11 +806,11 @@ private static function split(string $path): array
806806
807807 private static function toLower (string $ string ): string
808808 {
809- if (false !== $ encoding = mb_detect_encoding ($ string )) {
809+ if (false !== $ encoding = mb_detect_encoding ($ string, null , true )) {
810810 return mb_strtolower ($ string , $ encoding );
811811 }
812812
813- return strtolower ($ string, $ encoding );
813+ return strtolower ($ string );
814814 }
815815
816816 private function __construct ()
0 commit comments