1 | <?php |
||
14 | class HttpHeadersBag implements \ArrayAccess, \Iterator |
||
15 | { |
||
16 | /** |
||
17 | * @var string[] |
||
18 | */ |
||
19 | private $headers; |
||
20 | |||
21 | /** |
||
22 | * Is used by the iterator feature to store a possible "false" value when the loop over the array is finished. |
||
23 | * |
||
24 | * @var mixed |
||
25 | */ |
||
26 | private $next; |
||
27 | |||
28 | public function __construct(array $headers = null) |
||
32 | |||
33 | /** |
||
34 | * @param string $name |
||
35 | * @param mixed $value |
||
36 | * @return self |
||
37 | */ |
||
38 | public function set(string $name, $value) |
||
44 | |||
45 | /** |
||
46 | * @param string $name |
||
47 | * @param mixed $default |
||
48 | * @return mixed |
||
49 | */ |
||
50 | public function get(string $name, $default = null) |
||
57 | |||
58 | /** |
||
59 | * @param string $name |
||
60 | * @param mixed $value |
||
61 | * @return self |
||
62 | */ |
||
63 | public function add(string $name, $value) |
||
76 | |||
77 | /** |
||
78 | * @param string $name |
||
79 | */ |
||
80 | public function remove(string $name) |
||
84 | |||
85 | /** |
||
86 | * {@inheritdoc} |
||
87 | */ |
||
88 | public function offsetExists($offset) |
||
92 | |||
93 | /** |
||
94 | * {@inheritdoc} |
||
95 | */ |
||
96 | public function offsetGet($offset) |
||
100 | |||
101 | /** |
||
102 | * {@inheritdoc} |
||
103 | */ |
||
104 | public function offsetSet($offset, $value) |
||
108 | |||
109 | /** |
||
110 | * {@inheritdoc} |
||
111 | */ |
||
112 | public function offsetUnset($offset) |
||
116 | |||
117 | public function current() |
||
121 | |||
122 | public function next() |
||
126 | |||
127 | public function key() |
||
131 | |||
132 | public function valid() |
||
136 | |||
137 | public function rewind() |
||
141 | } |
||
142 |
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: