Skip to content

Commit 649aec2

Browse files
committed
fix: Remove phpstan errors
1 parent 1179907 commit 649aec2

29 files changed

+322
-372
lines changed

system/Session/Handlers/ArrayHandler.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,16 @@
2121
*/
2222
class ArrayHandler extends BaseHandler
2323
{
24+
/**
25+
* @var array<string, mixed>
26+
*/
2427
protected static $cache = [];
2528

2629
/**
2730
* Re-initialize existing session, or creates a new one.
2831
*
29-
* @param string $path The path where to store/retrieve the session
30-
* @param string $name The session name
32+
* @param string $path The path where to store/retrieve the session.
33+
* @param string $name The session name.
3134
*/
3235
public function open($path, $name): bool
3336
{
@@ -37,7 +40,7 @@ public function open($path, $name): bool
3740
/**
3841
* Reads the session data from the session storage, and returns the results.
3942
*
40-
* @param string $id The session ID
43+
* @param string $id The session ID.
4144
*
4245
* @return false|string Returns an encoded string of the read data.
4346
* If nothing was read, it must return false.
@@ -51,8 +54,8 @@ public function read($id)
5154
/**
5255
* Writes the session data to the session storage.
5356
*
54-
* @param string $id The session ID
55-
* @param string $data The encoded session data
57+
* @param string $id The session ID.
58+
* @param string $data The encoded session data.
5659
*/
5760
public function write($id, $data): bool
5861
{
@@ -68,9 +71,9 @@ public function close(): bool
6871
}
6972

7073
/**
71-
* Destroys a session
74+
* Destroys a session.
7275
*
73-
* @param string $id The session ID being destroyed
76+
* @param string $id The session ID being destroyed.
7477
*/
7578
public function destroy($id): bool
7679
{

system/Session/Handlers/BaseHandler.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
use SessionHandlerInterface;
2020

2121
/**
22-
* Base class for session handling
22+
* Base class for session handling.
2323
*/
2424
abstract class BaseHandler implements SessionHandlerInterface
2525
{
@@ -40,7 +40,7 @@ abstract class BaseHandler implements SessionHandlerInterface
4040
protected $lock = false;
4141

4242
/**
43-
* Cookie prefix
43+
* Cookie prefix.
4444
*
4545
* The Config\Cookie::$prefix setting is completely ignored.
4646
* See https://codeigniter.com/user_guide/libraries/sessions.html#session-preferences
@@ -50,14 +50,14 @@ abstract class BaseHandler implements SessionHandlerInterface
5050
protected $cookiePrefix = '';
5151

5252
/**
53-
* Cookie domain
53+
* Cookie domain.
5454
*
5555
* @var string
5656
*/
5757
protected $cookieDomain = '';
5858

5959
/**
60-
* Cookie path
60+
* Cookie path.
6161
*
6262
* @var string
6363
*/
@@ -71,7 +71,7 @@ abstract class BaseHandler implements SessionHandlerInterface
7171
protected $cookieSecure = false;
7272

7373
/**
74-
* Cookie name to use
74+
* Cookie name to use.
7575
*
7676
* @var string
7777
*/
@@ -85,17 +85,17 @@ abstract class BaseHandler implements SessionHandlerInterface
8585
protected $matchIP = false;
8686

8787
/**
88-
* Current session ID
88+
* Current session ID.
8989
*
9090
* @var string|null
9191
*/
9292
protected $sessionID;
9393

9494
/**
9595
* The 'save path' for the session
96-
* varies between
96+
* varies between.
9797
*
98-
* @var array|string
98+
* @var string
9999
*/
100100
protected $savePath;
101101

system/Session/Handlers/DatabaseHandler.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
use ReturnTypeWillChange;
2222

2323
/**
24-
* Base database session handler
24+
* Base database session handler.
2525
*
2626
* Do not use this class. Use database specific handler class.
2727
*/
@@ -49,21 +49,21 @@ class DatabaseHandler extends BaseHandler
4949
protected $db;
5050

5151
/**
52-
* The database type
52+
* The database type.
5353
*
5454
* @var string
5555
*/
5656
protected $platform;
5757

5858
/**
59-
* Row exists flag
59+
* Row exists flag.
6060
*
6161
* @var bool
6262
*/
6363
protected $rowExists = false;
6464

6565
/**
66-
* ID prefix for multiple session cookies
66+
* ID prefix for multiple session cookies.
6767
*/
6868
protected string $idPrefix;
6969

@@ -74,16 +74,16 @@ public function __construct(SessionConfig $config, string $ipAddress)
7474
{
7575
parent::__construct($config, $ipAddress);
7676

77-
// Store Session configurations
78-
$this->DBGroup = $config->DBGroup ?? config(Database::class)->defaultGroup;
79-
// Add session cookie name for multiple session cookies.
80-
$this->idPrefix = $config->cookieName . ':';
81-
8277
$this->table = $this->savePath;
83-
if (empty($this->table)) {
78+
79+
if ($this->table === '') {
8480
throw SessionException::forMissingDatabaseTable();
8581
}
8682

83+
// Store Session configurations
84+
$this->DBGroup = $config->DBGroup ?? config(Database::class)->defaultGroup;
85+
// Add session cookie name for multiple session cookies.
86+
$this->idPrefix = $config->cookieName . ':';
8787
$this->db = Database::connect($this->DBGroup);
8888
$this->platform = $this->db->getPlatform();
8989
}
@@ -96,7 +96,7 @@ public function __construct(SessionConfig $config, string $ipAddress)
9696
*/
9797
public function open($path, $name): bool
9898
{
99-
if (empty($this->db->connID)) {
99+
if ($this->db->connID === false) {
100100
$this->db->initialize();
101101
}
102102

@@ -153,7 +153,7 @@ public function read($id)
153153
}
154154

155155
/**
156-
* Sets SELECT clause
156+
* Sets SELECT clause.
157157
*
158158
* @return void
159159
*/
@@ -163,7 +163,7 @@ protected function setSelect(BaseBuilder $builder)
163163
}
164164

165165
/**
166-
* Decodes column data
166+
* Decodes column data.
167167
*
168168
* @param string $data
169169
*
@@ -177,8 +177,8 @@ protected function decodeData($data)
177177
/**
178178
* Writes the session data to the session storage.
179179
*
180-
* @param string $id The session ID
181-
* @param string $data The encoded session data
180+
* @param string $id The session ID.
181+
* @param string $data The encoded session data.
182182
*/
183183
public function write($id, $data): bool
184184
{
@@ -230,7 +230,7 @@ public function write($id, $data): bool
230230
}
231231

232232
/**
233-
* Prepare data to insert/update
233+
* Prepare data to insert/update.
234234
*/
235235
protected function prepareData(string $data): string
236236
{
@@ -246,9 +246,9 @@ public function close(): bool
246246
}
247247

248248
/**
249-
* Destroys a session
249+
* Destroys a session.
250250
*
251-
* @param string $id The session ID being destroyed
251+
* @param string $id The session ID being destroyed.
252252
*/
253253
public function destroy($id): bool
254254
{

system/Session/Handlers/FileHandler.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
use ReturnTypeWillChange;
2020

2121
/**
22-
* Session handler using file system for storage
22+
* Session handler using file system for storage.
2323
*/
2424
class FileHandler extends BaseHandler
2525
{
@@ -31,14 +31,14 @@ class FileHandler extends BaseHandler
3131
protected $savePath;
3232

3333
/**
34-
* The file handle
34+
* The file handle.
3535
*
3636
* @var resource|null
3737
*/
3838
protected $fileHandle;
3939

4040
/**
41-
* File Name
41+
* File Name.
4242
*
4343
* @var string
4444
*/
@@ -59,7 +59,7 @@ class FileHandler extends BaseHandler
5959
protected $matchIP = false;
6060

6161
/**
62-
* Regex of session ID
62+
* Regex of session ID.
6363
*
6464
* @var string
6565
*/
@@ -69,7 +69,7 @@ public function __construct(SessionConfig $config, string $ipAddress)
6969
{
7070
parent::__construct($config, $ipAddress);
7171

72-
if (! empty($this->savePath)) {
72+
if ($this->savePath !== '') {
7373
$this->savePath = rtrim($this->savePath, '/\\');
7474
ini_set('session.save_path', $this->savePath);
7575
} else {
@@ -88,8 +88,8 @@ public function __construct(SessionConfig $config, string $ipAddress)
8888
/**
8989
* Re-initialize existing session, or creates a new one.
9090
*
91-
* @param string $path The path where to store/retrieve the session
92-
* @param string $name The session name
91+
* @param string $path The path where to store/retrieve the session.
92+
* @param string $name The session name.
9393
*
9494
* @throws SessionException
9595
*/
@@ -114,7 +114,7 @@ public function open($path, $name): bool
114114
/**
115115
* Reads the session data from the session storage, and returns the results.
116116
*
117-
* @param string $id The session ID
117+
* @param string $id The session ID.
118118
*
119119
* @return false|string Returns an encoded string of the read data.
120120
* If nothing was read, it must return false.
@@ -175,8 +175,8 @@ public function read($id)
175175
/**
176176
* Writes the session data to the session storage.
177177
*
178-
* @param string $id The session ID
179-
* @param string $data The encoded session data
178+
* @param string $id The session ID.
179+
* @param string $data The encoded session data.
180180
*/
181181
public function write($id, $data): bool
182182
{
@@ -239,9 +239,9 @@ public function close(): bool
239239
}
240240

241241
/**
242-
* Destroys a session
242+
* Destroys a session.
243243
*
244-
* @param string $id The session ID being destroyed
244+
* @param string $id The session ID being destroyed.
245245
*/
246246
public function destroy($id): bool
247247
{
@@ -310,7 +310,7 @@ public function gc($max_lifetime)
310310
}
311311

312312
/**
313-
* Configure Session ID regular expression
313+
* Configure Session ID regular expression.
314314
*
315315
* To make life easier, we force the PHP defaults. Because PHP9 forces them.
316316
*

0 commit comments

Comments
 (0)