1 | <?php |
||
6 | trait HttpHeadersTrait |
||
7 | { |
||
8 | |||
9 | /** |
||
10 | * Headers |
||
11 | * |
||
12 | * @var array |
||
13 | */ |
||
14 | private $headers; |
||
15 | |||
16 | /** |
||
17 | * The response status code |
||
18 | * |
||
19 | * @var int |
||
20 | */ |
||
21 | private $responseCode; |
||
22 | |||
23 | /** |
||
24 | * |
||
25 | * {@inheritdoc} |
||
26 | * @see \Generics\Streams\HttpStream::setHeader() |
||
27 | * @return HttpClient |
||
28 | */ |
||
29 | 22 | public function setHeader($headerName, $headerValue) |
|
33 | |||
34 | /** |
||
35 | * Reset the headers |
||
36 | */ |
||
37 | 23 | public function resetHeaders() |
|
41 | |||
42 | /** |
||
43 | * |
||
44 | * {@inheritdoc} |
||
45 | * @see \Generics\Streams\HttpStream::getHeaders() |
||
46 | */ |
||
47 | 22 | public function getHeaders(): array |
|
51 | |||
52 | /** |
||
53 | * Retrieve the response status code |
||
54 | * |
||
55 | * @return int |
||
56 | */ |
||
57 | 16 | public function getResponseCode(): int |
|
61 | |||
62 | /** |
||
63 | * Adjust the headers by injecting default values for missing keys. |
||
64 | */ |
||
65 | 22 | private function adjustHeaders($requestType) |
|
93 | |||
94 | /** |
||
95 | * Depending on request type the connection header is either |
||
96 | * set to keep-alive or close |
||
97 | * |
||
98 | * @param string $requestType |
||
99 | */ |
||
100 | 18 | private function adjustConnectionHeader($requestType) |
|
108 | |||
109 | /** |
||
110 | * Try to parse line as header and add the results to local header list |
||
111 | * |
||
112 | * @param string $line |
||
113 | */ |
||
114 | 18 | private function addParsedHeader($line) |
|
124 | |||
125 | /** |
||
126 | * Adjust number of bytes to read according content length header |
||
127 | * |
||
128 | * @param int $numBytes |
||
129 | * @return int |
||
130 | */ |
||
131 | 18 | private function adjustNumbytes($numBytes): int |
|
140 | |||
141 | /** |
||
142 | * Retrieve content type from headers |
||
143 | * |
||
144 | * @return string |
||
145 | */ |
||
146 | 18 | private function getContentEncoding(): string |
|
150 | |||
151 | /** |
||
152 | * Retrieve an given header |
||
153 | * |
||
154 | * @param string $name |
||
155 | * @return string |
||
156 | */ |
||
157 | 18 | private function getHeader(string $name): string |
|
167 | } |
||
168 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.