1 | <?php |
||
10 | trait SessionTrait { |
||
11 | |||
12 | /** @var bool */ |
||
13 | protected $started; |
||
14 | |||
15 | /** |
||
16 | * Starts a session to be used by the driver client |
||
17 | */ |
||
18 | public function start() { |
||
21 | |||
22 | /** |
||
23 | * Tells if the session is started or not |
||
24 | * @return bool |
||
25 | */ |
||
26 | public function isStarted() { |
||
29 | |||
30 | /** |
||
31 | * Stops the session completely, clean slate for the browser |
||
32 | * @return bool |
||
33 | */ |
||
34 | public function stop() { |
||
41 | |||
42 | /** |
||
43 | * Clears the cookies in the browser, all of them |
||
44 | * @return bool |
||
45 | */ |
||
46 | public function reset() { |
||
51 | } |
||
52 |
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.