Skip to content

Commit 4e3b24f

Browse files
author
smoench
committed
[Filesystem] depreacte calling isAbsolutePath with a null
1 parent 7750284 commit 4e3b24f

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
4.4.0
5+
-----
6+
7+
* support for passing a `null` value to `Filesystem::isAbsolutePath()` is deprecated and will be removed in 5.0
8+
49
4.3.0
510
-----
611

Filesystem.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,10 @@ public function mirror($originDir, $targetDir, \Traversable $iterator = null, $o
600600
*/
601601
public function isAbsolutePath($file)
602602
{
603+
if (null === $file) {
604+
@trigger_error(sprintf('Calling "%s()" with a null in the $file argument is deprecated since Symfony 4.4.', __METHOD__), E_USER_DEPRECATED);
605+
}
606+
603607
return strspn($file, '/\\', 0, 1)
604608
|| (\strlen($file) > 3 && ctype_alpha($file[0])
605609
&& ':' === $file[1]

Tests/FilesystemTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1397,10 +1397,18 @@ public function providePathsForIsAbsolutePath()
13971397
['var/lib', false],
13981398
['../var/lib', false],
13991399
['', false],
1400-
[null, false],
14011400
];
14021401
}
14031402

1403+
/**
1404+
* @group legacy
1405+
* @expectedDeprecation Calling "Symfony\Component\Filesystem\Filesystem::isAbsolutePath()" with a null in the $file argument is deprecated since Symfony 4.4.
1406+
*/
1407+
public function testIsAbsolutePathWithNull()
1408+
{
1409+
$this->assertFalse($this->filesystem->isAbsolutePath(null));
1410+
}
1411+
14041412
public function testTempnam()
14051413
{
14061414
$dirname = $this->workspace;

0 commit comments

Comments
 (0)