@@ -89,13 +89,13 @@ function chown(string $filename, $user): void
89
89
90
90
91
91
/**
92
- * Makes a copy of the file source to
93
- * dest .
92
+ * Makes a copy of the file from to
93
+ * to .
94
94
*
95
95
* If you wish to move a file, use the rename function.
96
96
*
97
- * @param string $source Path to the source file.
98
- * @param string $dest The destination path. If dest is a URL, the
97
+ * @param string $from Path to the source file.
98
+ * @param string $to The destination path. If to is a URL, the
99
99
* copy operation may fail if the wrapper does not support overwriting of
100
100
* existing files.
101
101
*
@@ -105,13 +105,13 @@ function chown(string $filename, $user): void
105
105
* @throws FilesystemException
106
106
*
107
107
*/
108
- function copy (string $ source , string $ dest , $ context = null ): void
108
+ function copy (string $ from , string $ to , $ context = null ): void
109
109
{
110
110
error_clear_last ();
111
111
if ($ context !== null ) {
112
- $ result = \copy ($ source , $ dest , $ context );
112
+ $ result = \copy ($ from , $ to , $ context );
113
113
} else {
114
- $ result = \copy ($ source , $ dest );
114
+ $ result = \copy ($ from , $ to );
115
115
}
116
116
if ($ result === false ) {
117
117
throw FilesystemException::createFromPhpError ();
@@ -226,6 +226,52 @@ function fflush($stream): void
226
226
}
227
227
228
228
229
+ /**
230
+ * Similar to fgets except that
231
+ * fgetcsv parses the line it reads for fields in
232
+ * CSV format and returns an array containing the fields
233
+ * read.
234
+ *
235
+ * @param resource $stream A valid file pointer to a file successfully opened by
236
+ * fopen, popen, or
237
+ * fsockopen.
238
+ * @param int $length Must be greater than the longest line (in characters) to be found in
239
+ * the CSV file (allowing for trailing line-end characters). Otherwise the
240
+ * line is split in chunks of length characters,
241
+ * unless the split would occur inside an enclosure.
242
+ *
243
+ * Omitting this parameter (or setting it to 0,
244
+ * or NULL in PHP 8.0.0 or later) the maximum line length is not limited,
245
+ * which is slightly slower.
246
+ * @param string $separator The optional separator parameter sets the field separator (one single-byte character only).
247
+ * @param string $enclosure The optional enclosure parameter sets the field enclosure character (one single-byte character only).
248
+ * @param string $escape The optional escape parameter sets the escape character (at most one single-byte character).
249
+ * An empty string ("") disables the proprietary escape mechanism.
250
+ * @return array|false|null Returns an indexed array containing the fields read on success.
251
+ * @throws FilesystemException
252
+ *
253
+ */
254
+ function fgetcsv ($ stream , int $ length = null , string $ separator = ", " , string $ enclosure = "\"" , string $ escape = "\\" )
255
+ {
256
+ error_clear_last ();
257
+ if ($ escape !== "\\" ) {
258
+ $ result = \fgetcsv ($ stream , $ length , $ separator , $ enclosure , $ escape );
259
+ } elseif ($ enclosure !== "\"" ) {
260
+ $ result = \fgetcsv ($ stream , $ length , $ separator , $ enclosure );
261
+ } elseif ($ separator !== ", " ) {
262
+ $ result = \fgetcsv ($ stream , $ length , $ separator );
263
+ } elseif ($ length !== null ) {
264
+ $ result = \fgetcsv ($ stream , $ length );
265
+ } else {
266
+ $ result = \fgetcsv ($ stream );
267
+ }
268
+ if ($ result === false ) {
269
+ throw FilesystemException::createFromPhpError ();
270
+ }
271
+ return $ result ;
272
+ }
273
+
274
+
229
275
/**
230
276
* This function is similar to file, except that
231
277
* file_get_contents returns the file in a
@@ -872,7 +918,7 @@ function fopen(string $filename, string $mode, bool $use_include_path = false, $
872
918
* @throws FilesystemException
873
919
*
874
920
*/
875
- function fputcsv ($ stream , array $ fields , string $ separator = ", " , string $ enclosure = ' " ' , string $ escape = "\\" , string $ eol = "\n" ): int
921
+ function fputcsv ($ stream , array $ fields , string $ separator = ", " , string $ enclosure = "\"" , string $ escape = "\\" , string $ eol = "\n" ): int
876
922
{
877
923
error_clear_last ();
878
924
$ result = \fputcsv ($ stream , $ fields , $ separator , $ enclosure , $ escape , $ eol );
@@ -1009,24 +1055,23 @@ function ftruncate($stream, int $size): void
1009
1055
/**
1010
1056
*
1011
1057
*
1012
- * @param resource $handle A file system pointer resource
1058
+ * @param resource $stream A file system pointer resource
1013
1059
* that is typically created using fopen.
1014
- * @param string $string The string that is to be written.
1015
- * @param int $length If the length argument is given, writing will
1016
- * stop after length bytes have been written or
1017
- * the end of string is reached, whichever comes
1018
- * first.
1060
+ * @param string $data The string that is to be written.
1061
+ * @param int $length If length is an integer, writing will stop
1062
+ * after length bytes have been written or the
1063
+ * end of data is reached, whichever comes first.
1019
1064
* @return int
1020
1065
* @throws FilesystemException
1021
1066
*
1022
1067
*/
1023
- function fwrite ($ handle , string $ string , int $ length = null ): int
1068
+ function fwrite ($ stream , string $ data , int $ length = null ): int
1024
1069
{
1025
1070
error_clear_last ();
1026
1071
if ($ length !== null ) {
1027
- $ result = \fwrite ($ handle , $ string , $ length );
1072
+ $ result = \fwrite ($ stream , $ data , $ length );
1028
1073
} else {
1029
- $ result = \fwrite ($ handle , $ string );
1074
+ $ result = \fwrite ($ stream , $ data );
1030
1075
}
1031
1076
if ($ result === false ) {
1032
1077
throw FilesystemException::createFromPhpError ();
@@ -1420,22 +1465,22 @@ function realpath(string $path): string
1420
1465
1421
1466
1422
1467
/**
1423
- * Attempts to rename oldname to
1424
- * newname , moving it between directories if necessary.
1425
- * If renaming a file and newname exists,
1468
+ * Attempts to rename from to
1469
+ * to , moving it between directories if necessary.
1470
+ * If renaming a file and to exists,
1426
1471
* it will be overwritten. If renaming a directory and
1427
- * newname exists,
1472
+ * to exists,
1428
1473
* this function will emit a warning.
1429
1474
*
1430
- * @param string $oldname The old name.
1475
+ * @param string $from The old name.
1431
1476
*
1432
- * The wrapper used in oldname
1477
+ * The wrapper used in from
1433
1478
* must match the wrapper used in
1434
- * newname .
1435
- * @param string $newname The new name.
1479
+ * to .
1480
+ * @param string $to The new name.
1436
1481
*
1437
1482
*
1438
- * On Windows, if newname already exists, it must be writable.
1483
+ * On Windows, if to already exists, it must be writable.
1439
1484
* Otherwise rename fails and issues E_WARNING.
1440
1485
*
1441
1486
*
@@ -1444,13 +1489,13 @@ function realpath(string $path): string
1444
1489
* @throws FilesystemException
1445
1490
*
1446
1491
*/
1447
- function rename (string $ oldname , string $ newname , $ context = null ): void
1492
+ function rename (string $ from , string $ to , $ context = null ): void
1448
1493
{
1449
1494
error_clear_last ();
1450
1495
if ($ context !== null ) {
1451
- $ result = \rename ($ oldname , $ newname , $ context );
1496
+ $ result = \rename ($ from , $ to , $ context );
1452
1497
} else {
1453
- $ result = \rename ($ oldname , $ newname );
1498
+ $ result = \rename ($ from , $ to );
1454
1499
}
1455
1500
if ($ result === false ) {
1456
1501
throw FilesystemException::createFromPhpError ();
@@ -1573,29 +1618,29 @@ function tmpfile()
1573
1618
/**
1574
1619
* Attempts to set the access and modification times of the file named in the
1575
1620
* filename parameter to the value given in
1576
- * time .
1621
+ * mtime .
1577
1622
* Note that the access time is always modified, regardless of the number
1578
1623
* of parameters.
1579
1624
*
1580
1625
* If the file does not exist, it will be created.
1581
1626
*
1582
1627
* @param string $filename The name of the file being touched.
1583
- * @param int $time The touch time. If time is not supplied ,
1628
+ * @param int $mtime The touch time. If mtime is NULL ,
1584
1629
* the current system time is used.
1585
- * @param int $atime If present , the access time of the given filename is set to
1630
+ * @param int $atime If NULL , the access time of the given filename is set to
1586
1631
* the value of atime. Otherwise, it is set to
1587
- * the value passed to the time parameter.
1588
- * If neither are present , the current system time is used.
1632
+ * the value passed to the mtime parameter.
1633
+ * If both are NULL , the current system time is used.
1589
1634
* @throws FilesystemException
1590
1635
*
1591
1636
*/
1592
- function touch (string $ filename , int $ time = null , int $ atime = null ): void
1637
+ function touch (string $ filename , int $ mtime = null , int $ atime = null ): void
1593
1638
{
1594
1639
error_clear_last ();
1595
1640
if ($ atime !== null ) {
1596
- $ result = \touch ($ filename , $ time , $ atime );
1597
- } elseif ($ time !== null ) {
1598
- $ result = \touch ($ filename , $ time );
1641
+ $ result = \touch ($ filename , $ mtime , $ atime );
1642
+ } elseif ($ mtime !== null ) {
1643
+ $ result = \touch ($ filename , $ mtime );
1599
1644
} else {
1600
1645
$ result = \touch ($ filename );
1601
1646
}
0 commit comments