bug #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
This commit is contained in:
commit
184a40ae20
@ -480,11 +480,11 @@ class Filesystem
|
|||||||
$startPathArr = explode('/', trim($startPath, '/'));
|
$startPathArr = explode('/', trim($startPath, '/'));
|
||||||
$endPathArr = explode('/', trim($endPath, '/'));
|
$endPathArr = explode('/', trim($endPath, '/'));
|
||||||
|
|
||||||
$normalizePathArray = function ($pathSegments, $absolute) {
|
$normalizePathArray = function ($pathSegments) {
|
||||||
$result = array();
|
$result = array();
|
||||||
|
|
||||||
foreach ($pathSegments as $segment) {
|
foreach ($pathSegments as $segment) {
|
||||||
if ('..' === $segment && ($absolute || count($result))) {
|
if ('..' === $segment) {
|
||||||
array_pop($result);
|
array_pop($result);
|
||||||
} elseif ('.' !== $segment) {
|
} elseif ('.' !== $segment) {
|
||||||
$result[] = $segment;
|
$result[] = $segment;
|
||||||
@ -494,8 +494,8 @@ class Filesystem
|
|||||||
return $result;
|
return $result;
|
||||||
};
|
};
|
||||||
|
|
||||||
$startPathArr = $normalizePathArray($startPathArr, static::isAbsolutePath($startPath));
|
$startPathArr = $normalizePathArray($startPathArr);
|
||||||
$endPathArr = $normalizePathArray($endPathArr, static::isAbsolutePath($endPath));
|
$endPathArr = $normalizePathArray($endPathArr);
|
||||||
|
|
||||||
// Find for which directory the common path stops
|
// Find for which directory the common path stops
|
||||||
$index = 0;
|
$index = 0;
|
||||||
|
Reference in New Issue
Block a user