@@ -89,13 +89,13 @@ function chown(string $filename, $user): void
8989
9090
9191/**
92- * Makes a copy of the file source to
93- * dest .
92+ * Makes a copy of the file from to
93+ * to .
9494 *
9595 * If you wish to move a file, use the rename function.
9696 *
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
9999 * copy operation may fail if the wrapper does not support overwriting of
100100 * existing files.
101101 *
@@ -105,13 +105,13 @@ function chown(string $filename, $user): void
105105 * @throws FilesystemException
106106 *
107107 */
108- function copy (string $ source , string $ dest , $ context = null ): void
108+ function copy (string $ from , string $ to , $ context = null ): void
109109{
110110 error_clear_last ();
111111 if ($ context !== null ) {
112- $ result = \copy ($ source , $ dest , $ context );
112+ $ result = \copy ($ from , $ to , $ context );
113113 } else {
114- $ result = \copy ($ source , $ dest );
114+ $ result = \copy ($ from , $ to );
115115 }
116116 if ($ result === false ) {
117117 throw FilesystemException::createFromPhpError ();
@@ -226,6 +226,52 @@ function fflush($stream): void
226226}
227227
228228
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+
229275/**
230276 * This function is similar to file, except that
231277 * file_get_contents returns the file in a
@@ -872,7 +918,7 @@ function fopen(string $filename, string $mode, bool $use_include_path = false, $
872918 * @throws FilesystemException
873919 *
874920 */
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
876922{
877923 error_clear_last ();
878924 $ result = \fputcsv ($ stream , $ fields , $ separator , $ enclosure , $ escape , $ eol );
@@ -1009,24 +1055,23 @@ function ftruncate($stream, int $size): void
10091055/**
10101056 *
10111057 *
1012- * @param resource $handle A file system pointer resource
1058+ * @param resource $stream A file system pointer resource
10131059 * 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.
10191064 * @return int
10201065 * @throws FilesystemException
10211066 *
10221067 */
1023- function fwrite ($ handle , string $ string , int $ length = null ): int
1068+ function fwrite ($ stream , string $ data , int $ length = null ): int
10241069{
10251070 error_clear_last ();
10261071 if ($ length !== null ) {
1027- $ result = \fwrite ($ handle , $ string , $ length );
1072+ $ result = \fwrite ($ stream , $ data , $ length );
10281073 } else {
1029- $ result = \fwrite ($ handle , $ string );
1074+ $ result = \fwrite ($ stream , $ data );
10301075 }
10311076 if ($ result === false ) {
10321077 throw FilesystemException::createFromPhpError ();
@@ -1420,22 +1465,22 @@ function realpath(string $path): string
14201465
14211466
14221467/**
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,
14261471 * it will be overwritten. If renaming a directory and
1427- * newname exists,
1472+ * to exists,
14281473 * this function will emit a warning.
14291474 *
1430- * @param string $oldname The old name.
1475+ * @param string $from The old name.
14311476 *
1432- * The wrapper used in oldname
1477+ * The wrapper used in from
14331478 * must match the wrapper used in
1434- * newname .
1435- * @param string $newname The new name.
1479+ * to .
1480+ * @param string $to The new name.
14361481 *
14371482 *
1438- * On Windows, if newname already exists, it must be writable.
1483+ * On Windows, if to already exists, it must be writable.
14391484 * Otherwise rename fails and issues E_WARNING.
14401485 *
14411486 *
@@ -1444,13 +1489,13 @@ function realpath(string $path): string
14441489 * @throws FilesystemException
14451490 *
14461491 */
1447- function rename (string $ oldname , string $ newname , $ context = null ): void
1492+ function rename (string $ from , string $ to , $ context = null ): void
14481493{
14491494 error_clear_last ();
14501495 if ($ context !== null ) {
1451- $ result = \rename ($ oldname , $ newname , $ context );
1496+ $ result = \rename ($ from , $ to , $ context );
14521497 } else {
1453- $ result = \rename ($ oldname , $ newname );
1498+ $ result = \rename ($ from , $ to );
14541499 }
14551500 if ($ result === false ) {
14561501 throw FilesystemException::createFromPhpError ();
@@ -1573,29 +1618,29 @@ function tmpfile()
15731618/**
15741619 * Attempts to set the access and modification times of the file named in the
15751620 * filename parameter to the value given in
1576- * time .
1621+ * mtime .
15771622 * Note that the access time is always modified, regardless of the number
15781623 * of parameters.
15791624 *
15801625 * If the file does not exist, it will be created.
15811626 *
15821627 * @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 ,
15841629 * 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
15861631 * 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.
15891634 * @throws FilesystemException
15901635 *
15911636 */
1592- function touch (string $ filename , int $ time = null , int $ atime = null ): void
1637+ function touch (string $ filename , int $ mtime = null , int $ atime = null ): void
15931638{
15941639 error_clear_last ();
15951640 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 );
15991644 } else {
16001645 $ result = \touch ($ filename );
16011646 }
0 commit comments