| 1 | <?php |
||
| 12 | trait TransformMethodsTrait |
||
| 13 | { |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @return array |
||
| 17 | */ |
||
| 18 | public function toArray() |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Specify data which should be serialized to JSON |
||
| 27 | * @link http://php.net/manual/en/jsonserializable.jsonserialize.php |
||
| 28 | * @return mixed data which can be serialized by <b>json_encode</b>, |
||
| 29 | * which is a value of any type other than a resource. |
||
| 30 | * @since 5.4.0 |
||
| 31 | */ |
||
| 32 | function jsonSerialize() |
||
| 42 | } |
||
| 43 |
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: