Skip to content

Commit 9b717b2

Browse files
author
Marijus Plančiūnas
authored
Merge pull request #1 from villagepay/2.7-php82
PHP 8 support
2 parents b67e5cb + 7c38645 commit 9b717b2

8 files changed

+48
-48
lines changed

Resources/stubs/SessionHandlerInterface.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ interface SessionHandlerInterface
4141
*
4242
* @return bool true on success, false on failure
4343
*/
44-
public function open($savePath, $sessionName);
44+
public function open($savePath, $sessionName): bool;
4545

4646
/**
4747
* Closes the current session.
@@ -50,7 +50,7 @@ public function open($savePath, $sessionName);
5050
*
5151
* @return bool true on success, false on failure
5252
*/
53-
public function close();
53+
public function close(): bool;
5454

5555
/**
5656
* Reads the session data.
@@ -61,7 +61,7 @@ public function close();
6161
*
6262
* @return string Same session data as passed in write() or empty string when non-existent or on failure
6363
*/
64-
public function read($sessionId);
64+
public function read($sessionId): string;
6565

6666
/**
6767
* Writes the session data to the storage.
@@ -76,7 +76,7 @@ public function read($sessionId);
7676
*
7777
* @return bool true on success, false on failure
7878
*/
79-
public function write($sessionId, $data);
79+
public function write($sessionId, $data): bool;
8080

8181
/**
8282
* Destroys a session.
@@ -87,7 +87,7 @@ public function write($sessionId, $data);
8787
*
8888
* @return bool true on success, false on failure
8989
*/
90-
public function destroy($sessionId);
90+
public function destroy($sessionId): bool;
9191

9292
/**
9393
* Cleans up expired sessions (garbage collection).
@@ -98,5 +98,5 @@ public function destroy($sessionId);
9898
*
9999
* @return bool true on success, false on failure
100100
*/
101-
public function gc($maxlifetime);
101+
public function gc($maxlifetime): bool;
102102
}

Session/Storage/Handler/LegacyPdoSessionHandler.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,23 +92,23 @@ public function __construct(\PDO $pdo, array $dbOptions = array())
9292
/**
9393
* {@inheritdoc}
9494
*/
95-
public function open($savePath, $sessionName)
95+
public function open($savePath, $sessionName): bool
9696
{
9797
return true;
9898
}
9999

100100
/**
101101
* {@inheritdoc}
102102
*/
103-
public function close()
103+
public function close(): bool
104104
{
105105
return true;
106106
}
107107

