10000 Remove unnecessary if construct · symfony/symfony@fc745f4 · GitHub
[go: up one dir, main page]

Skip to content

Commit fc745f4

Browse files
committed
Remove unnecessary if construct
If `0 === $depth` evaluates to true `str_repeat('../', $depth)` would result in the empty string anyway, so there is no need to handle this case.
1 parent 2adfb37 commit fc745f4

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -400,13 +400,8 @@ public function makePathRelative($endPath, $startPath)
400400
$depth = count($startPathArr) - $index;
401401
}
402402

403-
// When we need to traverse from the start, and we are starting from a root path, don't add '../'
404-
if ('/' === $startPath[0] && 0 === $index && 0 === $depth) {
405-
$traverser = '';
406-
} else {
407-
// Repeated "../" for each level need to reach the common path
408-
$traverser = str_repeat('../', $depth);
409-
}
403+
// Repeated "../" for each level need to reach the common path
404+
$traverser = str_repeat('../', $depth);
410405

411406
$endPathRemainder = implode('/', array_slice($endPathArr, $index));
412407

0 commit comments

Comments
 (0)
0