1 | <?php |
||
22 | trait DataSourceCollectionTrait |
||
23 | { |
||
24 | /** |
||
25 | * @var DataSourceInterface |
||
26 | */ |
||
27 | protected $dataSource; |
||
28 | |||
29 | /** |
||
30 | * @param DataSourceInterface $dataSource |
||
31 | */ |
||
32 | public function __construct(DataSourceInterface $dataSource) |
||
36 | |||
37 | /** |
||
38 | * {@inheritdoc} |
||
39 | */ |
||
40 | public function count() |
||
48 | |||
49 | /** |
||
50 | * {@inheritdoc} |
||
51 | */ |
||
52 | public function getIterator() |
||
60 | |||
61 | /** |
||
62 | * {@inheritdoc} |
||
63 | */ |
||
64 | public function slice($offset, $length = null) |
||
72 | |||
73 | /** |
||
74 | * {@inheritdoc} |
||
75 | */ |
||
76 | public function find(SpecificationInterface $criteria) |
||
84 | } |
||
85 |
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.