@@ -81,7 +81,7 @@ public static function canonicalize(string $path): string
81
81
82
82
// Replace "~" with user's home directory.
83
83
if ('~ ' === $ path [0 ]) {
84
- $ path = self ::getHomeDirectory ().mb_substr ($ path , 1 );
84
+ $ path = self ::getHomeDirectory ().substr ($ path , 1 );
85
85
}
86
86
87
87
$ path = self ::normalize ($ path );
@@ -151,14 +151,14 @@ public static function getDirectory(string $path): string
151
151
$ path = self ::canonicalize ($ path );
152
152
153
153
// 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 );
157
157
} else {
158
158
$ scheme = '' ;
159
159
}
160
160
161
- if (false === ( $ dirSeparatorPosition = strrpos ($ path , '/ ' ) )) {
161
+ if (false === $ dirSeparatorPosition = strrpos ($ path , '/ ' )) {
162
162
return '' ;
163
163
}
164
164
@@ -169,10 +169,10 @@ public static function getDirectory(string $path): string
169
169
170
170
// Directory equals Windows root "C:/"
171
171
if (2 === $ dirSeparatorPosition && ctype_alpha ($ path [0 ]) && ': ' === $ path [1 ]) {
172
- return $ scheme .mb_substr ($ path , 0 , 3 );
172
+ return $ scheme .substr ($ path , 0 , 3 );
173
173
}
174
174
175
- return $ scheme .mb_substr ($ path , 0 , $ dirSeparatorPosition );
175
+ return $ scheme .substr ($ path , 0 , $ dirSeparatorPosition );
176
176
}
177
177
178
178
/**
@@ -219,7 +219,7 @@ public static function getRoot(string $path): string
219
219
}
220
220
221
221
// Maintain scheme
222
- if (false !== ( $ schemeSeparatorPosition = strpos ($ path , ':// ' ) )) {
222
+ if (false !== $ schemeSeparatorPosition = strpos ($ path , ':// ' )) {
223
223
$ scheme = substr ($ path , 0 , $ schemeSeparatorPosition + 3 );
224
224
$ path = substr ($ path , $ schemeSeparatorPosition + 3 );
225
225
} else {
@@ -233,7 +233,7 @@ public static function getRoot(string $path): string
233
233
return $ scheme .'/ ' ;
234
234
}
235
235
236
- $ length = mb_strlen ($ path );
236
+ $ length = \strlen ($ path );
237
237
238
238
// Windows root
239
239
if ($ length > 1 && ': ' === $ path [1 ] && ctype_alpha ($ firstCharacter )) {
@@ -349,16 +349,16 @@ public static function changeExtension(string $path, string $extension): string
349
349
$ extension = ltrim ($ extension , '. ' );
350
350
351
351
// No extension for paths
352
- if ('/ ' === mb_substr ($ path , -1 )) {
352
+ if ('/ ' === substr ($ path , -1 )) {
353
353
return $ path ;
354
354
}
355
355
356
356
// No actual extension in path
357
357
if (empty ($ actualExtension )) {
358
- return $ path .('. ' === mb_substr ($ path , -1 ) ? '' : '. ' ).$ extension ;
358
+ return $ path .('. ' === substr ($ path , -1 ) ? '' : '. ' ).$ extension ;
359
359
}
360
360
361
- return mb_substr ($ path , 0 , -mb_strlen ($ actualExtension )).$ extension ;
361
+ return substr ($ path , 0 , -\strlen ($ actualExtension )).$ extension ;
362
362
}
363
363
364
364
public static function isAbsolute (string $ path ): bool
@@ -368,8 +368,8 @@ public static function isAbsolute(string $path): bool
368
368
}
369
369
370
370
// 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 );
373
373
}
374
374
375
375
$ firstCharacter = $ path [0 ];
@@ -380,9 +380,9 @@ public static function isAbsolute(string $path): bool
380
380
}
381
381
382
382
// Windows root
383
- if (mb_strlen ($ path ) > 1 && ctype_alpha ($ firstCharacter ) && ': ' === $ path [1 ]) {
383
+ if (\strlen ($ path ) > 1 && ctype_alpha ($ firstCharacter ) && ': ' === $ path [1 ]) {
384
384
// Special case: "C:"
385
- if (2 === mb_strlen ($ path )) {
385
+ if (2 === \strlen ($ path )) {
386
386
return true ;
387
387
}
388
388
@@ -451,9 +451,9 @@ public static function makeAbsolute(string $path, string $basePath): string
451
451
return self ::canonicalize ($ path );
452
452
}
453
453
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 );
457
457
} else {
458
458
$ scheme = '' ;
459
459
}
@@ -574,7 +574,7 @@ public static function makeRelative(string $path, string $basePath): string
574
574
*/
575
575
public static function isLocal (string $ path ): bool
576
576
{
577
- return '' !== $ path && false === mb_strpos ($ path , ':// ' );
577
+ return '' !== $ path && false === strpos ($ path , ':// ' );
578
578
}
579
579
580
580
/**
@@ -638,7 +638,7 @@ public static function getLongestCommonBasePath(string ...$paths): ?string
638
638
639
639
// Prevent false positives for common prefixes
640
640
// see isBasePath()
641
- if (0 === mb_strpos ($ path .'/ ' , $ basePath .'/ ' )) {
641
+ if (0 === strpos ($ path .'/ ' , $ basePath .'/ ' )) {
642
642
// next path
643
643
continue 2 ;
644
644
}
@@ -666,12 +666,12 @@ public static function join(string ...$paths): string
666
666
if (null === $ finalPath ) {
667
667
// For first part we keep slashes, like '/top', 'C:\' or 'phar://'
668
668
$ finalPath = $ path ;
669
- $ wasScheme = (false !== mb_strpos ($ path , ':// ' ));
669
+ $ wasScheme = (false !== strpos ($ path , ':// ' ));
670
670
continue ;
671
671
}
672
672
673
673
// 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 ), ['/ ' , '\\' ])) {
675
675
$ finalPath .= '/ ' ;
676
676
}
677
677
@@ -717,7 +717,7 @@ public static function isBasePath(string $basePath, string $ofPath): bool
717
717
// Don't append a slash for the root "/", because then that root
718
718
// won't be discovered as common prefix ("//" is not a prefix of
719
719
// "/foobar/").
720
- return 0 === mb_strpos ($ ofPath .'/ ' , rtrim ($ basePath , '/ ' ).'/ ' );
720
+ return 0 === strpos ($ ofPath .'/ ' , rtrim ($ basePath , '/ ' ).'/ ' );
721
721
}
722
722
723
723
/**
@@ -776,28 +776,28 @@ private static function split(string $path): array
776
776
}
777
777
778
778
// 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 );
782
782
} else {
783
783
$ root = '' ;
784
784
}
785
785
786
- $ length = mb_strlen ($ path );
786
+ $ length = \strlen ($ path );
787
787
788
788
// Remove and remember root directory
789
- if (0 === mb_strpos ($ path , '/ ' )) {
789
+ if (0 === strpos ($ path , '/ ' )) {
790
790
$ root .= '/ ' ;
791
- $ path = $ length > 1 ? mb_substr ($ path , 1 ) : '' ;
791
+ $ path = $ length > 1 ? substr ($ path , 1 ) : '' ;
792
792
} elseif ($ length > 1 && ctype_alpha ($ path [0 ]) && ': ' === $ path [1 ]) {
793
793
if (2 === $ length ) {
794
794
// Windows special case: "C:"
795
795
$ root .= $ path .'/ ' ;
796
796
$ path = '' ;
797
797
} elseif ('/ ' === $ path [2 ]) {
798
798
// 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 ) : '' ;
801
801
}
802
802
}
803
803
@@ -806,11 +806,11 @@ private static function split(string $path): array
806
806
807
807
private static function toLower (string $ string ): string
808
808
{
809
- if (false !== $ encoding = mb_detect_encoding ($ string )) {
809
+ if (false !== $ encoding = mb_detect_encoding ($ string, null , true )) {
810
810
return mb_strtolower ($ string , $ encoding );
811
811
}
812
812
813
- return strtolower ($ string, $ encoding );
813
+ return strtolower ($ string );
814
814
}
815
815
816
816
private function __construct ()
0 commit comments