| 1 | <?php |
||
| 9 | trait Enumerable |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * The "booting" method of the trait. |
||
| 13 | */ |
||
| 14 | public static function bootEnumerable() |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Set an enumerable attribute value. |
||
| 24 | * |
||
| 25 | * @param string $key |
||
| 26 | * @param $value |
||
| 27 | * @param string $class |
||
| 28 | * |
||
| 29 | * @throws EnumException |
||
| 30 | * @throws InvalidEnumValueException |
||
| 31 | * |
||
| 32 | * @return $this |
||
| 33 | */ |
||
| 34 | public function setAttributeEnum(string $key, $value, string $class) |
||
| 51 | } |
||
| 52 |
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: