1 | <?php |
||
8 | trait DateFormat |
||
9 | { |
||
10 | /** |
||
11 | * @return string |
||
12 | */ |
||
13 | public function getFormat() |
||
17 | |||
18 | /** |
||
19 | * @return string |
||
20 | */ |
||
21 | public function getTimezone() |
||
29 | |||
30 | /** |
||
31 | * @param string|null $format |
||
32 | * |
||
33 | * @return $this |
||
34 | */ |
||
35 | public function setFormat($format) |
||
41 | |||
42 | /** |
||
43 | * @param string $timezone |
||
44 | * |
||
45 | * @return $this |
||
46 | */ |
||
47 | public function setTimezone($timezone) |
||
53 | } |
||
54 |
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: