1 | <?php |
||
4 | trait SortTrait |
||
5 | { |
||
6 | /** |
||
7 | * @return \Spindle\Collection\Collection (new instance) |
||
8 | */ |
||
9 | 1 | public function usort(callable $cmp) |
|
15 | |||
16 | /** |
||
17 | * @param int $sort_flags \SORT_REGULAR|\SORT_NUMERIC|\SORT_STRING |
||
18 | * @return \Spindle\Collection\Collection (new instance) |
||
19 | */ |
||
20 | 1 | public function rsort($sort_flags = \SORT_REGULAR) |
|
26 | |||
27 | /** |
||
28 | * @param int $sort_flags \SORT_REGULAR|\SORT_NUMERIC|\SORT_STRING |
||
29 | * @return \Spindle\Collection\Collection (new instance) |
||
30 | */ |
||
31 | 1 | public function sort($sort_flags = \SORT_REGULAR) |
|
37 | |||
38 | /** |
||
39 | * stable sort |
||
40 | * @return \Spindle\Collection\Collection (new instance) |
||
41 | */ |
||
42 | 1 | public function usortStable(callable $cmp) |
|
52 | |||
53 | /** |
||
54 | * sort with Schwartzian Transform |
||
55 | * @param string|callable $fn map function |
||
56 | * @param SORT_ASC|SORT_DESC $sort_order |
||
57 | * @param SORT_REGULAR|SORT_NUMERIC|SORT_STRING $sort_flags |
||
58 | * @return \Spindle\Collection (new instance) |
||
59 | */ |
||
60 | 1 | public function mapSort($fn, $sort_order = \SORT_ASC, $sort_flags = \SORT_REGULAR) |
|
67 | } |
||
68 |
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.