| 1 | <?php |
||
| 21 | trait SessionAwareMethods |
||
| 22 | { |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @var SessionDriverInterface |
||
| 26 | */ |
||
| 27 | protected $sessionDriver; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Gets Session driver |
||
| 31 | * |
||
| 32 | * @return SessionDriverInterface |
||
| 33 | */ |
||
| 34 | 6 | public function getSessionDriver() |
|
| 41 | |||
| 42 | /** |
||
| 43 | * Sets session driver |
||
| 44 | * |
||
| 45 | * @param SessionDriverInterface $driver |
||
| 46 | * |
||
| 47 | * @return self|$this |
||
|
|
|||
| 48 | */ |
||
| 49 | 6 | public function setSessionDriver(SessionDriverInterface $driver) |
|
| 54 | } |
In PHP traits cannot be used for type-hinting as they do not define a well-defined structure. This is because any class that uses a trait can rename that trait’s methods.
If you would like to return an object that has a guaranteed set of methods, you could create a companion interface that lists these methods explicitly.