| 1 | <?php |
||
| 23 | trait TForm |
||
| 24 | { |
||
| 25 | /** |
||
| 26 | * @var mixed |
||
| 27 | */ |
||
| 28 | protected $id; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @param string $name |
||
| 32 | * @param string $class |
||
| 33 | */ |
||
| 34 | protected function addExtension(string $name, string $class) |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @param array $defaults |
||
| 43 | */ |
||
| 44 | public function restore(array $defaults = []) |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @return mixed |
||
| 52 | */ |
||
| 53 | public function getId() |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @param mixed $id |
||
| 60 | */ |
||
| 61 | public function setId($id) |
||
| 65 | } |
||
| 66 |
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
Idableprovides a methodequalsIdthat 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.