Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Filesystem] deprecate calling isAbsolutePath with a null #32315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions UPGRADE-4.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ DependencyInjection
arguments: [!tagged_iterator app.handler]
```

Filesystem
----------

* Support for passing a `null` value to `Filesystem::isAbsolutePath()` is deprecated.

Form
----

Expand Down
1 change: 1 addition & 0 deletions UPGRADE-5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Component/Filesystem/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
-----

Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Component/Filesystem/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
10 changes: 9 additions & 1 deletion src/Symfony/Component/Filesystem/Tests/FilesystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down