| 1 | <?php |
||
| 10 | trait HasParentAttributes |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * Return an array of attributes to apply on the parent. This generally means |
||
| 14 | * the attributes that should be applied on the <li> tag. |
||
| 15 | * |
||
| 16 | * @return array |
||
| 17 | */ |
||
| 18 | public function parentAttributes(): array |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @param string $attribute |
||
| 25 | * @param string $value |
||
| 26 | * |
||
| 27 | * @return $this |
||
| 28 | */ |
||
| 29 | public function setParentAttribute(string $attribute, string $value = '') |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @param array $attributes |
||
| 38 | * |
||
| 39 | * @return $this |
||
| 40 | */ |
||
| 41 | public function setParentAttributes(array $attributes) |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @param string $class |
||
| 50 | * |
||
| 51 | * @return $this |
||
| 52 | */ |
||
| 53 | public function addParentClass(string $class) |
||
| 59 | } |
||
| 60 |
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: