Skip to content

Commit 5aaab8d

Browse files
committed
Replace psalm with phpstan
1 parent 9849d2e commit 5aaab8d

File tree

8 files changed

+36
-40
lines changed

8 files changed

+36
-40
lines changed

phpstan-dev.neon

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,3 @@ parameters:
22
level: 5
33
paths:
44
- tests
5-
6-
includes:
7-
- phpstan-dev-baseline.neon

phpstan.neon

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,3 @@ parameters:
22
level: 6
33
paths:
44
- src
5-
6-
includes:
7-
- phpstan-baseline.neon

src/Auth/Process/Consent.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ class Consent extends Auth\ProcessingFilter
5757
/**
5858
* Attributes where the value should be hidden
5959
*
60-
* @var array
60+
* @var array<mixed>
6161
*/
6262
private array $hiddenAttributes = [];
6363

6464
/**
6565
* Attributes which should not require consent
6666
*
67-
* @var array
67+
* @var array<mixed>
6868
*/
6969
private array $noconsentattributes = [];
7070

@@ -88,12 +88,12 @@ class Consent extends Auth\ProcessingFilter
8888
*
8989
* Validates and parses the configuration.
9090
*
91-
* @param array $config Configuration information.
91+
* @param array<mixed> $config Configuration information.
9292
* @param mixed $reserved For future use.
9393
*
9494
* @throws \SimpleSAML\Error\Exception if the configuration is not valid.
9595
*/
96-
public function __construct(array $config, $reserved)
96+
public function __construct($config, $reserved)
9797
{
9898
parent::__construct($config, $reserved);
9999

@@ -181,7 +181,7 @@ public function __construct(array $config, $reserved)
181181
/**
182182
* Helper function to check whether consent is disabled.
183183
*
184-
* @param mixed $option The consent.disable option. Either an array of array, an array or a boolean.
184+
* @param mixed $option The consent.disable option. Either an array of array, an array or a boolean.
185185
* @param string $entityId The entityID of the SP/IdP.
186186
*
187187
* @return boolean True if disabled, false if not.
@@ -241,8 +241,7 @@ private static function checkDisable($option, string $entityId): bool
241241
* This function saves the state, and redirects the user to the page where the user can authorize the release of
242242
* the attributes. If storage is used and the consent has already been given the user is passed on.
243243
*
244-
* @param array &$state The state of the response.
245-
*
244+
* @param array<mixed> &$state The state of the response.
246245
*
247246
* @throws \SimpleSAML\Module\saml\Error\NoPassive if the request was passive and consent is needed.
248247
*/
@@ -282,6 +281,7 @@ public function process(array &$state): void
282281
Stats::log('consent:disabled', $statsData);
283282
return;
284283
}
284+
285285
if (
286286
isset($state['Destination']['consent.disable']) &&
287287
self::checkDisable($state['Destination']['consent.disable'], $idpEntityId)
@@ -416,7 +416,7 @@ public static function getTargetedID(string $userid, string $source, string $des
416416
* Create a hash value for the attributes that changes when attributes are added or removed. If the attribute
417417
* values are included in the hash, the hash will change if the values change.
418418
*
419-
* @param array $attributes The attributes.
419+
* @param array<mixed> $attributes The attributes.
420420
* @param bool $includeValues Whether or not to include the attribute value in the generation of the hash.
421421
*
422422
* @return string SHA1 of the user id, source id, destination id and salt.

src/Consent/Store/Cookie.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,39 +34,40 @@ class Cookie extends \SimpleSAML\Module\consent\Store
3434
/**
3535
* @var string Cookie name prefix
3636
*/
37-
private $name;
37+
private string $name;
3838

3939
/**
4040
* @var int Cookie lifetime
4141
*/
42-
private $lifetime;
42+
private int $lifetime;
4343

4444
/**
4545
* @var string Cookie path
4646
*/
47-
private $path;
47+
private string $path;
4848

4949
/**
5050
* @var string Cookie domain
5151
*/
52-
private $domain = '';
52+
private string $domain = '';
5353

5454
/**
5555
* @var bool Cookie secure flag
5656
*/
57-
private $secure;
57+
private bool $secure;
5858

5959
/**
6060
* @var string|null Cookie samesite flag
6161
*/
62-
private $samesite = null;
62+
private ?string $samesite = null;
63+
6364

6465
/**
6566
* Parse configuration.
6667
*
6768
* This constructor parses the configuration.
6869
*
69-
* @param array $config Configuration for database consent store.
70+
* @param array<mixed> $config Configuration for database consent store.
7071
*
7172
* @throws \Exception in case of a configuration error.
7273
*/
@@ -109,6 +110,7 @@ public function __construct(array $config)
109110
}
110111
}
111112

113+
112114
/**
113115
* Check for consent.
114116
*
@@ -224,7 +226,7 @@ public function deleteAllConsents(string $userId): void
224226
*
225227
* @param string $userId The hash identifying the user at an IdP.
226228
*
227-
* @return array Array of all destination ids the user has given consent for.
229+
* @return array<mixed> Array of all destination ids the user has given consent for.
228230
*/
229231
public function getConsents(string $userId): array
230232
{
@@ -343,7 +345,7 @@ private function setConsentCookie(string $name, ?string $value): bool
343345
'path' => $this->path,
344346
'domain' => $this->domain,
345347
'httponly' => true,
346-
'secure' => $httpUtils->isHTTPS(),
348+
'secure' => $this->secure,
347349
'samesite' => $this->samesite,
348350
];
349351

src/Consent/Store/Database.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ class Database extends \SimpleSAML\Module\consent\Store
4949

5050
/**
5151
* Options for the database;
52+
*
53+
* @var array<mixed>
5254
*/
5355
private array $options = [];
5456

@@ -77,7 +79,7 @@ class Database extends \SimpleSAML\Module\consent\Store
7779
*
7880
* This constructor parses the configuration.
7981
*
80-
* @param array $config Configuration for database consent store.
82+
* @param array<mixed> $config Configuration for database consent store.
8183
*
8284
* @throws \Exception in case of a configuration error.
8385
*/
@@ -139,7 +141,7 @@ public function __construct(array $config)
139141
/**
140142
* Called before serialization.
141143
*
142-
* @return array The variables which should be serialized.
144+
* @return string[] The variables which should be serialized.
143145
*/
144146
public function __sleep(): array
145147
{
@@ -303,7 +305,7 @@ public function deleteAllConsents(string $userId): int
303305
*
304306
* @param string $userId The hash identifying the user at an IdP.
305307
*
306-
* @return array Array of all destination ids the user has given consent for.
308+
* @return string[] Array of all destination ids the user has given consent for.
307309
*/
308310
public function getConsents(string $userId): array
309311
{
@@ -334,16 +336,13 @@ public function getConsents(string $userId): array
334336
* returned.
335337
*
336338
* @param string $statement The statement which should be executed.
337-
* @param array $parameters Parameters for the statement.
339+
* @param array<mixed> $parameters Parameters for the statement.
338340
*
339341
* @return \PDOStatement|false The statement, or false if execution failed.
340342
*/
341343
private function execute(string $statement, array $parameters)
342344
{
343345
$db = $this->getDB();
344-
if ($db === false) {
345-
return false;
346-
}
347346

348347
$st = $db->prepare($statement);
349348
if ($st === false) {
@@ -374,7 +373,7 @@ private function execute(string $statement, array $parameters)
374373
* - users: Total number of uses that have given consent
375374
* ' services: Total number of services that has been given consent to
376375
*
377-
* @return array Array containing the statistics
376+
* @return array<mixed> Array containing the statistics
378377
*/
379378
public function getStatistics(): array
380379
{
@@ -427,9 +426,9 @@ public function getStatistics(): array
427426
/**
428427
* Get database handle.
429428
*
430-
* @return \PDO|false Database handle, or false if we fail to connect.
429+
* @return \PDO Database handle, or false if we fail to connect.
431430
*/
432-
private function getDB()
431+
private function getDB(): PDO
433432
{
434433
if ($this->db !== null) {
435434
return $this->db;
@@ -439,6 +438,7 @@ private function getDB()
439438
if (isset($this->timeout)) {
440439
$driver_options[PDO::ATTR_TIMEOUT] = $this->timeout;
441440
}
441+
442442
if (!empty($this->options)) {
443443
$this->options = array_merge($driver_options, $this->options);
444444
} else {
@@ -456,7 +456,7 @@ private function getDB()
456456
*
457457
* This function formats a PDO error, as returned from errorInfo.
458458
*
459-
* @param array $error The error information.
459+
* @param string[] $error The error information.
460460
*
461461
* @return string Error text.
462462
*/

src/Logout.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Logout
1818
{
1919
/**
2020
* @param \SimpleSAML\IdP $idp
21-
* @param array $state
21+
* @param array<mixed> $state
2222
*/
2323
public static function postLogout(IdP $idp, array $state): void
2424
{

src/Store.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ abstract class Store
2020
*
2121
* This constructor should always be called first in any class which implements this class.
2222
*
23-
* @param array &$config The configuration for this storage handler.
23+
* @param array<mixed> &$config The configuration for this storage handler.
2424
*/
25-
protected function __construct(array &$config)
26-
{
25+
protected function __construct(
26+
protected array &$config) {
2727
}
2828

2929

@@ -108,7 +108,7 @@ public function getStatistics()
108108
*
109109
* @param string $userId The hash identifying the user at an IdP.
110110
*
111-
* @return array Array of all destination ids the user has given consent for.
111+
* @return array<mixed> Array of all destination ids the user has given consent for.
112112
*/
113113
abstract public function getConsents(string $userId): array;
114114

tests/src/Controller/ConsentControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public static function loadState(string $id, string $stage, bool $allowMissing =
9191
'consent:store.destination' => 'urn:some:sp',
9292
'consent:store.attributeSet' => 'some hash',
9393
'consent:store' => new class () extends Cookie {
94-
public function __construct(array &$config = [])
94+
public function __construct()
9595
{
9696
}
9797

0 commit comments

Comments
 (0)