1 | <?php |
||
28 | trait TForm |
||
29 | { |
||
30 | /** |
||
31 | * @var mixed |
||
32 | */ |
||
33 | protected $id; |
||
34 | |||
35 | /** |
||
36 | * @var string|NULL |
||
37 | */ |
||
38 | protected $errorClass = NULL; |
||
39 | |||
40 | /** |
||
41 | * @param array $defaults |
||
42 | * |
||
43 | * @return void |
||
44 | */ |
||
45 | public function restore(array $defaults = []) : void |
||
50 | |||
51 | /** |
||
52 | * @return mixed |
||
53 | */ |
||
54 | public function getId() |
||
58 | |||
59 | /** |
||
60 | * @param mixed $id |
||
61 | * |
||
62 | * @return void |
||
63 | */ |
||
64 | public function setId($id) : void |
||
68 | |||
69 | /** |
||
70 | * @param string $errorClass |
||
71 | * |
||
72 | * @return void |
||
73 | */ |
||
74 | public function setErrorClass(string $errorClass) : void |
||
78 | |||
79 | /** |
||
80 | * @return void |
||
81 | */ |
||
82 | protected function beforeRender() : void |
||
108 | |||
109 | /** |
||
110 | * @param string $name |
||
111 | * @param string $class |
||
112 | * |
||
113 | * @return void |
||
114 | */ |
||
115 | protected function addExtension(string $name, string $class) : void |
||
121 | } |
||
122 |
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.