| 1 | <?php |
||
| 5 | trait SerializableContainerTrait |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * Gets container. |
||
| 9 | * |
||
| 10 | * @return array |
||
| 11 | */ |
||
| 12 | 9 | public function getContainer() |
|
| 16 | |||
| 17 | /** |
||
| 18 | * Returns the string representation of the object. |
||
| 19 | * |
||
| 20 | * @return string |
||
| 21 | */ |
||
| 22 | 6 | public function serialize() |
|
| 26 | |||
| 27 | /** |
||
| 28 | * Constructs object from serialized string. |
||
| 29 | * |
||
| 30 | * @param string $serialized |
||
| 31 | * |
||
| 32 | * @return void |
||
| 33 | */ |
||
| 34 | 3 | public function unserialize($serialized) |
|
| 38 | |||
| 39 | /** |
||
| 40 | * Serializes the object to a value that can be serialized by json_encode(). |
||
| 41 | * |
||
| 42 | * @return array |
||
| 43 | */ |
||
| 44 | 3 | public function jsonSerialize() |
|
| 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: