[Filesystem] depreacte calling isAbsolutePath with a null

This commit is contained in:
smoench 2019-07-02 08:30:32 +02:00
parent 64eaf7e3a6
commit 93190182f6
No known key found for this signature in database
GPG Key ID: EB008C0F094A779B
5 changed files with 24 additions and 1 deletions

View File

@ -41,6 +41,11 @@ DependencyInjection
arguments: [!tagged_iterator app.handler] arguments: [!tagged_iterator app.handler]
``` ```
Filesystem
----------
* Support for passing a `null` value to `Filesystem::isAbsolutePath()` is deprecated.
Form Form
---- ----

View File

@ -135,6 +135,7 @@ EventDispatcher
Filesystem 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::dumpFile()` method no longer supports arrays in the `$content` argument.
* The `Filesystem::appendToFile()` method no longer supports arrays in the `$content` argument. * The `Filesystem::appendToFile()` method no longer supports arrays in the `$content` argument.

View File

@ -1,6 +1,11 @@
CHANGELOG 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 4.3.0
----- -----

View File

@ -600,6 +600,10 @@ class Filesystem
*/ */
public function isAbsolutePath($file) 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) return strspn($file, '/\\', 0, 1)
|| (\strlen($file) > 3 && ctype_alpha($file[0]) || (\strlen($file) > 3 && ctype_alpha($file[0])
&& ':' === $file[1] && ':' === $file[1]

View File

@ -1397,10 +1397,18 @@ class FilesystemTest extends FilesystemTestCase
['var/lib', false], ['var/lib', false],
['../var/lib', false], ['../var/lib', false],
['', 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() public function testTempnam()
{ {
$dirname = $this->workspace; $dirname = $this->workspace;