| 1 | <?php namespace Peek\Api; |
||
| 7 | trait Jsonable |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @return array |
||
| 11 | */ |
||
| 12 | public function jsonSerialize() |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @return array |
||
| 19 | */ |
||
| 20 | public function toArray() |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @return string |
||
| 27 | */ |
||
| 28 | public function __toString() |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @return string |
||
| 35 | */ |
||
| 36 | public function toJson() |
||
| 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: