deprecate relative paths in makePathRelative()
This commit is contained in:
parent
12bb22c4eb
commit
893df5804e
|
@ -66,6 +66,7 @@ Filesystem
|
|||
* The `Symfony\Component\Filesystem\LockHandler` class has been deprecated,
|
||||
use the `Symfony\Component\Lock\Store\FlockStore` class
|
||||
or the `Symfony\Component\Lock\Store\FlockStore\SemaphoreStore` class directly instead.
|
||||
* Support for passing relative paths to `Filesystem::makePathRelative()` is deprecated and will be removed in 4.0.
|
||||
|
||||
Finder
|
||||
------
|
||||
|
|
|
@ -200,6 +200,7 @@ Filesystem
|
|||
* The `Symfony\Component\Filesystem\LockHandler` has been removed,
|
||||
use the `Symfony\Component\Lock\Store\FlockStore` class
|
||||
or the `Symfony\Component\Lock\Store\FlockStore\SemaphoreStore` class directly instead.
|
||||
* Support for passing relative paths to `Filesystem::makePathRelative()` has been removed.
|
||||
|
||||
Finder
|
||||
------
|
||||
|
|
|
@ -5,6 +5,7 @@ CHANGELOG
|
|||
-----
|
||||
|
||||
* added `appendToFile()` to append contents to existing files
|
||||
* support for passing relative paths to `Filesystem::makePathRelative()` is deprecated and will be removed in 4.0
|
||||
|
||||
3.2.0
|
||||
-----
|
||||
|
|
|
@ -446,6 +446,10 @@ class Filesystem
|
|||
*/
|
||||
public function makePathRelative($endPath, $startPath)
|
||||
{
|
||||
if (!$this->isAbsolutePath($endPath) || !$this->isAbsolutePath($startPath)) {
|
||||
@trigger_error(sprintf('Support for passing relative paths to %s() is deprecated since version 3.4 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
// Normalize separators on Windows
|
||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||
$endPath = str_replace('\\', '/', $endPath);
|
||||
|
@ -596,7 +600,7 @@ class Filesystem
|
|||
{
|
||||
return strspn($file, '/\\', 0, 1)
|
||||
|| (strlen($file) > 3 && ctype_alpha($file[0])
|
||||
&& ':' === substr($file, 1, 1)
|
||||
&& ':' === $file[1]
|
||||
&& strspn($file, '/\\', 2, 1)
|
||||
)
|
||||
|| null !== parse_url($file, PHP_URL_SCHEME)
|
||||
|
|
|
@ -1103,7 +1103,6 @@ class FilesystemTest extends FilesystemTestCase
|
|||
array('/var/lib/symfony/src/Symfony/', '/var/lib/symfony/src/Symfony/Component/', '../'),
|
||||
array('/var/lib/symfony/src/Symfony', '/var/lib/symfony/src/Symfony/Component', '../'),
|
||||
array('/var/lib/symfony/src/Symfony', '/var/lib/symfony/src/Symfony/Component/', '../'),
|
||||
array('var/lib/symfony/', 'var/lib/symfony/src/Symfony/Component', '../../../'),
|
||||
array('/usr/lib/symfony/', '/var/lib/symfony/src/Symfony/Component', '../../../../../../usr/lib/symfony/'),
|
||||
array('/var/lib/symfony/src/Symfony/', '/var/lib/symfony/', 'src/Symfony/'),
|
||||
array('/aa/bb', '/aa/bb', './'),
|
||||
|
@ -1145,6 +1144,15 @@ class FilesystemTest extends FilesystemTestCase
|
|||
return $paths;
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Support for passing relative paths to Symfony\Component\Filesystem\Filesystem::makePathRelative() is deprecated since version 3.4 and will be removed in 4.0.
|
||||
*/
|
||||
public function testMakePathRelativeWithRelativePaths()
|
||||
{
|
||||
$this->assertSame('../../../', $this->filesystem->makePathRelative('var/lib/symfony/', 'var/lib/symfony/src/Symfony/Component'));
|
||||
}
|
||||
|
||||
public function testMirrorCopiesFilesAndDirectoriesRecursively()
|
||||
{
|
||||
$sourcePath = $this->workspace.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR;
|
||||
|
|
Reference in New Issue