@@ -24,25 +24,31 @@ function stream_context_set_params($context, array $params): void
2424
2525
2626/**
27- * Makes a copy of up to maxlength bytes
27+ * Makes a copy of up to length bytes
2828 * of data from the current position (or from the
2929 * offset position, if specified) in
30- * source to dest . If
31- * maxlength is not specified , all remaining content in
32- * source will be copied.
30+ * from to to . If
31+ * length is NULL , all remaining content in
32+ * from will be copied.
3333 *
34- * @param resource $source The source stream
35- * @param resource $dest The destination stream
36- * @param int $maxlength Maximum bytes to copy
34+ * @param resource $from The source stream
35+ * @param resource $to The destination stream
36+ * @param int $length Maximum bytes to copy. By default all bytes left are copied.
3737 * @param int $offset The offset where to start to copy data
3838 * @return int Returns the total count of bytes copied.
3939 * @throws StreamException
4040 *
4141 */
42- function stream_copy_to_stream ($ source , $ dest , int $ maxlength = - 1 , int $ offset = 0 ): int
42+ function stream_copy_to_stream ($ from , $ to , int $ length = null , int $ offset = 0 ): int
4343{
4444 error_clear_last ();
45- $ result = \stream_copy_to_stream ($ source , $ dest , $ maxlength , $ offset );
45+ if ($ offset !== 0 ) {
46+ $ result = \stream_copy_to_stream ($ from , $ to , $ length , $ offset );
47+ } elseif ($ length !== null ) {
48+ $ result = \stream_copy_to_stream ($ from , $ to , $ length );
49+ } else {
50+ $ result = \stream_copy_to_stream ($ from , $ to );
51+ }
4652 if ($ result === false ) {
4753 throw StreamException::createFromPhpError ();
4854 }
0 commit comments