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