1 | <?php |
||
9 | trait HeadersTrait { |
||
10 | |||
11 | /** |
||
12 | * Gets the current request response headers |
||
13 | * Should be called only after a request, other calls are undefined behaviour |
||
14 | * @return array |
||
15 | */ |
||
16 | public function getResponseHeaders() { |
||
19 | |||
20 | /** |
||
21 | * Current request status code response |
||
22 | * @return int |
||
23 | */ |
||
24 | public function getStatusCode() { |
||
27 | |||
28 | /** |
||
29 | * The name say its all |
||
30 | * @param string $name |
||
31 | * @param string $value |
||
32 | */ |
||
33 | public function setRequestHeader($name, $value) { |
||
39 | |||
40 | } |
||
41 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: