1 | <?php |
||
9 | trait AccessMethodsTrait |
||
10 | { |
||
11 | |||
12 | |||
13 | /** |
||
14 | * @param array $items |
||
15 | */ |
||
16 | public function setItems($items) |
||
20 | |||
21 | /** |
||
22 | * {@inheritDoc} |
||
23 | */ |
||
24 | 2 | public function add($element, $key = null) |
|
32 | |||
33 | /** |
||
34 | * @param string $id |
||
35 | * @param mixed $value |
||
36 | */ |
||
37 | 3 | public function set($id, $value) |
|
41 | |||
42 | |||
43 | /** |
||
44 | * Returns a parameter by name. |
||
45 | * |
||
46 | * @param string $key The key |
||
47 | * @param mixed $default The default value if the parameter key does not exist |
||
48 | * |
||
49 | * @return mixed |
||
50 | */ |
||
51 | 1 | public function get($key, $default = null) |
|
55 | |||
56 | /** |
||
57 | * @return boolean |
||
58 | * @param string $key |
||
59 | */ |
||
60 | public function has($key) |
||
64 | |||
65 | /** |
||
66 | * @param $key |
||
67 | * @return bool |
||
68 | * @deprecated Use ->has($key) instead |
||
69 | */ |
||
70 | public function exists($key) |
||
74 | |||
75 | |||
76 | /** |
||
77 | * Returns the parameters. |
||
78 | * |
||
79 | * @return array An array of parameters |
||
80 | */ |
||
81 | 1 | public function all() |
|
85 | |||
86 | /** |
||
87 | * Returns the parameter keys. |
||
88 | * |
||
89 | * @return array An array of parameter keys |
||
90 | */ |
||
91 | public function keys() |
||
95 | |||
96 | /** |
||
97 | * Returns the parameter values. |
||
98 | * |
||
99 | * @return array An array of parameter values |
||
100 | */ |
||
101 | public function values() |
||
105 | |||
106 | |||
107 | /** |
||
108 | * @param string $key |
||
109 | * @return null |
||
110 | */ |
||
111 | 1 | public function unset($key) |
|
120 | } |
||
121 |
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: