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

Skip to content

Commit 71d1d51

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

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ public function dumpFile(string $filename, $content)
695695
*
696696
* @throws IOException If the file is not writable
697697
*/
698-
public function appendToFile(string $filename, $content)
698+
public function appendToFile(string $filename, $content, int $flags = 0)
699699
{
700700
if (\is_array($content)) {
701701
throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be string or resource, array given.', __METHOD__));
@@ -707,7 +707,7 @@ public function appendToFile(string $filename, $content)
707707
$this->mkdir($dir);
708708
}
709709

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

0 commit comments

Comments
 (0)
0