1 | <?php |
||
15 | trait Sessions |
||
16 | { |
||
17 | /** |
||
18 | * @var string Session ID |
||
19 | */ |
||
20 | protected $sessionId; |
||
21 | |||
22 | /** |
||
23 | * @var integer |
||
24 | */ |
||
25 | protected $sessionStartTimeout = 10; |
||
26 | |||
27 | /** |
||
28 | * @var boolean |
||
29 | */ |
||
30 | protected $sessionStarted = false; |
||
31 | |||
32 | /** |
||
33 | * @var boolean |
||
34 | */ |
||
35 | protected $sessionFlushing = false; |
||
36 | |||
37 | /** |
||
38 | * @var resource |
||
39 | */ |
||
40 | protected $sessionFp; |
||
41 | |||
42 | /** |
||
43 | * @var string |
||
44 | */ |
||
45 | protected $sessionPrefix = 'sess_'; |
||
46 | |||
47 | /** |
||
48 | * Is session started? |
||
49 | * @return boolean |
||
50 | */ |
||
51 | public function sessionStarted() |
||
55 | |||
56 | /** |
||
57 | * Deferred event 'onSessionStart' |
||
58 | * @return callable |
||
59 | */ |
||
60 | public function onSessionStartEvent() |
||
83 | |||
84 | /** |
||
85 | * Deferred event 'onSessionRead' |
||
86 | * @return callable |
||
87 | */ |
||
88 | public function onSessionReadEvent() |
||
108 | |||
109 | /** |
||
110 | * Reads session data |
||
111 | * @param string $sid Session ID |
||
112 | * @param callable $cb Callback |
||
113 | * @return void |
||
114 | */ |
||
115 | public function sessionRead($sid, $cb = null) |
||
128 | |||
129 | /** |
||
130 | * Commmit session data |
||
131 | * @param callable $cb Callback |
||
132 | * @return void |
||
133 | */ |
||
134 | public function sessionCommit($cb = null) |
||
155 | |||
156 | /** |
||
157 | * Session start |
||
158 | * @param boolean $force_start |
||
159 | * @return void |
||
160 | */ |
||
161 | protected function sessionStart($force_start = true) |
||
180 | |||
181 | /** |
||
182 | * Start new session |
||
183 | * @param callable $cb Callback |
||
184 | * @return void |
||
185 | */ |
||
186 | protected function sessionStartNew($cb = null) |
||
209 | |||
210 | /** |
||
211 | * Encodes session data |
||
212 | * @return string|false |
||
213 | */ |
||
214 | protected function sessionEncode() |
||
225 | |||
226 | /** |
||
227 | * Set session state |
||
228 | * @param mixed $var |
||
229 | * @return void |
||
230 | */ |
||
231 | protected function setSessionState($var) |
||
235 | |||
236 | /** |
||
237 | * Get session state |
||
238 | * @return mixed |
||
239 | */ |
||
240 | protected function getSessionState() |
||
244 | |||
245 | /** |
||
246 | * Decodes session data |
||
247 | * @param string $str Data |
||
248 | * @return boolean |
||
249 | */ |
||
250 | protected function sessionDecode($str) |
||
263 | |||
264 | /** |
||
265 | * session_encode() - clone, which not require session_start() |
||
266 | * @see http://www.php.net/manual/en/function.session-encode.php |
||
267 | * @param array $array |
||
268 | * @return string |
||
269 | */ |
||
270 | public function serializePHP($array) |
||
290 | |||
291 | /** |
||
292 | * session_decode() - clone, which not require session_start() |
||
293 | * @see http://www.php.net/manual/en/function.session-decode.php#108037 |
||
294 | * @param string $session_data |
||
295 | * @return array |
||
296 | */ |
||
297 | protected function unserializePHP($session_data) |
||
318 | } |
||
319 |
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.