Skip to content

Commit 1ed6d46

Browse files
committed
Session typos changes
1 parent 190669d commit 1ed6d46

4 files changed

Lines changed: 45 additions & 36 deletions

File tree

system/Session/Handlers/BaseHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ abstract class BaseHandler implements \SessionHandlerInterface
116116
* The 'save path' for the session
117117
* varies between
118118
*
119-
* @var mixed
119+
* @var string
120120
*/
121121
protected $savePath;
122122

system/Session/Handlers/RedisHandler.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public function __construct(BaseConfig $config, string $ipAddress)
137137
* @param string $name Session cookie name, unused
138138
* @return boolean
139139
*/
140-
public function open($save_path, $name)
140+
public function open($save_path, $name): bool
141141
{
142142
if (empty($this->savePath))
143143
{
@@ -176,7 +176,7 @@ public function open($save_path, $name)
176176
*
177177
* @param string $sessionID Session ID
178178
*
179-
* @return string Serialized session data
179+
* @return string|false Serialized session data
180180
*/
181181
public function read($sessionID)
182182
{
@@ -185,10 +185,11 @@ public function read($sessionID)
185185
// Needed by write() to detect session_regenerate_id() calls
186186
$this->sessionID = $sessionID;
187187

188-
$session_data = $this->redis->get($this->keyPrefix . $sessionID);
188+
$session_data = $this->redis->get($this->keyPrefix . $sessionID);
189189
is_string($session_data) ? $this->keyExists = true : $session_data = '';
190190

191191
$this->fingerprint = md5($session_data);
192+
192193
return $session_data;
193194
}
194195

@@ -207,7 +208,7 @@ public function read($sessionID)
207208
*
208209
* @return boolean
209210
*/
210-
public function write($sessionID, $sessionData)
211+
public function write($sessionID, $sessionData): bool
211212
{
212213
if (! isset($this->redis))
213214
{
@@ -256,7 +257,7 @@ public function write($sessionID, $sessionData)
256257
*
257258
* @return boolean
258259
*/
259-
public function close()
260+
public function close(): bool
260261
{
261262
if (isset($this->redis))
262263
{
@@ -296,7 +297,7 @@ public function close()
296297
*
297298
* @return boolean
298299
*/
299-
public function destroy($sessionID)
300+
public function destroy($sessionID): bool
300301
{
301302
if (isset($this->redis, $this->lockKey))
302303
{
@@ -321,7 +322,7 @@ public function destroy($sessionID)
321322
* @param integer $maxlifetime Maximum lifetime of sessions
322323
* @return boolean
323324
*/
324-
public function gc($maxlifetime)
325+
public function gc($maxlifetime): bool
325326
{
326327
// Not necessary, Redis takes care of that.
327328
return true;

system/Session/Session.php

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,16 @@ class Session implements SessionInterface
143143
* @var boolean
144144
*/
145145
protected $cookieSecure = false;
146+
147+
/**
148+
* sid regex expression
149+
*
150+
* @var string
151+
*/
146152
protected $sidRegexp;
147153

148154
/**
149-
* Logger instance to record error messages and awarnings.
155+
* Logger instance to record error messages and warnings.
150156
*
151157
* @var \PSR\Log\LoggerInterface
152158
*/
@@ -185,6 +191,8 @@ public function __construct(\SessionHandlerInterface $driver, $config)
185191

186192
/**
187193
* Initialize the session container and starts up the session.
194+
*
195+
* @return mixed
188196
*/
189197
public function start()
190198
{
@@ -527,7 +535,7 @@ public function get(string $key = null)
527535
*
528536
* @return boolean
529537
*/
530-
public function has(string $key)
538+
public function has(string $key): bool
531539
{
532540
return isset($_SESSION[$key]);
533541
}
@@ -582,10 +590,10 @@ public function remove($key)
582590
* Magic method to set variables in the session by simply calling
583591
* $session->foo = bar;
584592
*
585-
* @param string $key Identifier of the session property to set.
586-
* @param $value
593+
* @param string $key Identifier of the session property to set.
594+
* @param string|array $value
587595
*/
588-
public function __set($key, $value)
596+
public function __set(string $key, $value)
589597
{
590598
$_SESSION[$key] = $value;
591599
}
@@ -600,7 +608,7 @@ public function __set($key, $value)
600608
*
601609
* @return null|string
602610
*/
603-
public function __get($key)
611+
public function __get(string $key)
604612
{
605613
// Note: Keep this order the same, just in case somebody wants to
606614
// use 'session_id' as a session data key, for whatever reason
@@ -675,9 +683,9 @@ public function getFlashdata(string $key = null)
675683
/**
676684
* Keeps a single piece of flash data alive for one more request.
677685
*
678-
* @param string $key Property identifier or array of them
686+
* @param array|string $key Property identifier or array of them
679687
*/
680-
public function keepFlashdata(string $key)
688+
public function keepFlashdata($key)
681689
{
682690
$this->markAsFlashdata($key);
683691
}
@@ -691,7 +699,7 @@ public function keepFlashdata(string $key)
691699
*
692700
* @return boolean False if any of the properties are not already set
693701
*/
694-
public function markAsFlashdata($key)
702+
public function markAsFlashdata($key): bool
695703
{
696704
if (is_array($key))
697705
{
@@ -757,7 +765,7 @@ public function unmarkFlashdata($key)
757765
*
758766
* @return array The property names of all flashdata
759767
*/
760-
public function getFlashKeys()
768+
public function getFlashKeys(): array
761769
{
762770
if (! isset($_SESSION['__ci_vars']))
763771
{
@@ -786,7 +794,7 @@ public function getFlashKeys()
786794
* @param null $value Value to store
787795
* @param integer $ttl Time-to-live in seconds
788796
*/
789-
public function setTempdata($data, $value = null, $ttl = 300)
797+
public function setTempdata($data, $value = null, int $ttl = 300)
790798
{
791799
$this->set($data, $value);
792800
$this->markAsTempdata($data, $ttl);
@@ -798,10 +806,10 @@ public function setTempdata($data, $value = null, $ttl = 300)
798806
* Returns either a single piece of tempdata, or all temp data currently
799807
* in the session.
800808
*
801-
* @param $key Session data key
802-
* @return mixed Session data value or null if not found.
809+
* @param string $key Session data key
810+
* @return mixed Session data value or null if not found.
803811
*/
804-
public function getTempdata($key = null)
812+
public function getTempdata(string $key = null)
805813
{
806814
if (isset($key))
807815
{
@@ -829,7 +837,7 @@ public function getTempdata($key = null)
829837
*
830838
* @param string $key Session data key
831839
*/
832-
public function removeTempdata($key)
840+
public function removeTempdata(string $key)
833841
{
834842
$this->unmarkTempdata($key);
835843
unset($_SESSION[$key]);
@@ -846,7 +854,7 @@ public function removeTempdata($key)
846854
*
847855
* @return boolean False if any of the properties were not set
848856
*/
849-
public function markAsTempdata($key, $ttl = 300)
857+
public function markAsTempdata($key, int $ttl = 300): bool
850858
{
851859
$ttl += time();
852860

@@ -932,7 +940,7 @@ public function unmarkTempdata($key)
932940
*
933941
* @return array
934942
*/
935-
public function getTempKeys()
943+
public function getTempKeys(): array
936944
{
937945
if (! isset($_SESSION['__ci_vars']))
938946
{

system/Session/SessionInterface.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function get(string $key = null);
100100
*
101101
* @return boolean
102102
*/
103-
public function has(string $key);
103+
public function has(string $key): bool;
104104

105105
//--------------------------------------------------------------------
106106

@@ -127,7 +127,7 @@ public function remove($key);
127127
* flashdata property, with $value containing the property value.
128128
*
129129
* @param string|array $data Property identifier or associative array of properties
130-
* @param null $value Property value if $data is a scalar
130+
* @param string|array $value Property value if $data is a scalar
131131
*/
132132
public function setFlashdata($data, $value = null);
133133

@@ -149,9 +149,9 @@ public function getFlashdata(string $key = null);
149149
/**
150150
* Keeps a single piece of flash data alive for one more request.
151151
*
152-
* @param string $key Property identifier or array of them
152+
* @param array|string $key Property identifier or array of them
153153
*/
154-
public function keepFlashdata(string $key);
154+
public function keepFlashdata($key);
155155

156156
//--------------------------------------------------------------------
157157

@@ -180,7 +180,7 @@ public function unmarkFlashdata($key);
180180
*
181181
* @return array The property names of all flashdata
182182
*/
183-
public function getFlashKeys();
183+
public function getFlashKeys(): array;
184184

185185
//--------------------------------------------------------------------
186186

@@ -192,18 +192,18 @@ public function getFlashKeys();
192192
* @param mixed $value Value to store
193193
* @param integer $ttl Time-to-live in seconds
194194
*/
195-
public function setTempdata($data, $value = null, $ttl = 300);
195+
public function setTempdata($data, $value = null, int $ttl = 300);
196196

197197
//--------------------------------------------------------------------
198198

199199
/**
200200
* Returns either a single piece of tempdata, or all temp data currently
201201
* in the session.
202202
*
203-
* @param string $key Session data key
203+
* @param string $key Session data key
204204
* @return mixed Session data value or null if not found.
205205
*/
206-
public function getTempdata($key = null);
206+
public function getTempdata(string $key = null);
207207

208208
//--------------------------------------------------------------------
209209

@@ -212,7 +212,7 @@ public function getTempdata($key = null);
212212
*
213213
* @param string $key Session data key
214214
*/
215-
public function removeTempdata($key);
215+
public function removeTempdata(string $key);
216216

217217
//--------------------------------------------------------------------
218218

@@ -225,7 +225,7 @@ public function removeTempdata($key);
225225
*
226226
* @return boolean False if any of the properties were not set
227227
*/
228-
public function markAsTempdata($key, $ttl = 300);
228+
public function markAsTempdata($key, int $ttl = 300);
229229

230230
//--------------------------------------------------------------------
231231

@@ -244,7 +244,7 @@ public function unmarkTempdata($key);
244244
*
245245
* @return array
246246
*/
247-
public function getTempKeys();
247+
public function getTempKeys(): array;
248248

249249
//--------------------------------------------------------------------
250250
}

0 commit comments

Comments
 (0)