1 | <?php |
||
11 | final class MessageStream implements StreamInterface |
||
12 | { |
||
13 | /** |
||
14 | * @var StreamInterface |
||
15 | */ |
||
16 | private $decoratedStream; |
||
17 | |||
18 | /** |
||
19 | * MessageStream constructor. |
||
20 | * @param MessageInterface $message |
||
21 | */ |
||
22 | public function __construct(MessageInterface $message) |
||
23 | { |
||
24 | 22 | $this->decoratedStream = new LazyStream(function () use ($message) { |
|
25 | 22 | $headerString = implode( |
|
26 | 22 | "\r\n", |
|
27 | 22 | array_values( |
|
28 | 22 | array_filter( |
|
29 | 22 | array_map( |
|
30 | 22 | function (array $headers) { |
|
31 | 22 | return implode( |
|
32 | 22 | "\r\n", |
|
33 | 22 | array_map( |
|
34 | 22 | function (HeaderInterface $header) { |
|
35 | 22 | return (string) (new HeaderLine($header)); |
|
36 | 22 | }, |
|
37 | 22 | $headers |
|
38 | ) |
||
39 | ); |
||
40 | 22 | }, |
|
41 | 22 | $message->getHeaders() |
|
42 | ) |
||
43 | ) |
||
44 | ) |
||
45 | ); |
||
46 | |||
47 | 22 | return new ConcatenatedStream( |
|
48 | 22 | new \ArrayObject([ |
|
|
|||
49 | 22 | new StringStream($headerString), |
|
50 | 22 | new StringStream("\r\n\r\n"), |
|
51 | 22 | $message->getBody() |
|
52 | ]) |
||
53 | ); |
||
54 | 22 | }); |
|
55 | 22 | } |
|
56 | |||
57 | /** |
||
58 | * @return string |
||
59 | */ |
||
60 | 21 | public function __toString(): string |
|
64 | |||
65 | /** |
||
66 | * |
||
67 | */ |
||
68 | public function close(): void |
||
72 | |||
73 | /** |
||
74 | * @return mixed |
||
75 | */ |
||
76 | public function detach() |
||
80 | |||
81 | /** |
||
82 | * @return int|null |
||
83 | */ |
||
84 | public function getSize(): ?int |
||
88 | |||
89 | /** |
||
90 | * @return int |
||
91 | * @throws \RuntimeException |
||
92 | */ |
||
93 | public function tell(): int |
||
97 | |||
98 | /** |
||
99 | * @return bool |
||
100 | */ |
||
101 | 1 | public function eof(): bool |
|
105 | |||
106 | /** |
||
107 | * @return bool |
||
108 | */ |
||
109 | public function isSeekable(): bool |
||
113 | |||
114 | /** |
||
115 | * @param int $offset |
||
116 | * @param int $whence |
||
117 | * @return int |
||
118 | */ |
||
119 | public function seek(int $offset, int $whence = SEEK_SET): int |
||
123 | |||
124 | /** |
||
125 | * @return bool |
||
126 | */ |
||
127 | public function rewind(): bool |
||
131 | |||
132 | /** |
||
133 | * @return bool |
||
134 | */ |
||
135 | public function isWritable(): bool |
||
139 | |||
140 | /** |
||
141 | * @param $string |
||
142 | * @return int |
||
143 | */ |
||
144 | public function write($string): int |
||
148 | |||
149 | /** |
||
150 | * @return bool |
||
151 | */ |
||
152 | public function isReadable(): bool |
||
156 | |||
157 | /** |
||
158 | * @param int $length |
||
159 | * @return string |
||
160 | */ |
||
161 | 1 | public function read(int $length): string |
|
165 | |||
166 | /** |
||
167 | * @return string |
||
168 | */ |
||
169 | public function getContents(): string |
||
173 | |||
174 | /** |
||
175 | * @param array $keys |
||
176 | * @return array |
||
177 | */ |
||
178 | public function getMetadata(array $keys = []): array |
||
182 | } |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: