From 93190182f6796cffb9f16d1b55d4aceab17bffc3 Mon Sep 17 00:00:00 2001 From: smoench Date: Tue, 2 Jul 2019 08:30:32 +0200 Subject: [PATCH] [Filesystem] depreacte calling isAbsolutePath with a null --- UPGRADE-4.4.md | 5 +++++ UPGRADE-5.0.md | 1 + src/Symfony/Component/Filesystem/CHANGELOG.md | 5 +++++ src/Symfony/Component/Filesystem/Filesystem.php | 4 ++++ .../Component/Filesystem/Tests/FilesystemTest.php | 10 +++++++++- 5 files changed, 24 insertions(+), 1 deletion(-) diff --git a/UPGRADE-4.4.md b/UPGRADE-4.4.md index 96c170675cf6d..9d6ad7b3dc47a 100644 --- a/UPGRADE-4.4.md +++ b/UPGRADE-4.4.md @@ -41,6 +41,11 @@ DependencyInjection arguments: [!tagged_iterator app.handler] ``` +Filesystem +---------- + + * Support for passing a `null` value to `Filesystem::isAbsolutePath()` is deprecated. + Form ---- diff --git a/UPGRADE-5.0.md b/UPGRADE-5.0.md index bb6f87dd00877..3d613e647d762 100644 --- a/UPGRADE-5.0.md +++ b/UPGRADE-5.0.md @@ -135,6 +135,7 @@ EventDispatcher Filesystem ---------- + * The `Filesystem::isAbsolutePath()` method no longer supports `null` in the `$file` argument. * The `Filesystem::dumpFile()` method no longer supports arrays in the `$content` argument. * The `Filesystem::appendToFile()` method no longer supports arrays in the `$content` argument. diff --git a/src/Symfony/Component/Filesystem/CHANGELOG.md b/src/Symfony/Component/Filesystem/CHANGELOG.md index f6453c16e32d2..0b633ef2a7726 100644 --- a/src/Symfony/Component/Filesystem/CHANGELOG.md +++ b/src/Symfony/Component/Filesystem/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +4.4.0 +----- + + * support for passing a `null` value to `Filesystem::isAbsolutePath()` is deprecated and will be removed in 5.0 + 4.3.0 ----- diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index dd3d8b471edcc..969f5b05f99aa 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -600,6 +600,10 @@ public function mirror($originDir, $targetDir, \Traversable $iterator = null, $o */ public function isAbsolutePath($file) { + if (null === $file) { + @trigger_error(sprintf('Calling "%s()" with a null in the $file argument is deprecated since Symfony 4.4.', __METHOD__), E_USER_DEPRECATED); + } + return strspn($file, '/\\', 0, 1) || (\strlen($file) > 3 && ctype_alpha($file[0]) && ':' === $file[1] diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php index 7fa2ecd3de970..80fb44ec341ed 100644 --- a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php +++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php @@ -1397,10 +1397,18 @@ public function providePathsForIsAbsolutePath() ['var/lib', false], ['../var/lib', false], ['', false], - [null, false], ]; } + /** + * @group legacy + * @expectedDeprecation Calling "Symfony\Component\Filesystem\Filesystem::isAbsolutePath()" with a null in the $file argument is deprecated since Symfony 4.4. + */ + public function testIsAbsolutePathWithNull() + { + $this->assertFalse($this->filesystem->isAbsolutePath(null)); + } + public function testTempnam() { $dirname = $this->workspace;