1 | <?php |
||
20 | trait JsonTrait |
||
21 | { |
||
22 | /** |
||
23 | * @return Request |
||
24 | */ |
||
25 | public function expectsJson() |
||
29 | |||
30 | /** |
||
31 | * @return Request |
||
32 | */ |
||
33 | public function sendJson() |
||
37 | |||
38 | /** |
||
39 | * @param $body |
||
40 | * @return string |
||
41 | */ |
||
42 | public function json($body) |
||
46 | |||
47 | /** |
||
48 | * @param $body |
||
49 | * @return mixed |
||
50 | */ |
||
51 | public function unJson($body) |
||
57 | |||
58 | /** |
||
59 | * @return string |
||
60 | */ |
||
61 | private static function jsonLastErrorMsg(){ |
||
87 | } |
||
88 | |||
89 |
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.