1 | <?php namespace Comodojo\Dispatcher\Components; |
||
26 | trait DataSerialization { |
||
27 | |||
28 | /** |
||
29 | * Return the serialized data |
||
30 | * |
||
31 | * @return string $serialized |
||
32 | */ |
||
33 | public function serialize() { |
||
38 | |||
39 | /** |
||
40 | * Return the unserialized object |
||
41 | * |
||
42 | * @param string $data Serialized data |
||
43 | * |
||
44 | * @return Routes $this |
||
45 | */ |
||
46 | public function unserialize($data) { |
||
53 | |||
54 | } |
||
55 |
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: