Skip to content

Commit 7ae8440

Browse files
authored
chore: set complete php-cs-fixer rules (#258)
1 parent 545d6bf commit 7ae8440

21 files changed

+695
-669
lines changed

.php-cs-fixer.php

Lines changed: 384 additions & 40 deletions
Large diffs are not rendered by default.

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@
3838
"@test"
3939
],
4040
"lint": [
41-
"php-cs-fixer fix"
41+
"php-cs-fixer fix -vvv"
4242
],
4343
"test": [
44-
"phpunit --colors --coverage-html ./coverage"
44+
"phpunit --colors --coverage-html ./coverage --coverage-clover coverage/clover.xml"
4545
]
4646
}
4747
}

src/ArrayManager.php

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ public static function set(string $key, $value): void
2727
$_SESSION[$key] = $value;
2828
}
2929

30-
/**
31-
* @throws SessionException
32-
*/
30+
/** @throws SessionException */
3331
public static function has(string $key): bool
3432
{
3533
static::startSessionIfNotHasStarted();
@@ -47,19 +45,15 @@ public static function hasKeyAndValue(string $key, $value): bool
4745
return \array_key_exists($key, $_SESSION) && $_SESSION[$key] === $value;
4846
}
4947

50-
/**
51-
* @throws SessionException
52-
*/
48+
/** @throws SessionException */
5349
public static function get(string $key)
5450
{
5551
static::startSessionIfNotHasStarted();
5652

5753
return (static::has($key)) ? $_SESSION[$key] : null;
5854
}
5955

60-
/**
61-
* @throws SessionException
62-
*/
56+
/** @throws SessionException */
6357
public static function remove(string $key): void
6458
{
6559
static::startSessionIfNotHasStartedForceWrite();
@@ -69,19 +63,15 @@ public static function remove(string $key): void
6963
}
7064
}
7165

72-
/**
73-
* @throws SessionException
74-
*/
66+
/** @throws SessionException */
7567
public static function getAll(): array
7668
{
7769
static::startSessionIfNotHasStarted();
7870

7971
return $_SESSION;
8072
}
8173

82-
/**
83-
* @throws SessionException
84-
*/
74+
/** @throws SessionException */
8575
public static function getAndRemove(string $key)
8676
{
8777
static::startSessionIfNotHasStartedForceWrite();
@@ -119,9 +109,7 @@ public static function removeFlash(string $key): void
119109
}
120110
}
121111

122-
/**
123-
* @throws SessionException
124-
*/
112+
/** @throws SessionException */
125113
public static function keepFlash(array $keys = []): void
126114
{
127115
static::startSessionIfNotHasStartedForceWrite();

src/Database.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@
99
use Rancoud\Database\Configurator;
1010
use Rancoud\Database\Database as DB;
1111
use Rancoud\Database\DatabaseException;
12-
use SessionHandlerInterface;
13-
use SessionUpdateTimestampHandlerInterface;
1412

1513
/**
1614
* Class Database.
1715
*/
18-
class Database implements SessionHandlerInterface, SessionUpdateTimestampHandlerInterface
16+
class Database implements \SessionHandlerInterface, \SessionUpdateTimestampHandlerInterface
1917
{
2018
protected DB $db;
2119

@@ -24,7 +22,7 @@ class Database implements SessionHandlerInterface, SessionUpdateTimestampHandler
2422
protected int $lengthSessionID = 127;
2523

2624
/**
27-
* @param Configurator|array $configuration
25+
* @param array|Configurator $configuration
2826
*
2927
* @throws SessionException
3028
*/
@@ -51,9 +49,7 @@ public function setUserId(?int $userId): void
5149
$this->userId = $userId;
5250
}
5351

54-
/**
55-
* @throws SessionException
56-
*/
52+
/** @throws SessionException */
5753
public function setLengthSessionID(int $length): void
5854
{
5955
if ($length < 32) {
@@ -141,8 +137,6 @@ public function destroy($id): bool
141137
* @param int $max_lifetime
142138
*
143139
* @throws SessionException
144-
*
145-
* @noinspection PhpLanguageLevelInspection
146140
*/
147141
#[\ReturnTypeWillChange]
148142
public function gc($max_lifetime): bool
@@ -220,8 +214,7 @@ public function create_sid(): string // phpcs:ignore
220214
$count = $this->db->count($sql, $params);
221215
if ($count !== 0) {
222216
// @codeCoverageIgnoreStart
223-
/* Could not reach this statement without mocking the function
224-
*/
217+
// Could not reach this statement without mocking the function
225218
return $this->create_sid();
226219
// @codeCoverageIgnoreEnd
227220
}

src/DefaultEncryption.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44

55
namespace Rancoud\Session;
66

7-
use SessionHandler;
8-
97
/**
108
* Class DefaultEncryption.
119
*/
12-
class DefaultEncryption extends SessionHandler
10+
class DefaultEncryption extends \SessionHandler
1311
{
1412
use Encryption;
1513

src/DriverManager.php

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,44 +7,36 @@
77
use Predis\Client as PredisClient;
88
use Rancoud\Database\Configurator;
99
use Rancoud\Database\Database as DB;
10-
use SessionHandler;
11-
use SessionHandlerInterface;
1210

1311
/**
1412
* Class DriverManager.
1513
*/
1614
abstract class DriverManager
1715
{
18-
protected static ?SessionHandlerInterface $driver = null;
16+
protected static ?\SessionHandlerInterface $driver = null;
1917

2018
/** @throws SessionException */
2119
abstract protected static function throwExceptionIfHasStarted();
2220

2321
abstract protected static function getLifetimeForRedis();
2422

25-
/**
26-
* @throws SessionException
27-
*/
23+
/** @throws SessionException */
2824
protected static function configureDriver(): void
2925
{
3026
if (empty(static::$driver)) {
3127
static::useDefaultDriver();
3228
}
3329
}
3430

35-
/**
36-
* @throws SessionException
37-
*/
31+
/** @throws SessionException */
3832
public static function useDefaultDriver(): void
3933
{
4034
static::throwExceptionIfHasStarted();
4135

42-
static::$driver = new SessionHandler();
36+
static::$driver = new \SessionHandler();
4337
}
4438

45-
/**
46-
* @throws SessionException
47-
*/
39+
/** @throws SessionException */
4840
public static function useDefaultEncryptionDriver(string $key, ?string $method = null): void
4941
{
5042
static::throwExceptionIfHasStarted();
@@ -55,19 +47,15 @@ public static function useDefaultEncryptionDriver(string $key, ?string $method =
5547
static::$driver = $driver;
5648
}
5749

58-
/**
59-
* @throws SessionException
60-
*/
50+
/** @throws SessionException */
6151
public static function useFileDriver(): void
6252
{
6353
static::throwExceptionIfHasStarted();
6454

6555
static::$driver = new File();
6656
}
6757

68-
/**
69-
* @throws SessionException
70-
*/
58+
/** @throws SessionException */
7159
public static function useFileEncryptionDriver(string $key, ?string $method = null): void
7260
{
7361
static::throwExceptionIfHasStarted();
@@ -79,7 +67,7 @@ public static function useFileEncryptionDriver(string $key, ?string $method = nu
7967
}
8068

8169
/**
82-
* @param Configurator|array $configuration
70+
* @param array|Configurator $configuration
8371
*
8472
* @throws SessionException
8573
*/
@@ -93,9 +81,7 @@ public static function useNewDatabaseDriver($configuration): void
9381
static::$driver = $driver;
9482
}
9583

96-
/**
97-
* @throws SessionException
98-
*/
84+
/** @throws SessionException */
9985
public static function useCurrentDatabaseDriver(DB $databaseInstance): void
10086
{
10187
static::throwExceptionIfHasStarted();
@@ -107,7 +93,7 @@ public static function useCurrentDatabaseDriver(DB $databaseInstance): void
10793
}
10894

10995
/**
110-
* @param Configurator|array $configuration
96+
* @param array|Configurator $configuration
11197
*
11298
* @throws SessionException
11399
*/
@@ -122,9 +108,7 @@ public static function useNewDatabaseEncryptionDriver($configuration, string $ke
122108
static::$driver = $driver;
123109
}
124110

125-
/**
126-
* @throws SessionException
127-
*/
111+
/** @throws SessionException */
128112
public static function useCurrentDatabaseEncryptionDriver(DB $databaseInstance, string $key, ?string $method = null): void // phpcs:ignore
129113
{
130114
static::throwExceptionIfHasStarted();
@@ -152,9 +136,7 @@ public static function useNewRedisDriver($configuration): void
152136
static::$driver = $driver;
153137
}
154138

155-
/**
156-
* @throws SessionException
157-
*/
139+
/** @throws SessionException */
158140
public static function useCurrentRedisDriver(PredisClient $redisInstance): void
159141
{
160142
static::throwExceptionIfHasStarted();
@@ -183,9 +165,7 @@ public static function useNewRedisEncryptionDriver($configuration, string $key,
183165
static::$driver = $driver;
184166
}
185167

186-
/**
187-
* @throws SessionException
188-
*/
168+
/** @throws SessionException */
189169
public static function useCurrentRedisEncryptionDriver(PredisClient $redisInstance, string $key, ?string $method = null): void // phpcs:ignore
190170
{
191171
static::throwExceptionIfHasStarted();
@@ -213,17 +193,15 @@ private static function setKeyAndMethod($driver, string $key, ?string $method):
213193
}
214194
}
215195

216-
/**
217-
* @throws SessionException
218-
*/
219-
public static function useCustomDriver(SessionHandlerInterface $customDriver): void
196+
/** @throws SessionException */
197+
public static function useCustomDriver(\SessionHandlerInterface $customDriver): void
220198
{
221199
static::throwExceptionIfHasStarted();
222200

223201
static::$driver = $customDriver;
224202
}
225203

226-
public static function getDriver(): SessionHandlerInterface
204+
public static function getDriver(): \SessionHandlerInterface
227205
{
228206
return static::$driver;
229207
}

0 commit comments

Comments
 (0)