1 | <?php |
||
16 | trait HttpHeadersTrait |
||
17 | { |
||
18 | |||
19 | /** |
||
20 | * Headers |
||
21 | * |
||
22 | * @var array |
||
23 | */ |
||
24 | private $headers; |
||
25 | |||
26 | /** |
||
27 | * The response status code |
||
28 | * |
||
29 | * @var int |
||
30 | */ |
||
31 | private $responseCode; |
||
32 | |||
33 | /** |
||
34 | * |
||
35 | * {@inheritdoc} |
||
36 | * @see \Generics\Streams\HttpStream::setHeader() |
||
37 | * @return HttpClient |
||
38 | */ |
||
39 | 22 | public function setHeader($headerName, $headerValue) |
|
43 | |||
44 | /** |
||
45 | * Reset the headers |
||
46 | */ |
||
47 | 25 | public function resetHeaders() |
|
51 | |||
52 | /** |
||
53 | * |
||
54 | * {@inheritdoc} |
||
55 | * @see \Generics\Streams\HttpStream::getHeaders() |
||
56 | */ |
||
57 | 22 | public function getHeaders(): array |
|
61 | |||
62 | /** |
||
63 | * Retrieve the response status code |
||
64 | * |
||
65 | * @return int |
||
66 | */ |
||
67 | 16 | public function getResponseCode(): int |
|
71 | |||
72 | /** |
||
73 | * Adjust the headers by injecting default values for missing keys. |
||
74 | */ |
||
75 | 22 | private function adjustHeaders($requestType) |
|
103 | |||
104 | /** |
||
105 | * Depending on request type the connection header is either |
||
106 | * set to keep-alive or close |
||
107 | * |
||
108 | * @param string $requestType |
||
109 | */ |
||
110 | 18 | private function adjustConnectionHeader($requestType) |
|
118 | |||
119 | /** |
||
120 | * Try to parse line as header and add the results to local header list |
||
121 | * |
||
122 | * @param string $line |
||
123 | */ |
||
124 | 18 | private function addParsedHeader($line) |
|
134 | |||
135 | /** |
||
136 | * Adjust number of bytes to read according content length header |
||
137 | * |
||
138 | * @param int $numBytes |
||
139 | * @return int |
||
140 | */ |
||
141 | 18 | private function adjustNumbytes($numBytes): int |
|
150 | |||
151 | /** |
||
152 | * Retrieve content type from headers |
||
153 | * |
||
154 | * @return string |
||
155 | */ |
||
156 | 18 | private function getContentEncoding(): string |
|
160 | |||
161 | /** |
||
162 | * Retrieve an given header |
||
163 | * |
||
164 | * @param string $name |
||
165 | * @return string |
||
166 | */ |
||
167 | 18 | private function getHeader(string $name): string |
|
177 | } |
||
178 |
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.