Conditions | 2 |
Paths | 1 |
Total Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
9 | public function handlesEvents(): array |
||
10 | { |
||
11 | return collect($this->handlesEvents ?? []) |
||
|
|||
12 | ->mapWithKeys(function ($methodName, $eventClass) { |
||
13 | if (is_numeric($eventClass)) { |
||
14 | $eventClass = $methodName; |
||
15 | $methodName = 'on' . ucfirst(class_basename($eventClass)); |
||
16 | } |
||
17 | |||
18 | return [$eventClass => $methodName]; |
||
19 | }) |
||
20 | ->toArray(); |
||
21 | } |
||
22 | |||
42 |
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: