Skip to content

Commit 184a40a

Browse files
bug symfony#25022 [Filesystem] Updated Filesystem::makePathRelative (inso)
This PR was merged into the 4.0-dev branch. Discussion ---------- [Filesystem] Updated Filesystem::makePathRelative | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Removed checks for absolute paths since Symfony >= 4.0 drops support for relative paths. Commits ------- 9da7c50 removed checks for absolute paths
2 parents 1193c26 + 9da7c50 commit 184a40a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -480,11 +480,11 @@ public function makePathRelative($endPath, $startPath)
480480
$startPathArr = explode('/', trim($startPath, '/'));
481481
$endPathArr = explode('/', trim($endPath, '/'));
482482

483-
$normalizePathArray = function ($pathSegments, $absolute) {
483+
$normalizePathArray = function ($pathSegments) {
484484
$result = array();
485485

486486
foreach ($pathSegments as $segment) {
487-
if ('..' === $segment && ($absolute || count($result))) {
487+
if ('..' === $segment) {
488488
array_pop($result);
489489
} elseif ('.' !== $segment) {
490490
$result[] = $segment;
@@ -494,8 +494,8 @@ public function makePathRelative($endPath, $startPath)
494494
return $result;
495495
};
496496

497-
$startPathArr = $normalizePathArray($startPathArr, static::isAbsolutePath($startPath));
498-
$endPathArr = $normalizePathArray($endPathArr, static::isAbsolutePath($endPath));
497+
$startPathArr = $normalizePathArray($startPathArr);
498+
$endPathArr = $normalizePathArray($endPathArr);
499499

500500
// Find for which directory the common path stops
501501
$index = 0;

0 commit comments

Comments
 (0)