1 | <?php |
||
17 | trait SortableTrait |
||
18 | { |
||
19 | /** |
||
20 | * @var SortableBehavior |
||
21 | */ |
||
22 | private $_sortableBehavior; |
||
23 | |||
24 | |||
25 | /** |
||
26 | * @throws InvalidConfigException |
||
27 | */ |
||
28 | private function getSortableBehavior() |
||
43 | |||
44 | /** |
||
45 | * @return integer |
||
46 | */ |
||
47 | public function getSortablePosition() |
||
51 | |||
52 | /** |
||
53 | * @return $this |
||
54 | */ |
||
55 | public function moveFirst() |
||
59 | |||
60 | /** |
||
61 | * @return $this |
||
62 | */ |
||
63 | public function moveLast() |
||
67 | |||
68 | /** |
||
69 | * @param integer $position |
||
70 | * @param bool $forward Move existing items to forward or backward |
||
71 | * @return $this |
||
72 | */ |
||
73 | public function moveTo($position, $forward = true) |
||
77 | |||
78 | /** |
||
79 | * @param ActiveRecord $model |
||
80 | * @return $this |
||
81 | */ |
||
82 | public function moveBefore($model) |
||
86 | |||
87 | /** |
||
88 | * @param ActiveRecord $model |
||
89 | * @return $this |
||
90 | */ |
||
91 | public function moveAfter($model) |
||
95 | |||
96 | /** |
||
97 | * Reorders items with values of sortAttribute begin from zero. |
||
98 | * @param bool $middle |
||
99 | * @return integer |
||
100 | * @throws \Exception |
||
101 | */ |
||
102 | public function reorder($middle = true) |
||
106 | } |
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.