Skip to content

Commit fa3471f

Browse files
committed
Cleanup codebase
1 parent 8be8c54 commit fa3471f

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

interfaces/UriString.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
use function array_merge;
2626
use function array_pop;
2727
use function array_reduce;
28-
use function end;
2928
use function explode;
3029
use function filter_var;
3130
use function implode;
@@ -420,7 +419,7 @@ public static function removeDotSegments(Stringable|string $path): string
420419

421420
$oldSegments = explode('/', $path);
422421
$newPath = implode('/', array_reduce($oldSegments, $reducer(...), []));
423-
if (isset(self::DOT_SEGMENTS[end($oldSegments)])) {
422+
if (isset(self::DOT_SEGMENTS[$oldSegments[array_key_last($oldSegments)]])) {
424423
$newPath .= '/';
425424
}
426425

uri/BaseUri.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
use function array_pop;
3030
use function array_reduce;
3131
use function count;
32-
use function end;
3332
use function explode;
3433
use function implode;
3534
use function in_array;
@@ -517,8 +516,7 @@ final protected static function formatPath(string $path, string $basePath): stri
517516
final protected static function formatPathWithEmptyBaseQuery(string $path): string
518517
{
519518
$targetSegments = static::getSegments($path);
520-
/** @var string $basename */
521-
$basename = end($targetSegments);
519+
$basename = $targetSegments[array_key_last($targetSegments)];
522520

523521
return '' === $basename ? './' : $basename;
524522
}
@@ -572,7 +570,7 @@ final protected function removeDotSegments(string $path): string
572570

573571
$oldSegments = explode('/', $path);
574572
$newPath = implode('/', array_reduce($oldSegments, $reducer(...), []));
575-
if (isset(static::DOT_SEGMENTS[end($oldSegments)])) {
573+
if (isset(static::DOT_SEGMENTS[$oldSegments[array_key_last($oldSegments)]])) {
576574
$newPath .= '/';
577575
}
578576

uri/Uri.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@
4141
use TypeError;
4242

4343
use function array_filter;
44+
use function array_key_last;
4445
use function array_map;
4546
use function array_pop;
4647
use function base64_decode;
4748
use function base64_encode;
4849
use function class_exists;
4950
use function count;
50-
use function end;
5151
use function explode;
5252
use function feof;
5353
use function file_get_contents;
@@ -1836,8 +1836,7 @@ public function relativize(Stringable|string $uri): UriInterface
18361836
private static function formatPathWithEmptyBaseQuery(string $path): string
18371837
{
18381838
$targetSegments = self::getSegments($path);
1839-
/** @var string $basename */
1840-
$basename = end($targetSegments);
1839+
$basename = $targetSegments[array_key_last($targetSegments)];
18411840

18421841
return '' === $basename ? './' : $basename;
18431842
}

0 commit comments

Comments
 (0)