[Filesystem] deprecate chmod support in dumpFile()

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.
This commit is contained in:
Christian Flothmann 2015-04-23 23:36:48 +02:00
parent c16930f9ae
commit faee0d714b
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);