Skip to content

Commit efd2cee

Browse files
committed
Replacing return type with @return docblock
1 parent 9810b68 commit efd2cee

File tree

3 files changed

+102
-34
lines changed

3 files changed

+102
-34
lines changed

system/Session/Session.php

Lines changed: 57 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ public function start()
233233
$this->setSaveHandler();
234234

235235
// Sanitize the cookie, because apparently PHP doesn't do that for userspace handlers
236-
if (isset($_COOKIE[$this->config->cookieName])
236+
if (
237+
isset($_COOKIE[$this->config->cookieName])
237238
&& (! is_string($_COOKIE[$this->config->cookieName]) || preg_match('#\A' . $this->sidRegexp . '\z#', $_COOKIE[$this->config->cookieName]) !== 1)
238239
) {
239240
unset($_COOKIE[$this->config->cookieName]);
@@ -267,8 +268,10 @@ public function start()
267268
* Destroys the current session.
268269
*
269270
* @deprecated Use destroy() instead.
271+
*
272+
* @return void
270273
*/
271-
public function stop(): void
274+
public function stop()
272275
{
273276
$this->destroy();
274277
}
@@ -277,8 +280,10 @@ public function stop(): void
277280
* Configuration.
278281
*
279282
* Handle input binds and configuration defaults.
283+
*
284+
* @return void
280285
*/
281-
protected function configure(): void
286+
protected function configure()
282287
{
283288
ini_set('session.name', $this->config->cookieName);
284289

@@ -318,8 +323,10 @@ protected function configure(): void
318323
*
319324
* To make life easier, we force the PHP defaults. Because PHP9 forces them.
320325
* See https://wiki.php.net/rfc/deprecations_php_8_4#sessionsid_length_and_sessionsid_bits_per_character
326+
*
327+
* @return void
321328
*/
322-
protected function configureSidLength(): void
329+
protected function configureSidLength()
323330
{
324331
$bitsPerCharacter = (int) ini_get('session.sid_bits_per_character');
325332
$sidLength = (int) ini_get('session.sid_length');
@@ -342,8 +349,10 @@ protected function configureSidLength(): void
342349
*
343350
* Clears old "flash" data, marks the new one for deletion and handles
344351
* "temp" data deletion.
352+
*
353+
* @return void
345354
*/
346-
protected function initVars(): void
355+
protected function initVars()
347356
{
348357
if (! isset($_SESSION['__ci_vars'])) {
349358
return;
@@ -370,8 +379,10 @@ protected function initVars(): void
370379
* Regenerates the session ID.
371380
*
372381
* @param bool $destroy Should old session data be destroyed?
382+
*
383+
* @return void
373384
*/
374-
public function regenerate(bool $destroy = false): void
385+
public function regenerate(bool $destroy = false)
375386
{
376387
$_SESSION['__ci_last_regenerate'] = Time::now()->getTimestamp();
377388
session_regenerate_id($destroy);
@@ -401,8 +412,10 @@ private function removeOldSessionCookie(): void
401412

402413
/**
403414
* Destroys the current session.
415+
*
416+
* @return void
404417
*/
405-
public function destroy(): void
418+
public function destroy()
406419
{
407420
if (ENVIRONMENT === 'testing') {
408421
return;
@@ -436,8 +449,10 @@ public function close()
436449
*
437450
* @param array|string $data Property name or associative array of properties
438451
* @param array|bool|float|int|object|string|null $value Property value if single key provided
452+
*
453+
* @return void
439454
*/
440-
public function set($data, $value = null): void
455+
public function set($data, $value = null)
441456
{
442457
if (is_array($data)) {
443458
foreach ($data as $key => &$value) {
@@ -510,8 +525,10 @@ public function has(string $key): bool
510525
*
511526
* @param string $key Identifier of the session property we are interested in.
512527
* @param array $data value to be pushed to existing session key.
528+
*
529+
* @return void
513530
*/
514-
public function push(string $key, array $data): void
531+
public function push(string $key, array $data)
515532
{
516533
if ($this->has($key) && is_array($value = $this->get($key))) {
517534
$this->set($key, array_merge($value, $data));
@@ -526,8 +543,10 @@ public function push(string $key, array $data): void
526543
* of a specific session property to remove.
527544
*
528545
* @param array|string $key Identifier of the session property or properties to remove.
546+
*
547+
* @return void
529548
*/
530-
public function remove($key): void
549+
public function remove($key)
531550
{
532551
if (is_array($key)) {
533552
foreach ($key as $k) {
@@ -598,8 +617,10 @@ public function __isset(string $key): bool
598617
*
599618
* @param array|string $data Property identifier or associative array of properties
600619
* @param array|bool|float|int|object|string|null $value Property value if $data is a scalar
620+
*
621+
* @return void
601622
*/
602-
public function setFlashdata($data, $value = null): void
623+
public function setFlashdata($data, $value = null)
603624
{
604625
$this->set($data, $value);
605626
$this->markAsFlashdata(is_array($data) ? array_keys($data) : $data);
@@ -638,8 +659,10 @@ public function getFlashdata(?string $key = null)
638659
* Keeps a single piece of flash data alive for one more request.
639660
*
640661
* @param array|string $key Property identifier or array of them
662+
*
663+
* @return void
641664
*/
642-
public function keepFlashdata($key): void
665+
public function keepFlashdata($key)
643666
{
644667
$this->markAsFlashdata($key);
645668
}
@@ -680,8 +703,10 @@ public function markAsFlashdata($key): bool
680703
* Unmark data in the session as flashdata.
681704
*
682705
* @param array|string $key Property identifier or array of them
706+
*
707+
* @return void
683708
*/
684-
public function unmarkFlashdata($key): void
709+
public function unmarkFlashdata($key)
685710
{
686711
if (! isset($_SESSION['__ci_vars'])) {
687712
return;
@@ -731,8 +756,10 @@ public function getFlashKeys(): array
731756
* @param array|string $data Session data key or associative array of items
732757
* @param array|bool|float|int|object|string|null $value Value to store
733758
* @param int $ttl Time-to-live in seconds
759+
*
760+
* @return void
734761
*/
735-
public function setTempdata($data, $value = null, int $ttl = 300): void
762+
public function setTempdata($data, $value = null, int $ttl = 300)
736763
{
737764
$this->set($data, $value);
738765
$this->markAsTempdata($data, $ttl);
@@ -750,7 +777,7 @@ public function getTempdata(?string $key = null)
750777
{
751778
if (isset($key)) {
752779
return (isset($_SESSION['__ci_vars'], $_SESSION['__ci_vars'][$key], $_SESSION[$key])
753-
&& is_int($_SESSION['__ci_vars'][$key])) ? $_SESSION[$key] : null;
780+
&& is_int($_SESSION['__ci_vars'][$key])) ? $_SESSION[$key] : null;
754781
}
755782

756783
$tempdata = [];
@@ -770,8 +797,10 @@ public function getTempdata(?string $key = null)
770797
* Removes a single piece of temporary data from the session.
771798
*
772799
* @param string $key Session data key
800+
*
801+
* @return void
773802
*/
774-
public function removeTempdata(string $key): void
803+
public function removeTempdata(string $key)
775804
{
776805
$this->unmarkTempdata($key);
777806
unset($_SESSION[$key]);
@@ -830,8 +859,10 @@ public function markAsTempdata($key, int $ttl = 300): bool
830859
* lifespan and allowing it to live as long as the session does.
831860
*
832861
* @param array|string $key Property identifier or array of them
862+
*
863+
* @return void
833864
*/
834-
public function unmarkTempdata($key): void
865+
public function unmarkTempdata($key)
835866
{
836867
if (! isset($_SESSION['__ci_vars'])) {
837868
return;
@@ -875,17 +906,21 @@ public function getTempKeys(): array
875906
/**
876907
* Sets the driver as the session handler in PHP.
877908
* Extracted for easier testing.
909+
*
910+
* @return void
878911
*/
879-
protected function setSaveHandler(): void
912+
protected function setSaveHandler()
880913
{
881914
session_set_save_handler($this->driver, true);
882915
}
883916

884917
/**
885918
* Starts the session.
886919
* Extracted for testing reasons.
920+
*
921+
* @return void
887922
*/
888-
protected function startSession(): void
923+
protected function startSession()
889924
{
890925
if (ENVIRONMENT === 'testing') {
891926
$_SESSION = [];
@@ -900,8 +935,10 @@ protected function startSession(): void
900935
* Takes care of setting the cookie on the client side.
901936
*
902937
* @codeCoverageIgnore
938+
*
939+
* @return void
903940
*/
904-
protected function setCookie(): void
941+
protected function setCookie()
905942
{
906943
$expiration = $this->config->expiration === 0 ? 0 : Time::now()->getTimestamp() + $this->config->expiration;
907944
$this->cookie = $this->cookie->withValue(session_id())->withExpires($expiration);

system/Session/SessionInterface.php

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,17 @@ interface SessionInterface
2222
* Regenerates the session ID.
2323
*
2424
* @param bool $destroy Should old session data be destroyed?
25+
*
26+
* @return void
2527
*/
26-
public function regenerate(bool $destroy = false): void;
28+
public function regenerate(bool $destroy = false);
2729

2830
/**
2931
* Destroys the current session.
32+
*
33+
* @return void
3034
*/
31-
public function destroy(): void;
35+
public function destroy();
3236

3337
/**
3438
* Sets user data into the session.
@@ -41,8 +45,10 @@ public function destroy(): void;
4145
*
4246
* @param array|string $data Property name or associative array of properties
4347
* @param array|bool|float|int|object|string|null $value Property value if single key provided
48+
*
49+
* @return void
4450
*/
45-
public function set($data, $value = null): void;
51+
public function set($data, $value = null);
4652

4753
/**
4854
* Get user data that has been set in the session.
@@ -74,8 +80,10 @@ public function has(string $key): bool;
7480
* of a specific session property to remove.
7581
*
7682
* @param array|string $key Identifier of the session property or properties to remove.
83+
*
84+
* @return void
7785
*/
78-
public function remove($key): void;
86+
public function remove($key);
7987

8088
/**
8189
* Sets data into the session that will only last for a single request.
@@ -88,8 +96,10 @@ public function remove($key): void;
8896
*
8997
* @param array|string $data Property identifier or associative array of properties
9098
* @param array|string $value Property value if $data is a scalar
99+
*
100+
* @return void
91101
*/
92-
public function setFlashdata($data, $value = null): void;
102+
public function setFlashdata($data, $value = null);
93103

94104
/**
95105
* Retrieve one or more items of flash data from the session.
@@ -107,8 +117,10 @@ public function getFlashdata(?string $key = null);
107117
* Keeps a single piece of flash data alive for one more request.
108118
*
109119
* @param array|string $key Property identifier or array of them
120+
*
121+
* @return void
110122
*/
111-
public function keepFlashdata($key): void;
123+
public function keepFlashdata($key);
112124

113125
/**
114126
* Mark a session property or properties as flashdata.
@@ -123,8 +135,10 @@ public function markAsFlashdata($key);
123135
* Unmark data in the session as flashdata.
124136
*
125137
* @param array|string $key Property identifier or array of them
138+
*
139+
* @return void
126140
*/
127-
public function unmarkFlashdata($key): void;
141+
public function unmarkFlashdata($key);
128142

129143
/**
130144
* Retrieve all of the keys for session data marked as flashdata.
@@ -140,8 +154,10 @@ public function getFlashKeys(): array;
140154
* @param array|string $data Session data key or associative array of items
141155
* @param array|bool|float|int|object|string|null $value Value to store
142156
* @param int $ttl Time-to-live in seconds
157+
*
158+
* @return void
143159
*/
144-
public function setTempdata($data, $value = null, int $ttl = 300): void;
160+
public function setTempdata($data, $value = null, int $ttl = 300);
145161

146162
/**
147163
* Returns either a single piece of tempdata, or all temp data currently
@@ -157,8 +173,10 @@ public function getTempdata(?string $key = null);
157173
* Removes a single piece of temporary data from the session.
158174
*
159175
* @param string $key Session data key
176+
*
177+
* @return void
160178
*/
161-
public function removeTempdata(string $key): void;
179+
public function removeTempdata(string $key);
162180

163181
/**
164182
* Mark one of more pieces of data as being temporary, meaning that
@@ -176,8 +194,10 @@ public function markAsTempdata($key, int $ttl = 300);
176194
* lifespan and allowing it to live as long as the session does.
177195
*
178196
* @param array|string $key Property identifier or array of them
197+
*
198+
* @return void
179199
*/
180-
public function unmarkTempdata($key): void;
200+
public function unmarkTempdata($key);
181201

182202
/**
183203
* Retrieve the keys of all session data that have been marked as temporary data.

0 commit comments

Comments
 (0)