1 | <?php |
||
9 | trait HasRendererTrait |
||
10 | { |
||
11 | protected $_isRendered = false; |
||
12 | |||
13 | /** |
||
14 | * @param boolean $isRendered |
||
15 | * @return $this |
||
16 | */ |
||
17 | public function setRendered($isRendered) |
||
23 | |||
24 | /** |
||
25 | * @return bool |
||
26 | */ |
||
27 | public function isRendered() |
||
31 | |||
32 | /** |
||
33 | * @return bool |
||
34 | */ |
||
35 | public function hasCustomRenderer() |
||
39 | |||
40 | /** |
||
41 | * @return mixed |
||
42 | */ |
||
43 | public function render() |
||
47 | |||
48 | /** |
||
49 | * @return mixed |
||
50 | */ |
||
51 | public function getRenderer() |
||
55 | |||
56 | /** |
||
57 | * @return mixed |
||
58 | */ |
||
59 | public function renderElement() |
||
63 | |||
64 | /** |
||
65 | * @return mixed |
||
66 | */ |
||
67 | public function renderErrors() |
||
71 | } |
||
72 |
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.