| 1 | <?php |
||
| 9 | trait HasMorphNameManagerTrait |
||
| 10 | { |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @var null|string |
||
| 14 | */ |
||
| 15 | protected $morphName = null; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @return null|string |
||
| 19 | */ |
||
| 20 | 2 | public function getMorphName(): string |
|
| 27 | |||
| 28 | /** |
||
| 29 | * @param null|string $morphName |
||
| 30 | */ |
||
| 31 | 2 | public function setMorphName(string $morphName) |
|
| 35 | |||
| 36 | 2 | protected function initMorphName() |
|
| 41 | } |
||
| 42 |
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.