1 | <?php |
||
10 | trait HasHtmlAttributes |
||
11 | { |
||
12 | /** |
||
13 | * @param string $attribute |
||
14 | * @param string $value |
||
15 | * |
||
16 | * @return $this |
||
17 | */ |
||
18 | public function setAttribute(string $attribute, string $value = '') |
||
24 | |||
25 | /** |
||
26 | * @param array $attributes |
||
27 | * |
||
28 | * @return $this |
||
29 | */ |
||
30 | public function setAttributes(array $attributes) |
||
36 | |||
37 | /** |
||
38 | * @param string $class |
||
39 | * |
||
40 | * @return $this |
||
41 | */ |
||
42 | public function addClass(string $class) |
||
48 | } |
||
49 |
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: