| 1 | <?php |
||
| 9 | trait NavigationTrait { |
||
| 10 | /** |
||
| 11 | * Visits a given url |
||
| 12 | * @param string $url |
||
| 13 | */ |
||
| 14 | public function visit($url) { |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Gets the current url if any |
||
| 20 | * @return string |
||
| 21 | */ |
||
| 22 | public function getCurrentUrl() { |
||
| 25 | |||
| 26 | |||
| 27 | /** |
||
| 28 | * Reloads the page if possible |
||
| 29 | */ |
||
| 30 | public function reload() { |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Goes forward if possible |
||
| 36 | */ |
||
| 37 | public function forward() { |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Goes back if possible |
||
| 43 | */ |
||
| 44 | public function back() { |
||
| 47 | |||
| 48 | |||
| 49 | } |
||
| 50 |
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: