Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 67755b1

Browse files
committed
Fix fabbot cs
1 parent 46d32d3 commit 67755b1

File tree

2 files changed

+88
-88
lines changed

2 files changed

+88
-88
lines changed

src/Symfony/Component/Filesystem/Path.php

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,17 @@ public static function canonicalize(string $path): string
8282

8383
// Replace "~" with user's home directory.
8484
if ('~' === $path[0]) {
85-
$path = self::getHomeDirectory().\mb_substr($path, 1);
85+
$path = self::getHomeDirectory().mb_substr($path, 1);
8686
}
8787

88-
$path = \str_replace('\\', '/', $path);
88+
$path = str_replace('\\', '/', $path);
8989

9090
[$root, $pathWithoutRoot] = self::split($path);
9191

9292
$canonicalParts = self::findCanonicalParts($root, $pathWithoutRoot);
9393

9494
// Add the root directory again
95-
self::$buffer[$path] = $canonicalPath = $root.\implode('/', $canonicalParts);
95+
self::$buffer[$path] = $canonicalPath = $root.implode('/', $canonicalParts);
9696
++self::$bufferSize;
9797

9898
// Clean up regularly to prevent memory leaks
@@ -152,9 +152,9 @@ public static function getDirectory(string $path): string
152152
$path = self::canonicalize($path);
153153

154154
// Maintain scheme
155-
if (false !== ($schemeSeparatorPosition = \mb_strpos($path, '://'))) {
156-
$scheme = \mb_substr($path, 0, $schemeSeparatorPosition + 3);
157-
$path = \mb_substr($path, $schemeSeparatorPosition + 3);
155+
if (false !== ($schemeSeparatorPosition = mb_strpos($path, '://'))) {
156+
$scheme = mb_substr($path, 0, $schemeSeparatorPosition + 3);
157+
$path = mb_substr($path, $schemeSeparatorPosition + 3);
158158
} else {
159159
$scheme = '';
160160
}
@@ -169,11 +169,11 @@ public static function getDirectory(string $path): string
169169
}
170170

171171
// Directory equals Windows root "C:/"
172-
if (2 === $dirSeparatorPosition && \ctype_alpha($path[0]) && ':' === $path[1]) {
173-
return $scheme.\mb_substr($path, 0, 3);
172+
if (2 === $dirSeparatorPosition && ctype_alpha($path[0]) && ':' === $path[1]) {
173+
return $scheme.mb_substr($path, 0, 3);
174174
}
175175

176-
return $scheme.\mb_substr($path, 0, $dirSeparatorPosition);
176+
return $scheme.mb_substr($path, 0, $dirSeparatorPosition);
177177
}
178178

179179
/**
@@ -193,16 +193,16 @@ public static function getDirectory(string $path): string
193193
public static function getHomeDirectory(): string
194194
{
195195
// For UNIX support
196-
if (\getenv('HOME')) {
197-
return self::canonicalize(\getenv('HOME'));
196+
if (getenv('HOME')) {
197+
return self::canonicalize(getenv('HOME'));
198198
}
199199

200200
// For >= Windows8 support
201-
if (\getenv('HOMEDRIVE') && \getenv('HOMEPATH')) {
202-
return self::canonicalize(\getenv('HOMEDRIVE').\getenv('HOMEPATH'));
201+
if (getenv('HOMEDRIVE') && getenv('HOMEPATH')) {
202+
return self::canonicalize(getenv('HOMEDRIVE').getenv('HOMEPATH'));
203203
}
204204

205-
throw new \RuntimeException("Cannot find the home directory path: Your environment or operation system isn't supported");
205+
throw new \RuntimeException("Cannot find the home directory path: Your environment or operation system isn't supported.");
206206
}
207207

208208
/**
@@ -234,7 +234,7 @@ public static function getRoot(string $path): string
234234
return $scheme.'/';
235235
}
236236

237-
$length = \mb_strlen($path);
237+
$length = mb_strlen($path);
238238

239239
// Windows root
240240
if ($length > 1 && ':' === $path[1] && ctype_alpha($firstCharacter)) {
@@ -258,18 +258,18 @@ public static function getRoot(string $path): string
258258
* @param string|null $extension if specified, only that extension is cut
259259
* off (may contain leading dot)
260260
*/
261-
public static function getFilenameWithoutExtension(string $path, ?string $extension = null)
261+
public static function getFilenameWithoutExtension(string $path, string $extension = null)
262262
{
263263
if ('' === $path) {
264264
return '';
265265
}
266266

267267
if (null !== $extension) {
268268
// remove extension and trailing dot
269-
return \rtrim(\basename($path, $extension), '.');
269+
return rtrim(basename($path, $extension), '.');
270270
}
271271

272-
return \pathinfo($path, PATHINFO_FILENAME);
272+
return pathinfo($path, \PATHINFO_FILENAME);
273273
}
274274

275275
/**
@@ -283,7 +283,7 @@ public static function getExtension(string $path, bool $forceLowerCase = false):
283283
return '';
284284
}
285285

286-
$extension = \pathinfo($path, PATHINFO_EXTENSION);
286+
$extension = pathinfo($path, \PATHINFO_EXTENSION);
287287

288288
if ($forceLowerCase) {
289289
$extension = self::toLower($extension);
@@ -326,7 +326,7 @@ public static function hasExtension(string $path, $extensions = null, bool $igno
326326
}
327327

328328
// remove leading '.' in extensions array
329-
$extensions[$key] = \ltrim($extension, '.');
329+
$extensions[$key] = ltrim($extension, '.');
330330
}
331331

332332
return \in_array($actualExtension, $extensions, true);
@@ -347,19 +347,19 @@ public static function changeExtension(string $path, string $extension): string
347347
}
348348

349349
$actualExtension = self::getExtension($path);
350-
$extension = \ltrim($extension, '.');
350+
$extension = ltrim($extension, '.');
351351

352352
// No extension for paths
353-
if ('/' === \mb_substr($path, -1)) {
353+
if ('/' === mb_substr($path, -1)) {
354354
return $path;
355355
}
356356

357357
// No actual extension in path
358358
if (empty($actualExtension)) {
359-
return $path.('.' === \mb_substr($path, -1) ? '' : '.').$extension;
359+
return $path.('.' === mb_substr($path, -1) ? '' : '.').$extension;
360360
}
361361

362-
return \mb_substr($path, 0, -\mb_strlen($actualExtension)).$extension;
362+
return mb_substr($path, 0, -mb_strlen($actualExtension)).$extension;
363363
}
364364

365365
public static function isAbsolute(string $path): bool
@@ -369,8 +369,8 @@ public static function isAbsolute(string $path): bool
369369
}
370370

371371
// Strip scheme
372-
if (false !== ($schemeSeparatorPosition = \mb_strpos($path, '://'))) {
373-
$path = \mb_substr($path, $schemeSeparatorPosition + 3);
372+
if (false !== ($schemeSeparatorPosition = mb_strpos($path, '://'))) {
373+
$path = mb_substr($path, $schemeSeparatorPosition + 3);
374374
}
375375

376376
$firstCharacter = $path[0];
@@ -381,9 +381,9 @@ public static function isAbsolute(string $path): bool
381381
}
382382

383383
// Windows root
384-
if (\mb_strlen($path) > 1 && \ctype_alpha($firstCharacter) && ':' === $path[1]) {
384+
if (mb_strlen($path) > 1 && ctype_alpha($firstCharacter) && ':' === $path[1]) {
385385
// Special case: "C:"
386-
if (2 === \mb_strlen($path)) {
386+
if (2 === mb_strlen($path)) {
387387
return true;
388388
}
389389

@@ -441,25 +441,25 @@ public static function isRelative(string $path): bool
441441
public static function makeAbsolute(string $path, string $basePath): string
442442
{
443443
if ('' === $basePath) {
444-
throw new InvalidArgumentException(\sprintf('The base path must be a non-empty string. Got: "%s"', $basePath));
444+
throw new InvalidArgumentException(sprintf('The base path must be a non-empty string. Got: "%s"', $basePath));
445445
}
446446

447447
if (!self::isAbsolute($basePath)) {
448-
throw new InvalidArgumentException(\sprintf('The base path "%s" is not an absolute path.', $basePath));
448+
throw new InvalidArgumentException(sprintf('The base path "%s" is not an absolute path.', $basePath));
449449
}
450450

451451
if (self::isAbsolute($path)) {
452452
return self::canonicalize($path);
453453
}
454454

455-
if (false !== ($schemeSeparatorPosition = \mb_strpos($basePath, '://'))) {
456-
$scheme = \mb_substr($basePath, 0, $schemeSeparatorPosition + 3);
457-
$basePath = \mb_substr($basePath, $schemeSeparatorPosition + 3);
455+
if (false !== ($schemeSeparatorPosition = mb_strpos($basePath, '://'))) {
456+
$scheme = mb_substr($basePath, 0, $schemeSeparatorPosition + 3);
457+
$basePath = mb_substr($basePath, $schemeSeparatorPosition + 3);
458458
} else {
459459
$scheme = '';
460460
}
461461

462-
return $scheme.self::canonicalize(\rtrim($basePath, '/\\').'/'.$path);
462+
return $scheme.self::canonicalize(rtrim($basePath, '/\\').'/'.$path);
463463
}
464464

465465
/**
@@ -526,7 +526,7 @@ public static function makeRelative(string $path, string $basePath): string
526526
if ('' === $root && '' !== $baseRoot) {
527527
// If base path is already in its root
528528
if ('' === $relativeBasePath) {
529-
$relativePath = \ltrim($relativePath, './\\');
529+
$relativePath = ltrim($relativePath, './\\');
530530
}
531531

532532
return $relativePath;
@@ -535,21 +535,21 @@ public static function makeRelative(string $path, string $basePath): string
535535
// If the passed path is absolute, but the base path is not, we
536536
// cannot generate a relative path
537537
if ('' !== $root && '' === $baseRoot) {
538-
throw new InvalidArgumentException(\sprintf('The absolute path "%s" cannot be made relative to the relative path "%s". You should provide an absolute base path instead.', $path, $basePath));
538+
throw new InvalidArgumentException(sprintf('The absolute path "%s" cannot be made relative to the relative path "%s". You should provide an absolute base path instead.', $path, $basePath));
539539
}
540540

541541
// Fail if the roots of the two paths are different
542542
if ($baseRoot && $root !== $baseRoot) {
543-
throw new InvalidArgumentException(\sprintf('The path "%s" cannot be made relative to "%s", because they have different roots ("%s" and "%s").', $path, $basePath, $root, $baseRoot));
543+
throw new InvalidArgumentException(sprintf('The path "%s" cannot be made relative to "%s", because they have different roots ("%s" and "%s").', $path, $basePath, $root, $baseRoot));
544544
}
545545

546546
if ('' === $relativeBasePath) {
547547
return $relativePath;
548548
}
549549

550550
// Build a "../../" prefix with as many "../" parts as necessary
551-
$parts = \explode('/', $relativePath);
552-
$baseParts = \explode('/', $relativeBasePath);
551+
$parts = explode('/', $relativePath);
552+
$baseParts = explode('/', $relativeBasePath);
553553
$dotDotPrefix = '';
554554

555555
// Once we found a non-matching part in the prefix, we need to add
@@ -567,15 +567,15 @@ public static function makeRelative(string $path, string $basePath): string
567567
$dotDotPrefix .= '../';
568568
}
569569

570-
return \rtrim($dotDotPrefix.\implode('/', $parts), '/');
570+
return rtrim($dotDotPrefix.implode('/', $parts), '/');
571571
}
572572

573573
/**
574574
* Returns whether the given path is on the local filesystem.
575575
*/
576576
public static function isLocal(string $path): bool
577577
{
578-
return '' !== $path && false === \mb_strpos($path, '://');
578+
return '' !== $path && false === mb_strpos($path, '://');
579579
}
580580

581581
/**
@@ -616,10 +616,10 @@ public static function isLocal(string $path): bool
616616
*/
617617
public static function getLongestCommonBasePath(string ...$paths): ?string
618618
{
619-
[$bpRoot, $basePath] = self::split(self::canonicalize(\reset($paths)));
619+
[$bpRoot, $basePath] = self::split(self::canonicalize(reset($paths)));
620620

621-
for (\next($paths); null !== \key($paths) && '' !== $basePath; \next($paths)) {
622-
[$root, $path] = self::split(self::canonicalize(\current($paths)));
621+
for (next($paths); null !== key($paths) && '' !== $basePath; next($paths)) {
622+
[$root, $path] = self::split(self::canonicalize(current($paths)));
623623

624624
// If we deal with different roots (e.g. C:/ vs. D:/), it's time
625625
// to quit
@@ -639,7 +639,7 @@ public static function getLongestCommonBasePath(string ...$paths): ?string
639639

640640
// Prevent false positives for common prefixes
641641
// see isBasePath()
642-
if (0 === \mb_strpos($path.'/', $basePath.'/')) {
642+
if (0 === mb_strpos($path.'/', $basePath.'/')) {
643643
// next path
644644
continue 2;
645645
}
@@ -667,17 +667,17 @@ public static function join(string ...$paths): string
667667
if (null === $finalPath) {
668668
// For first part we keep slashes, like '/top', 'C:\' or 'phar://'
669669
$finalPath = $path;
670-
$wasScheme = (false !== \mb_strpos($path, '://'));
670+
$wasScheme = (false !== mb_strpos($path, '://'));
671671
continue;
672672
}
673673

674674
// Only add slash if previous part didn't end with '/' or '\'
675-
if (!\in_array(\mb_substr($finalPath, -1), ['/', '\\'])) {
675+
if (!\in_array(mb_substr($finalPath, -1), ['/', '\\'])) {
676676
$finalPath .= '/';
677677
}
678678

679679
// If first part included a scheme like 'phar://' we allow \current part to start with '/', otherwise trim
680-
$finalPath .= $wasScheme ? $path : \ltrim($path, '/');
680+
$finalPath .= $wasScheme ? $path : ltrim($path, '/');
681681
$wasScheme = false;
682682
}
683683

@@ -718,15 +718,15 @@ public static function isBasePath(string $basePath, string $ofPath): bool
718718
// Don't append a slash for the root "/", because then that root
719719
// won't be discovered as common prefix ("//" is not a prefix of
720720
// "/foobar/").
721-
return 0 === \mb_strpos($ofPath.'/', \rtrim($basePath, '/').'/');
721+
return 0 === mb_strpos($ofPath.'/', rtrim($basePath, '/').'/');
722722
}
723723

724724
/**
725725
* @return non-empty-string[]
726726
*/
727727
private static function findCanonicalParts(string $root, string $pathWithoutRoot): array
728728
{
729-
$parts = \explode('/', $pathWithoutRoot);
729+
$parts = explode('/', $pathWithoutRoot);
730730

731731
$canonicalParts = [];
732732

@@ -739,7 +739,7 @@ private static function findCanonicalParts(string $root, string $pathWithoutRoot
739739
// Collapse ".." with the previous part, if one exists
740740
// Don't collapse ".." if the previous part is also ".."
741741
if ('..' === $part && \count($canonicalParts) > 0 && '..' !== $canonicalParts[\count($canonicalParts) - 1]) {
742-
\array_pop($canonicalParts);
742+
array_pop($canonicalParts);
743743

744744
continue;
745745
}
@@ -777,28 +777,28 @@ private static function split(string $path): array
777777
}
778778

779779
// Remember scheme as part of the root, if any
780-
if (false !== ($schemeSeparatorPosition = \mb_strpos($path, '://'))) {
781-
$root = \mb_substr($path, 0, $schemeSeparatorPosition + 3);
782-
$path = \mb_substr($path, $schemeSeparatorPosition + 3);
780+
if (false !== ($schemeSeparatorPosition = mb_strpos($path, '://'))) {
781+
$root = mb_substr($path, 0, $schemeSeparatorPosition + 3);
782+
$path = mb_substr($path, $schemeSeparatorPosition + 3);
783783
} else {
784784
$root = '';
785785
}
786786

787-
$length = \mb_strlen($path);
787+
$length = mb_strlen($path);
788788

789789
// Remove and remember root directory
790-
if (0 === \mb_strpos($path, '/')) {
790+
if (0 === mb_strpos($path, '/')) {
791791
$root .= '/';
792-
$path = $length > 1 ? \mb_substr($path, 1) : '';
793-
} elseif ($length > 1 && \ctype_alpha($path[0]) && ':' === $path[1]) {
792+
$path = $length > 1 ? mb_substr($path, 1) : '';
793+
} elseif ($length > 1 && ctype_alpha($path[0]) && ':' === $path[1]) {
794794
if (2 === $length) {
795795
// Windows special case: "C:"
796796
$root .= $path.'/';
797797
$path = '';
798798
} elseif ('/' === $path[2]) {
799799
// Windows normal case: "C:/"..
800-
$root .= \mb_substr($path, 0, 3);
801-
$path = $length > 3 ? \mb_substr($path, 3) : '';
800+
$root .= mb_substr($path, 0, 3);
801+
$path = $length > 3 ? mb_substr($path, 3) : '';
802802
}
803803
}
804804

@@ -808,10 +808,10 @@ private static function split(string $path): array
808808
private static function toLower(string $string): string
809809
{
810810
if (false !== $encoding = mb_detect_encoding($string)) {
811-
return \mb_strtolower($string, $encoding);
811+
return mb_strtolower($string, $encoding);
812812
}
813813

814-
return \strtolower($string, $encoding);
814+
return strtolower($string, $encoding);
815815
}
816816

817817
private function __construct()

0 commit comments

Comments
 (0)