| 1 | <?php |
||
| 11 | trait CollectionsOperationsTrait |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @var Route[] |
||
| 15 | */ |
||
| 16 | protected $routes = []; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @inheritdoc |
||
| 20 | * @deprecated Use all() |
||
| 21 | */ |
||
| 22 | public function getRoutes() |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @param array $routes |
||
| 29 | */ |
||
| 30 | public function setRoutes($routes) |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @param $route |
||
| 37 | * @return bool |
||
| 38 | */ |
||
| 39 | public function has($route) |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @param $route |
||
| 48 | * @return Route|\Symfony\Component\Routing\Route|null |
||
| 49 | */ |
||
| 50 | 5 | public function get($route) |
|
| 55 | |||
| 56 | |||
| 57 | /** |
||
| 58 | * @param Route $route |
||
| 59 | * @param null $name |
||
| 60 | * @return |
||
| 61 | */ |
||
| 62 | 11 | public function addRoute($route, $name = null) |
|
| 71 | } |
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.