Skip to content

Commit 6f6ec0d

Browse files
wouterjnicolas-grekas
authored andcommitted
[Components] Convert to native return types
1 parent 900b2f1 commit 6f6ec0d

File tree

1 file changed

+13
-39
lines changed

1 file changed

+13
-39
lines changed

Filesystem.php

Lines changed: 13 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,10 @@ class Filesystem
3131
* If the target file is newer, it is overwritten only when the
3232
* $overwriteNewerFiles option is set to true.
3333
*
34-
* @return void
35-
*
3634
* @throws FileNotFoundException When originFile doesn't exist
3735
* @throws IOException When copy fails
3836
*/
39-
public function copy(string $originFile, string $targetFile, bool $overwriteNewerFiles = false)
37+
public function copy(string $originFile, string $targetFile, bool $overwriteNewerFiles = false): void
4038
{
4139
$originIsLocal = stream_is_local($originFile) || 0 === stripos($originFile, 'file://');
4240
if ($originIsLocal && !is_file($originFile)) {
@@ -84,11 +82,9 @@ public function copy(string $originFile, string $targetFile, bool $overwriteNewe
8482
/**
8583
* Creates a directory recursively.
8684
*
87-
* @return void
88-
*
8985
* @throws IOException On any directory creation failure
9086
*/
91-
public function mkdir(string|iterable $dirs, int $mode = 0777)
87+
public function mkdir(string|iterable $dirs, int $mode = 0777): void
9288
{
9389
foreach ($this->toIterable($dirs) as $dir) {
9490
if (is_dir($dir)) {
@@ -127,11 +123,9 @@ public function exists(string|iterable $files): bool
127123
* @param int|null $time The touch time as a Unix timestamp, if not supplied the current system time is used
128124
* @param int|null $atime The access time as a Unix timestamp, if not supplied the current system time is used
129125
*
130-
* @return void
131-
*
132126
* @throws IOException When touch fails
133127
*/
134-
public function touch(string|iterable $files, int $time = null, int $atime = null)
128+
public function touch(string|iterable $files, int $time = null, int $atime = null): void
135129
{
136130
foreach ($this->toIterable($files) as $file) {
137131
if (!($time ? self::box('touch', $file, $time, $atime) : self::box('touch', $file))) {
@@ -143,11 +137,9 @@ public function touch(string|iterable $files, int $time = null, int $atime = nul
143137
/**
144138
* Removes files or directories.
145139
*
146-
* @return void
147-
*
148140
* @throws IOException When removal fails
149141
*/
150-
public function remove(string|iterable $files)
142+
public function remove(string|iterable $files): void
151143
{
152144
if ($files instanceof \Traversable) {
153145
$files = iterator_to_array($files, false);
@@ -211,11 +203,9 @@ private static function doRemove(array $files, bool $isRecursive): void
211203
* @param int $umask The mode mask (octal)
212204
* @param bool $recursive Whether change the mod recursively or not
213205
*
214-
* @return void
215-
*
216206
* @throws IOException When the change fails
217207
*/
218-
public function chmod(string|iterable $files, int $mode, int $umask = 0000, bool $recursive = false)
208+
public function chmod(string|iterable $files, int $mode, int $umask = 0000, bool $recursive = false): void
219209
{
220210
foreach ($this->toIterable($files) as $file) {
221211
if (!self::box('chmod', $file, $mode & ~$umask)) {
@@ -233,11 +223,9 @@ public function chmod(string|iterable $files, int $mode, int $umask = 0000, bool
233223
* @param string|int $user A user name or number
234224
* @param bool $recursive Whether change the owner recursively or not
235225
*
236-
* @return void
237-
*
238226
* @throws IOException When the change fails
239227
*/
240-
public function chown(string|iterable $files, string|int $user, bool $recursive = false)
228+
public function chown(string|iterable $files, string|int $user, bool $recursive = false): void
241229
{
242230
foreach ($this->toIterable($files) as $file) {
243231
if ($recursive && is_dir($file) && !is_link($file)) {
@@ -261,11 +249,9 @@ public function chown(string|iterable $files, string|int $user, bool $recursive
261249
* @param string|int $group A group name or number
262250
* @param bool $recursive Whether change the group recursively or not
263251
*
264-
* @return void
265-
*
266252
* @throws IOException When the change fails
267253
*/
268-
public function chgrp(string|iterable $files, string|int $group, bool $recursive = false)
254+
public function chgrp(string|iterable $files, string|int $group, bool $recursive = false): void
269255
{
270256
foreach ($this->toIterable($files) as $file) {
271257
if ($recursive && is_dir($file) && !is_link($file)) {
@@ -286,12 +272,10 @@ public function chgrp(string|iterable $files, string|int $group, bool $recursive
286272
/**
287273
* Renames a file or a directory.
288274
*
289-
* @return void
290-
*
291275
* @throws IOException When target file or directory already exists
292276
* @throws IOException When origin cannot be renamed
293277
*/
294-
public function rename(string $origin, string $target, bool $overwrite = false)
278+
public function rename(string $origin, string $target, bool $overwrite = false): void
295279
{
296280
// we check that target does not exist
297281
if (!$overwrite && $this->isReadable($target)) {
@@ -329,11 +313,9 @@ private function isReadable(string $filename): bool
329313
/**
330314
* Creates a symbolic link or copy a directory.
331315
*
332-
* @return void
333-
*
334316
* @throws IOException When symlink fails
335317
*/
336-
public function symlink(string $originDir, string $targetDir, bool $copyOnWindows = false)
318+
public function symlink(string $originDir, string $targetDir, bool $copyOnWindows = false): void
337319
{
338320
self::assertFunctionExists('symlink');
339321

@@ -367,12 +349,10 @@ public function symlink(string $originDir, string $targetDir, bool $copyOnWindow
367349
*
368350
* @param string|string[] $targetFiles The target file(s)
369351
*
370-
* @return void
371-
*
372352
* @throws FileNotFoundException When original file is missing or not a file
373353
* @throws IOException When link fails, including if link already exists
374354
*/
375-
public function hardlink(string $originFile, string|iterable $targetFiles)
355+
public function hardlink(string $originFile, string|iterable $targetFiles): void
376356
{
377357
self::assertFunctionExists('link');
378358

@@ -526,11 +506,9 @@ public function makePathRelative(string $endPath, string $startPath): string
526506
* - $options['copy_on_windows'] Whether to copy files instead of links on Windows (see symlink(), defaults to false)
527507
* - $options['delete'] Whether to delete files that are not in the source directory (defaults to false)
528508
*
529-
* @return void
530-
*
531509
* @throws IOException When file type is unknown
532510
*/
533-
public function mirror(string $originDir, string $targetDir, \Traversable $iterator = null, array $options = [])
511+
public function mirror(string $originDir, string $targetDir, \Traversable $iterator = null, array $options = []): void
534512
{
535513
$targetDir = rtrim($targetDir, '/\\');
536514
$originDir = rtrim($originDir, '/\\');
@@ -652,11 +630,9 @@ public function tempnam(string $dir, string $prefix, string $suffix = ''): strin
652630
*
653631
* @param string|resource $content The data to write into the file
654632
*
655-
* @return void
656-
*
657633
* @throws IOException if the file cannot be written to
658634
*/
659-
public function dumpFile(string $filename, $content)
635+
public function dumpFile(string $filename, $content): void
660636
{
661637
if (\is_array($content)) {
662638
throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be string or resource, array given.', __METHOD__));
@@ -699,11 +675,9 @@ public function dumpFile(string $filename, $content)
699675
* @param string|resource $content The content to append
700676
* @param bool $lock Whether the file should be locked when writing to it
701677
*
702-
* @return void
703-
*
704678
* @throws IOException If the file is not writable
705679
*/
706-
public function appendToFile(string $filename, $content, bool $lock = false)
680+
public function appendToFile(string $filename, $content, bool $lock = false): void
707681
{
708682
if (\is_array($content)) {
709683
throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be string or resource, array given.', __METHOD__));

0 commit comments

Comments
 (0)