8000 [Filesystem] Add third argument `$flags` to `Filesystem::appendToFile()` · symfony/symfony@bc331f2 · GitHub
[go: up one dir, main page]

Skip to content

Commit bc331f2

Browse files
committed
[Filesystem] Add third argument $flags to Filesystem::appendToFile()
1 parent ee6bbb2 commit bc331f2

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/Symfony/Component/Filesystem/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CHANGELOG
55
---
66

77
* Add `Path` class
8+
* `Filesystem::appendToFile()` now accepts a third argument `$flags`, which will be added to \FILE_APPEND
89

910
5.0.0
1011
-----

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -691,11 +691,13 @@ public function dumpFile(string $filename, $content)
691691
/**
692692
* Appends content to an existing file.
693693
*
694+
* @param string $filename
694695
* @param string|resource $content The content to append
696+
* @param int $flags
695697
*
696698
* @throws IOException If the file is not writable
697699
*/
698-
public function appendToFile(string $filename, $content)
700+
public function appendToFile(string $filename, $content, int $flags = 0)
699701
{
700702
if (\is_array($content)) {
701703
throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be string or resource, array given.', __METHOD__));
@@ -707,7 +709,7 @@ public function appendToFile(string $filename, $content)
707709
$this->mkdir($dir);
708710
}
709711

710-
if (false === self::box('file_put_contents', $filename, $content, \FILE_APPEND)) {
712+
if (false === self::box('file_put_contents', $filename, $content, $flags | \FILE_APPEND)) {
711713
throw new IOException(sprintf('Failed to write file "%s": ', $filename).self::$lastError, 0, null, $filename);
712714
}
713715
}

0 commit comments

Comments
 (0)
0