8000 minor #18195 Improved the PHPdoc of FileSystem::copy() (javiereguiluz) · symfony/symfony@56624e6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 56624e6

Browse files
minor #18195 Improved the PHPdoc of FileSystem::copy() (javiereguiluz)
This PR was squashed before being merged into the 2.3 branch (closes #18195). Discussion ---------- Improved the PHPdoc of FileSystem::copy() | Q | A | ------------- | --- | Branch | 2.3+ | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #12937 | License | MIT | Doc PR | - Commits ------- 9ad67ca Improved the PHPdoc of FileSystem::copy()
2 parents 092a42b + 9ad67ca commit 56624e6

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ class Filesystem
2323
/**
2424
* Copies a file.
2525
*
26-
* This method only copies the file if the origin file is newer than the target file.
26+
* If the target file is older than the origin file, it's always overwritten.
27+
* If the target file is newer, it is overwritten only when the
28+
* $overwriteNewerFiles option is set to true.
2729
*
28-
* By default, if the target already exists, it is not overridden.
29-
*
30-
* @param string $originFile The original filename
31-
* @param string $targetFile The target filename
32-
* @param bool $override Whether to override an existing file or not
30+
* @param string $originFile The original filename
31+
* @param string $targetFile The target filename
32+
* @param bool $overwriteNewerFiles If true, target files newer than origin files are overwritten
3333
*
3434
* @throws IOException When copy fails
3535
*/
36-
public function copy($originFile, $targetFile, $override = false)
36+
public function copy($originFile, $targetFile, $overwriteNewerFiles = false)
3737
{
3838
if (stream_is_local($originFile) && !is_file($originFile)) {
3939
throw new IOException(sprintf('Failed to copy %s because file not exists', $originFile));
@@ -42,7 +42,7 @@ public function copy($originFile, $targetFile, $override = false)
4242
$this->mkdir(dirname($targetFile));
4343

4444
$doCopy = true;
45-
if (!$override && null === parse_url($originFile, PHP_URL_HOST) && is_file($targetFile)) {
45+
if (!$overwriteNewerFiles && null === parse_url($originFile, PHP_URL_HOST) && is_file($targetFile)) {
4646
$doCopy = filemtime($originFile) > filemtime($targetFile);
4747
}
4848

0 commit comments

Comments
 (0)
0