1 | <?php |
||
8 | trait ManagesProjects |
||
9 | { |
||
10 | use TransformsProjects; |
||
11 | |||
12 | /** |
||
13 | * Get a list of of projects. |
||
14 | * |
||
15 | * @param int $accountId |
||
16 | * @return Project[] |
||
17 | */ |
||
18 | 7 | public function projects(int $accountId): array |
|
30 | |||
31 | /** |
||
32 | * Get a single project. |
||
33 | * |
||
34 | * @param int $accountId |
||
35 | * @param int $id |
||
36 | * |
||
37 | * @return Project |
||
38 | */ |
||
39 | 1 | public function project(int $accountId, int $id): Project |
|
45 | } |
||
46 |
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.