| 1 | <?php |
||
| 11 | trait RouterAwareTrait |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @var Router|null |
||
| 15 | */ |
||
| 16 | protected $router = null; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @param bool|Request $request |
||
| 20 | * @return array |
||
| 21 | */ |
||
| 22 | public function route($request = false) |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @return Router |
||
| 32 | */ |
||
| 33 | public function getRouter() |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @param bool|Router $router |
||
| 44 | * @return $this |
||
| 45 | */ |
||
| 46 | public function setRouter($router = false) |
||
| 52 | |||
| 53 | protected function initRouter() |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @return Router |
||
| 60 | */ |
||
| 61 | protected function newRouter() |
||
| 65 | } |
||
| 66 |
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.