| 1 | <?php |
||
| 13 | class SelectableItem implements MenuItemInterface |
||
| 14 | { |
||
| 15 | use SelectableTrait; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @var callable |
||
| 19 | */ |
||
| 20 | private $selectAction; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @param string $text |
||
| 24 | * @param callable $selectAction |
||
| 25 | * @param bool $showItemExtra |
||
| 26 | * @param bool $disabled |
||
| 27 | */ |
||
| 28 | public function __construct($text, callable $selectAction, $data = [], $showItemExtra = false, $disabled = false) |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Execute the items callable if required |
||
| 41 | * |
||
| 42 | * @return callable|void |
||
| 43 | */ |
||
| 44 | public function getSelectAction() |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Return the raw string of text |
||
| 51 | * |
||
| 52 | * @return string |
||
| 53 | */ |
||
| 54 | public function getText() |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Return the raw data |
||
| 61 | * |
||
| 62 | * @return array |
||
| 63 | */ |
||
| 64 | public function getData() |
||
| 68 | } |
||
| 69 |
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: