1 | <?php |
||
13 | class Emitter |
||
14 | { |
||
15 | /** |
||
16 | * Checks to see if content has previously been sent. |
||
17 | * |
||
18 | * If either headers have been sent or the output buffer contains content, |
||
19 | * raises an exception. |
||
20 | * |
||
21 | * @throws RuntimeException if headers have already been sent. |
||
22 | * @throws RuntimeException if output is present in the output buffer. |
||
23 | */ |
||
24 | private function assertNoPreviousOutput() |
||
34 | |||
35 | /** |
||
36 | * Emit the status line. |
||
37 | * |
||
38 | * Emits the status line using the protocol version and status code from |
||
39 | * the response; if a reason phrase is available, it, too, is emitted. |
||
40 | * |
||
41 | * It is important to mention that this method should be called after |
||
42 | * `emitHeaders()` in order to prevent PHP from changing the status code of |
||
43 | * the emitted response. |
||
44 | * |
||
45 | * @param Response $response |
||
46 | * |
||
47 | * @see \Zend\Diactoros\Response\SapiEmitterTrait::emitHeaders() |
||
48 | */ |
||
49 | private function emitStatusLine(Response $response) |
||
61 | |||
62 | /** |
||
63 | * Emit response headers. |
||
64 | * |
||
65 | * Loops through each header, emitting each; if the header value |
||
66 | * is an array with multiple values, ensures that each is sent |
||
67 | * in such a way as to create aggregate headers (instead of replace |
||
68 | * the previous). |
||
69 | * |
||
70 | * @param Response $response |
||
71 | */ |
||
72 | private function emitHeaders(Response $response) |
||
89 | |||
90 | /** |
||
91 | * Filter a header name to wordcase |
||
92 | * |
||
93 | * @param string $header |
||
94 | * @return string |
||
95 | */ |
||
96 | private function filterHeader($header) |
||
102 | |||
103 | /** |
||
104 | * Emits a response for a PHP SAPI environment. |
||
105 | * |
||
106 | * Emits the status line and headers via the header() function, and the |
||
107 | * body content via the output buffer. |
||
108 | * |
||
109 | * @param Response $response |
||
110 | */ |
||
111 | public function emit(Response $response, $maxBufferLength = 8192) |
||
141 | |||
142 | /** |
||
143 | * Parse content-range header |
||
144 | * http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.16 |
||
145 | * |
||
146 | * @param string $header |
||
147 | * @return false|array [unit, first, last, length]; returns false if no |
||
148 | * content range or an invalid content range is provided |
||
149 | */ |
||
150 | private function parseContentRange($header) |
||
162 | /** |
||
163 | * Emit a range of the message body. |
||
164 | * |
||
165 | * @param array $range |
||
166 | * @param ResponseInterface $response |
||
167 | * @param int $maxBufferLength |
||
168 | */ |
||
169 | private function emitBodyRange(array $range, Response $response, $maxBufferLength) |
||
201 | } |
||
202 |
This checks looks for assignemnts to variables using the
list(...)
function, where not all assigned variables are subsequently used.Consider the following code example.
Only the variables
$a
and$c
are used. There was no need to assign$b
.Instead, the list call could have been.