55/**
66 * Describes a stream instance.
77 */
8- interface StreamInterface
8+ interface StreamableInterface
99{
1010 /**
1111 * Reads all data from the stream into a string, from the beginning to end.
@@ -31,10 +31,25 @@ public function close();
3131 *
3232 * After the stream has been detached, the stream is in an unusable state.
3333 *
34- * @return void
34+ * @return resource|null Underlying PHP stream, if any
3535 */
3636 public function detach ();
3737
38+ /**
39+ * Replaces the underlying stream resource with the provided stream.
40+ *
41+ * Use this method to replace the underlying stream with another; as an
42+ * example, in server-side code, if you decide to return a file, you
43+ * would replace the original content-oriented stream with the file
44+ * stream.
45+ *
46+ * Any internal state such as caching of cursor position should be reset
47+ * when attach() is called, as the stream has changed.
48+ *
49+ * @return void
50+ */
51+ public function attach ($ stream );
52+
3853 /**
3954 * Get the size of the stream if known
4055 *
@@ -115,11 +130,25 @@ public function isReadable();
115130 public function read ($ length );
116131
117132 /**
118- * Returns the remaining contents in a string, up to maxlength bytes.
133+ * Returns the remaining contents in a string
119134 *
120- * @param int $maxLength The maximum bytes to read. Defaults to -1 (read
121- * all the remaining buffer).
122135 * @return string
123136 */
124- public function getContents ($ maxLength = -1 );
137+ public function getContents ();
138+
139+ /**
140+ * Get stream metadata as an associative array or retrieve a specific key.
141+ *
142+ * The keys returned are identical to the keys returned from PHP's
143+ * stream_get_meta_data() function.
144+ *
145+ * @param string $key Specific metadata to retrieve.
146+ *
147+ * @return array|mixed|null Returns an associative array if no key is
148+ * provided. Returns a specific key value if a key
149+ * is provided and the value is found, or null if
150+ * the key is not found.
151+ * @see http://php.net/manual/en/function.stream-get-meta-data.php
152+ */
153+ public function getMetadata ($ key = null );
125154}
0 commit comments