1 | <?php |
||
11 | trait ArrayAccessTrait |
||
12 | { |
||
13 | /** |
||
14 | * @param mixed $offset |
||
15 | * @return bool |
||
16 | */ |
||
17 | public function offsetExists($offset) |
||
21 | |||
22 | /** |
||
23 | * @param mixed $offset |
||
24 | * @return Route|null |
||
25 | */ |
||
26 | 1 | public function offsetGet($offset) |
|
30 | |||
31 | /** |
||
32 | * @param mixed $offset |
||
33 | * @param mixed $value |
||
34 | */ |
||
35 | public function offsetSet($offset, $value) |
||
39 | |||
40 | /** |
||
41 | * @param mixed $offset |
||
42 | */ |
||
43 | public function offsetUnset($offset) |
||
47 | } |
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
Idable
provides a methodequalsId
that 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.