1 | <?php |
||
15 | trait FieldWithRelation |
||
16 | { |
||
17 | /** |
||
18 | * @var string $relation |
||
19 | */ |
||
20 | protected $relation; |
||
21 | |||
22 | /** |
||
23 | * @var array |
||
24 | */ |
||
25 | protected $options; |
||
26 | |||
27 | /** |
||
28 | * @param string $relation |
||
29 | * @return self |
||
30 | */ |
||
31 | public function withRelation($relation) |
||
37 | |||
38 | /** |
||
39 | * @param void |
||
40 | * @return Relation |
||
41 | */ |
||
42 | public function getRelation() |
||
53 | |||
54 | /** |
||
55 | * {@inheritdoc} |
||
56 | */ |
||
57 | public function getOptions() |
||
69 | |||
70 | /** |
||
71 | * @param Validator $validator |
||
72 | * @return Validator |
||
73 | */ |
||
74 | public function beforeValidation(Validator $validator) |
||
87 | |||
88 | /** |
||
89 | * {@inheritdoc} |
||
90 | */ |
||
91 | public function getTableValue() |
||
96 | |||
97 | /** |
||
98 | * {@inheritdoc} |
||
99 | */ |
||
100 | public function getViewVariables() |
||
106 | } |
||
107 |
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.