| 1 | <?php |
||
| 8 | trait DevTools |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * Execute devtools command. |
||
| 12 | * @return int -1 if error occurred |
||
| 13 | */ |
||
| 14 | protected function devtools() |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Install Laravel ide helper package. |
||
| 26 | * @return int -1 if error occurred |
||
| 27 | */ |
||
| 28 | protected function idehelper() |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Install Laravel debugbar package. |
||
| 35 | * @return int -1 if error occurred |
||
| 36 | */ |
||
| 37 | protected function debugbar() |
||
| 41 | } |
||
| 42 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idableprovides a methodequalsIdthat in turn relies on the methodgetId(). If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()as an abstract method to the trait will make sure it is available.