| 1 | <?php |
||
| 20 | trait Hydrogen |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * @var ProcessorInterface |
||
| 24 | */ |
||
| 25 | private $processor; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @return ProcessorInterface |
||
| 29 | */ |
||
| 30 | public function getProcessor(): ProcessorInterface |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @return Query|$this |
||
| 41 | * @throws \LogicException |
||
| 42 | */ |
||
| 43 | public function query(): Query |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @param string $name |
||
| 55 | * @return null|Query |
||
| 56 | * @throws \LogicException |
||
| 57 | */ |
||
| 58 | public function __get(string $name) |
||
| 67 | } |
||
| 68 |
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.