108108
/**
109109
* {@inheritdoc}
110110
*/
111-
public function destroy($sessionId)
111+
public function destroy($sessionId): bool
112112
{
113113
// delete the record associated with this id
114114
$sql = "DELETE FROM $this->table WHERE $this->idCol = :id";
@@ -127,7 +127,7 @@ public function destroy($sessionId)
127127
/**
128128
* {@inheritdoc}
129129
*/
130-
public function gc($maxlifetime)
130+
public function gc($maxlifetime): bool
131131
{
132132
// delete the session records that have expired
133133
$sql = "DELETE FROM $this->table WHERE $this->timeCol < :time";
@@ -146,7 +146,7 @@ public function gc($maxlifetime)
146146
/**
147147
* {@inheritdoc}
148148
*/
149-
public function read($sessionId)
149+
public function read($sessionId): string
150150
{
151151
$sql = "SELECT $this->dataCol FROM $this->table WHERE $this->idCol = :id";
152152

@@ -171,7 +171,7 @@ public function read($sessionId)
171171
/**
172172
* {@inheritdoc}
173173
*/
174-
public function write($sessionId, $data)
174+
public function write($sessionId, $data): bool
175175
{
176176
$encoded = base64_encode($data);
177177

Session/Storage/Handler/MemcacheSessionHandler.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,39 +56,39 @@ public function __construct(\Memcache $memcache, array $options = array())
5656
/**
5757
* {@inheritdoc}
5858
*/
59-
public function open($savePath, $sessionName)
59+
public function open($savePath, $sessionName): bool
6060
{
6161
return true;
6262
}
6363

6464
/**
6565
* {@inheritdoc}
6666
*/
67-
public function close()
67+
public function close(): bool
6868
{
6969
return true;
7070
}
7171

7272
/**
7373
* {@inheritdoc}
7474
*/
75-
public function read($sessionId)
75+
public function read($sessionId): string
7676
{
7777
return $this->memcache->get($this->prefix.$sessionId) ?: '';
7878
}
7979

8080
/**
8181
* {@inheritdoc}
8282
*/
83-
public function write($sessionId, $data)
83+
public function write($sessionId, $data): bool
8484
{
8585
return $this->memcache->set($this->prefix.$sessionId, $data, 0, time() + $this->ttl);
8686
}
8787

8888
/**
8989
* {@inheritdoc}
9090
*/
91-
public function destroy($sessionId)
91+
public function destroy($sessionId): bool
9292
{
9393
$this->memcache->delete($this->prefix.$sessionId);
9494

@@ -98,7 +98,7 @@ public function destroy($sessionId)
9898
/**
9999
* {@inheritdoc}
100100
*/
101-
public function gc($maxlifetime)
101+
public function gc($maxlifetime): bool
102102
{
103103
// not required here because memcache will auto expire the records anyhow.
104104
return true;

Session/Storage/Handler/MemcachedSessionHandler.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,39 +62,39 @@ public function __construct(\Memcached $memcached, array $options = array())
6262
/**
6363
* {@inheritdoc}
6464
*/
65-
public function open($savePath, $sessionName)
65+
public function open($savePath, $sessionName): bool
6666
{
6767
return true;
6868
}
6969

7070
/**
7171
* {@inheritdoc}
7272
*/
73-
public function close()
73+
public function close(): bool
7474
{
7575
return true;
7676
}
7777

7878
/**
7979
* {@inheritdoc}
8080
*/
81-
public function read($sessionId)
81+
public function read($sessionId): string
8282
{
8383
return $this->memcached->get($this->prefix.$sessionId) ?: '';
8484
}
8585

8686
/**
8787
* {@inheritdoc}
8888
*/
89-
public function write($sessionId, $data)
89+
public function write($sessionId, $data): bool
9090
{
9191
return $this->memcached->set($this->prefix.$sessionId, $data, time() + $this->ttl);
9292
}
9393

9494
/**
9595
* {@inheritdoc}
9696
*/
97-
public function destroy($sessionId)
97+
public function destroy($sessionId): bool
9898
{
9999
$result = $this->memcached->delete($this->prefix.$sessionId);
100100

@@ -104,7 +104,7 @@ public function destroy($sessionId)
104104
/**
105105
* {@inheritdoc}
106106
*/
107-
public function gc($maxlifetime)
107+
public function gc($maxlifetime): bool
108108
{
109109
// not required here because memcached will auto expire the records anyhow.
110110
return true;

Session/Storage/Handler/MongoDbSessionHandler.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,23 +85,23 @@ public function __construct($mongo, array $options)
8585
/**
8686
* {@inheritdoc}
8787
*/
88-
public function open($savePath, $sessionName)
88+
public function open($savePath, $sessionName): bool
8989
{
9090
return true;
9191
}
9292

9393
/**
9494
* {@inheritdoc}
9595
*/
96-
public function close()
96+
public function close(): bool
9797
{
9898
return true;
9999
}
100100

101101
/**
102102
* {@inheritdoc}
103103
*/
104-
public function destroy($sessionId)
104+
public function destroy($sessionId): bool
105105
{
106106
$methodName = $this->mongo instanceof \MongoDB\Client ? 'deleteOne' : 'remove';
107107

@@ -115,7 +115,7 @@ public function destroy($sessionId)
115115
/**
116116
* {@inheritdoc}
117117
*/
118-
public function gc($maxlifetime)
118+
public function gc($maxlifetime): bool
119119
{
120120
$methodName = $this->mongo instanceof \MongoDB\Client ? 'deleteMany' : 'remove';
121121

@@ -129,7 +129,7 @@ public function gc($maxlifetime)
129129
/**
130130
* {@inheritdoc}
131131
*/
132-
public function write($sessionId, $data)
132+
public function write($sessionId, $data): bool
133133
{
134134
$expiry = $this->createDateTime(time() + (int) ini_get('session.gc_maxlifetime'));
135135

@@ -161,7 +161,7 @@ public function write($sessionId, $data)
161161
/**
162162
* {@inheritdoc}
163163
*/
164-
public function read($sessionId)
164+
public function read($sessionId): string
165165
{
166166
$dbData = $this->getCollection()->findOne(array(
167167
$this->options['id_field'] => $sessionId,

Session/Storage/Handler/NullSessionHandler.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,47 +23,47 @@ class NullSessionHandler implements \SessionHandlerInterface
2323
/**
2424
* {@inheritdoc}
2525
*/
26-
public function open($savePath, $sessionName)
26+
public function open($savePath, $sessionName): bool
2727
{
2828
return true;
2929
}
3030

3131
/**
3232
* {@inheritdoc}
3333
*/
34-
public function close()
34+
public function close(): bool
3535
{
3636
return true;
3737
}
3838

3939
/**
4040
* {@inheritdoc}
4141
*/
42-
public function read($sessionId)
42+
public function read($sessionId): string
4343
{
4444
return '';
4545
}
4646

4747
/**
4848
* {@inheritdoc}
4949
*/
50-
public function write($sessionId, $data)
50+
public function write($sessionId, $data): bool
5151
{
5252
return true;
5353
}
5454

5555
/**
5656
* {@inheritdoc}
5757
*/
58-
public function destroy($sessionId)
58+
public function destroy($sessionId): bool
5959
{
6060
return true;
6161
}
6262

6363
/**
6464
* {@inheritdoc}
6565
*/
66-
public function gc($maxlifetime)
66+
public function gc($maxlifetime): bool
6767
{
6868
return true;
6969
}

Session/Storage/Handler/PdoSessionHandler.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ public function isSessionExpired()
258258
/**
259259
* {@inheritdoc}
260260
*/
261-
public function open($savePath, $sessionName)
261+
public function open($savePath, $sessionName): bool
262262
{
263263
if (null === $this->pdo) {
264264
$this->connect($this->dsn ?: $savePath);
@@ -270,7 +270,7 @@ public function open($savePath, $sessionName)
270270
/**
271271
* {@inheritdoc}
272272
*/
273-
public function read($sessionId)
273+
public function read($sessionId): string
274274
{
275275
try {
276276
return $this->doRead($sessionId);
@@ -284,7 +284,7 @@ public function read($sessionId)
284284
/**
285285
* {@inheritdoc}
286286
*/
287-
public function gc($maxlifetime)
287+
public function gc($maxlifetime): bool
288288
{
289289
// We delay gc() to close() so that it is executed outside the transactional and blocking read-write process.
290290
// This way, pruning expired sessions does not block them from being started while the current session is used.
@@ -296,7 +296,7 @@ public function gc($maxlifetime)
296296
/**
297297
* {@inheritdoc}
298298
*/
299-
public function destroy($sessionId)
299+
public function destroy($sessionId): bool
300300
{
301301
// delete the record associated with this id
302302
$sql = "DELETE FROM $this->table WHERE $this->idCol = :id";
@@ -317,7 +317,7 @@ public function destroy($sessionId)
317317
/**
318318
* {@inheritdoc}
319319
*/
320-
public function write($sessionId, $data)
320+
public function write($sessionId, $data): bool
321321
{
322322
$maxlifetime = (int) ini_get('session.gc_maxlifetime');
323323

@@ -363,7 +363,7 @@ public function write($sessionId, $data)
363363
/**
364364
* {@inheritdoc}
365365
*/
366-
public function close()
366+
public function close(): bool
367367
{
368368
$this->commit();
369369

0 commit comments

Comments
 (0)