Skip to content

Commit 0544bdd

Browse files
committed
Merge pull request #3 from weierophinney/hotfix/sync-to-proposal
Sync interfaces with recent changes in proposal
2 parents 98ef8f2 + c49ddf2 commit 0544bdd

File tree

2 files changed

+39
-10
lines changed

2 files changed

+39
-10
lines changed

src/MessageInterface.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,23 @@ public function getProtocolVersion();
2020
/**
2121
* Gets the body of the message.
2222
*
23-
* @return StreamInterface|null Returns the body, or null if not set.
23+
* @return StreamableInterface|null Returns the body, or null if not set.
2424
*/
2525
public function getBody();
2626

2727
/**
2828
* Sets the body of the message.
2929
*
30-
* The body MUST be a StreamInterface object. Setting the body to null MUST
30+
* The body MUST be a StreamableInterface object. Setting the body to null MUST
3131
* remove the existing body.
3232
*
33-
* @param StreamInterface|null $body Body.
33+
* @param StreamableInterface|null $body Body.
3434
*
3535
* @return void
3636
*
3737
* @throws \InvalidArgumentException When the body is not valid.
3838
*/
39-
public function setBody(StreamInterface $body = null);
39+
public function setBody(StreamableInterface $body = null);
4040

4141
/**
4242
* Gets all message headers.

src/StreamInterface.php renamed to src/StreamableInterface.php

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
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

Comments
 (0)