Skip to content

Commit bfad114

Browse files
author
Jonathon Hill
committed
Level 4 static analysis
1 parent ea32e56 commit bfad114

File tree

9 files changed

+9
-26
lines changed

9 files changed

+9
-26
lines changed

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
parameters:
2-
level: 3
2+
level: 4
33
paths:
44
- src
55
- tests

src/Handlers/ArrayHandler.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ class ArrayHandler implements
2727
{
2828
use SessionIdTrait;
2929

30-
private Config $config;
31-
3230
private SessionId $sid;
3331

3432
/**
@@ -38,15 +36,8 @@ class ArrayHandler implements
3836

3937
public function __construct(Config $config, array $store = [])
4038
{
41-
// required for SessionIdTrait
42-
$this->config = $config;
4339
$this->sid = new SessionId($config);
44-
4540
$this->store = $store;
46-
47-
if (microtime(true) === false) {
48-
throw new RuntimeException("High resolution time not supported");
49-
}
5041
}
5142

5243
public function open($path, $name): bool

src/Handlers/FileHandler.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,13 @@ class FileHandler implements
2525
{
2626
use SessionIdTrait;
2727

28-
private Config $config;
29-
3028
private SessionId $sid;
3129

3230
private string $savePath;
3331

3432
public function __construct(Config $config)
3533
{
3634
// required for SessionIdTrait
37-
$this->config = $config;
3835
$this->sid = new SessionId($config);
3936
}
4037

src/Handlers/Psr16Handler.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ class Psr16Handler implements
2424
{
2525
use SessionIdTrait;
2626

27-
private Config $config;
28-
2927
private SessionId $sid;
3028

3129
private CacheInterface $store;
@@ -34,7 +32,6 @@ class Psr16Handler implements
3432

3533
public function __construct(Config $config, CacheInterface $store)
3634
{
37-
$this->config = $config; // still required by SessionIdTrait
3835
$this->store = $store;
3936
$this->sid = new SessionId($config);
4037
}

src/Handlers/RedisHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function open($path, $name): bool
4949
return false;
5050
}
5151

52-
if (!$redis->select((int) $query['database'] ?? 0)) {
52+
if (!$redis->select((int) ($query['database'] ?? 0))) {
5353
$redis->close();
5454
unset($redis);
5555
return false;

src/Manager.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,7 @@ public function start(): bool
347347
}
348348

349349
if ($contents === false) {
350-
if ($isOpen) {
351-
$handler->close();
352-
}
350+
$handler->close();
353351
return false;
354352
}
355353

@@ -433,7 +431,6 @@ public function write_close(): bool
433431
$handler->close();
434432
$this->currentSession->close();
435433
throw new RuntimeException("Data serialization failure");
436-
return false;
437434
}
438435

439436
if (!$this->currentSession->isModified() && $this->config->getLazyWrite()) {

src/Middleware/SessionCacheControlMiddleware.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function process(
2121
): ResponseInterface {
2222
$response = $handler->handle($request);
2323

24-
/** @var Manager */
24+
/** @var ?Manager */
2525
$manager = $request->getAttribute("sessionManager");
2626

2727
if (!$manager || !$manager instanceof Manager) {

src/Middleware/SessionMiddleware.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function process(
1919
ServerRequestInterface $request,
2020
RequestHandlerInterface $handler
2121
): ResponseInterface {
22-
/** @var Manager */
22+
/** @var ?Manager */
2323
$manager = $request->getAttribute("sessionManager");
2424

2525
if (!$manager || !$manager instanceof Manager) {

tests/behavior/PersistenceContext.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Compwright\PhpSession\Manager;
1212
use Compwright\PhpSession\Session;
1313
use PHPUnit\Framework\Assert;
14+
use RuntimeException;
1415

1516
/**
1617
* Defines application features from the specific context.
@@ -112,11 +113,11 @@ public function furtherSessionWritesAreNotSaved()
112113
Assert::assertFalse($this->session->isWriteable());
113114

114115
try {
115-
$this->session->bar = "baz";
116-
} catch (\RuntimeException $e) {
116+
$this->session->__set('bar', 'baz');
117+
} catch (RuntimeException $e) {
117118
// ignore
118119
} finally {
119-
Assert::assertFalse(isset($this->session->bar));
120+
Assert::assertFalse($this->session->__isset('bar'));
120121
}
121122
}
122123

0 commit comments

Comments
 (0)