minor #14460 [Filesystem] deprecate chmod support in dumpFile() (xabbuh)

This PR was merged into the 2.7 branch.

Discussion
----------

[Filesystem] deprecate chmod support in dumpFile()

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

The ability to support a custom permission mask in the `dumpFile()` method is deprecated since Symfony Symfony 2.3.12. This commit adds the `trigger_error()` call if a custom permission mask is passed.

Commits
-------

faee0d7 [Filesystem] deprecate chmod support in dumpFile()
This commit is contained in:
Fabien Potencier 2015-04-27 14:23:34 +02:00
commit 501df8d14c
2 changed files with 18 additions and 1 deletions

View File

@ -480,6 +480,10 @@ class Filesystem
$this->rename($tmpFile, $filename, true);
if (null !== $mode) {
if (func_num_args() > 2) {
trigger_error('Support for modifying file permissions is deprecated since version 2.3.12 and will be removed in 3.0.', E_USER_DEPRECATED);
}
$this->chmod($filename, $mode);
}
}

View File

@ -19,7 +19,7 @@ use Symfony\Component\Filesystem\Filesystem;
class FilesystemTest extends FilesystemTestCase
{
/**
* @var \Symfony\Component\Filesystem\Filesystem $filesystem
* @var \Symfony\Component\Filesystem\Filesystem
*/
private $filesystem = null;
@ -959,6 +959,19 @@ class FilesystemTest extends FilesystemTestCase
{
$filename = $this->workspace.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'baz.txt';
$this->filesystem->dumpFile($filename, 'bar');
$this->assertFileExists($filename);
$this->assertSame('bar', file_get_contents($filename));
}
/**
* @group legacy
*/
public function testDumpFileAndSetPermissions()
{
$filename = $this->workspace.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'baz.txt';
$this->filesystem->dumpFile($filename, 'bar', 0753);
$this->assertFileExists($filename);