Skip to content

Commit 8570e42

Browse files
committed
General improvements
1 parent 51d7ee4 commit 8570e42

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+583
-128
lines changed

src/SimpleSAML/Auth/ProcessingChain.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@
1414
use SimpleSAML\Utils;
1515
use Symfony\Component\HttpFoundation\Response;
1616

17+
use function array_key_exists;
18+
use function array_shift;
19+
use function array_splice;
20+
use function call_user_func;
21+
use function count;
22+
use function is_array;
23+
use function is_string;
24+
use function str_replace;
25+
use function var_export;
26+
1727
/**
1828
* Class for implementing authentication processing chains for IdPs.
1929
*

src/SimpleSAML/Auth/ProcessingFilter.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
use SimpleSAML\Assert\Assert;
88

9+
use function array_key_exists;
10+
911
/**
1012
* Base class for authentication processing filters.
1113
*
@@ -46,7 +48,7 @@ abstract class ProcessingFilter
4648
* @param array &$config Configuration for this filter.
4749
* @param mixed $reserved For future use.
4850
*/
49-
public function __construct(array &$config, /** @scrutinizer ignore-unused */ $reserved)
51+
public function __construct(array &$config, /** @scrutinizer ignore-unused */ mixed $reserved)
5052
{
5153
if (array_key_exists('%priority', $config)) {
5254
$this->priority = $config['%priority'];

src/SimpleSAML/Auth/Simple.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
1212
use SimpleSAML\Utils;
1313
use Symfony\Component\HttpFoundation\Response;
1414

15+
use function array_key_exists;
16+
use function call_user_func;
17+
use function get_class;
18+
use function is_string;
19+
use function parse_url;
20+
use function trim;
21+
use function urlencode;
22+
1523
/**
1624
* Helper class for simple authentication applications.
1725
*
@@ -186,10 +194,8 @@ public function login(array $params = []): Response
186194
* @param string|array|null $params Either the URL the user should be redirected to after logging out, or an array
187195
* with parameters for the logout. If this parameter is null, we will return to the current page.
188196
*/
189-
public function logout($params = null): Response
197+
public function logout(string|array|null $params = null): Response
190198
{
191-
Assert::true(is_array($params) || is_string($params) || $params === null);
192-
193199
if ($params === null) {
194200
$httpUtils = new Utils\HTTP();
195201
$params = $httpUtils->getSelfURL();

src/SimpleSAML/Auth/Source.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@
1313
use SimpleSAML\Utils;
1414
use Symfony\Component\HttpFoundation\{Request, Response};
1515

16+
use function array_key_exists;
17+
use function array_merge;
18+
use function call_user_func;
19+
use function get_class;
20+
use function is_array;
21+
use function is_string;
22+
use function strlen;
23+
use function var_export;
24+
1625
/**
1726
* This class defines a base class for authentication source.
1827
*
@@ -169,7 +178,7 @@ public static function completeAuth(array &$state): Response
169178
* @param array $params Extra information about the login. Different authentication requestors may provide different
170179
* information. Optional, will default to an empty array.
171180
*/
172-
public function initLogin($return, ?string $errorURL = null, array $params = []): Response
181+
public function initLogin(string|array $return, ?string $errorURL = null, array $params = []): Response
173182
{
174183
Assert::true(is_string($return) || is_array($return));
175184

src/SimpleSAML/Auth/State.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,15 @@
1212
use SimpleSAML\Session;
1313
use SimpleSAML\Utils;
1414

15+
use function array_key_exists;
16+
use function call_user_func;
17+
use function count;
18+
use function explode;
1519
use function filter_var;
1620
use function preg_match;
21+
use function serialize;
22+
use function unserialize;
23+
use function var_export;
1724

1825
/**
1926
* This is a helper class for saving and loading state information.

src/SimpleSAML/Command/RouterDebugCommand.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
use Symfony\Component\Console\Style\SymfonyStyle;
1313
use Symfony\Component\Routing\RouterInterface;
1414

15+
use function get_class;
16+
use function implode;
17+
use function is_object;
18+
1519
class RouterDebugCommand extends Command
1620
{
1721
/**

src/SimpleSAML/Compat/Logger.php

Lines changed: 23 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,19 @@
99
use Psr\Log\LogLevel;
1010
use SimpleSAML\Assert\Assert;
1111
use SimpleSAML\Logger as SspLogger;
12+
use Stringable;
13+
14+
use function var_export;
1215

1316
class Logger implements LoggerInterface
1417
{
1518
/**
1619
* System is unusable.
1720
*
18-
* @param string $message
21+
* @param string|\Stringable $message
1922
* @param array $context
20-
*
21-
* Type hint not possible due to upstream method signature
2223
*/
23-
public function emergency($message, array $context = []): void
24+
public function emergency(string|Stringable $message, array $context = []): void
2425
{
2526
SspLogger::emergency($message . ($context ? " " . var_export($context, true) : ""));
2627
}
@@ -32,12 +33,10 @@ public function emergency($message, array $context = []): void
3233
* Example: Entire website down, database unavailable, etc. This should
3334
* trigger the SMS alerts and wake you up.
3435
*
35-
* @param string $message
36+
* @param string|\Stringable $message
3637
* @param array $context
37-
*
38-
* Type hint not possible due to upstream method signature
3938
*/
40-
public function alert($message, array $context = []): void
39+
public function alert(string|Stringable $message, array $context = []): void
4140
{
4241
SspLogger::alert($message . ($context ? " " . var_export($context, true) : ""));
4342
}
@@ -48,12 +47,10 @@ public function alert($message, array $context = []): void
4847
*
4948
* Example: Application component unavailable, unexpected exception.
5049
*
51-
* @param string $message
50+
* @param string|\Stringable $message
5251
* @param array $context
53-
*
54-
* Type hint not possible due to upstream method signature
5552
*/
56-
public function critical($message, array $context = []): void
53+
public function critical(string|Stringable $message, array $context = []): void
5754
{
5855
SspLogger::critical($message . ($context ? " " . var_export($context, true) : ""));
5956
}
@@ -63,12 +60,10 @@ public function critical($message, array $context = []): void
6360
* Runtime errors that do not require immediate action but should typically
6461
* be logged and monitored.
6562
*
66-
* @param string $message
63+
* @param string|\Stringable $message
6764
* @param array $context
68-
*
69-
* Type hint not possible due to upstream method signature
7065
*/
71-
public function error($message, array $context = []): void
66+
public function error(string|Stringable $message, array $context = []): void
7267
{
7368
SspLogger::error($message . ($context ? " " . var_export($context, true) : ""));
7469
}
@@ -80,12 +75,10 @@ public function error($message, array $context = []): void
8075
* Example: Use of deprecated APIs, poor use of an API, undesirable things
8176
* that are not necessarily wrong.
8277
*
83-
* @param string $message
78+
* @param string|\Stringable $message
8479
* @param array $context
85-
*
86-
* Type hint not possible due to upstream method signature
8780
*/
88-
public function warning($message, array $context = []): void
81+
public function warning(string|Stringable $message, array $context = []): void
8982
{
9083
SspLogger::warning($message . ($context ? " " . var_export($context, true) : ""));
9184
}
@@ -94,12 +87,10 @@ public function warning($message, array $context = []): void
9487
/**
9588
* Normal but significant events.
9689
*
97-
* @param string $message
90+
* @param string|\Stringable $message
9891
* @param array $context
99-
*
100-
* Type hint not possible due to upstream method signature
10192
*/
102-
public function notice($message, array $context = []): void
93+
public function notice(string|Stringable $message, array $context = []): void
10394
{
10495
SspLogger::notice($message . ($context ? " " . var_export($context, true) : ""));
10596
}
@@ -110,12 +101,10 @@ public function notice($message, array $context = []): void
110101
*
111102
* Example: User logs in, SQL logs.
112103
*
113-
* @param string $message
104+
* @param string|\Stringable $message
114105
* @param array $context
115-
*
116-
* Type hint not possible due to upstream method signature
117106
*/
118-
public function info($message, array $context = []): void
107+
public function info(string|Stringable $message, array $context = []): void
119108
{
120109
SspLogger::info($message . ($context ? " " . var_export($context, true) : ""));
121110
}
@@ -124,12 +113,10 @@ public function info($message, array $context = []): void
124113
/**
125114
* Detailed debug information.
126115
*
127-
* @param string $message
116+
* @param string|\Stringable $message
128117
* @param array $context
129-
*
130-
* Type hint not possible due to upstream method signature
131118
*/
132-
public function debug($message, array $context = []): void
119+
public function debug(string|Stringable $message, array $context = []): void
133120
{
134121
SspLogger::debug($message . ($context ? " " . var_export($context, true) : ""));
135122
}
@@ -139,19 +126,16 @@ public function debug($message, array $context = []): void
139126
* Logs with an arbitrary level.
140127
*
141128
* @param mixed $level
142-
* @param string $message
129+
* @param string|\Stringable $message
143130
* @param array $context
144131
*
145132
* @throws \SimpleSAML\Assert\AssertionFailedException if assertions are false
146-
*
147-
* Type hint not possible due to upstream method signature
148133
*/
149-
public function log($level, $message, array $context = []): void
134+
public function log($level, string|Stringable $message, array $context = []): void
150135
{
151-
Assert::string($message);
152-
153136
switch ($level) {
154-
/* From PSR: Calling this method with one of the log level constants
137+
/**
138+
* From PSR: Calling this method with one of the log level constants
155139
* MUST have the same result as calling the level-specific method
156140
*/
157141
case LogLevel::ALERT:

src/SimpleSAML/Database.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
use PDOStatement;
1111
use SimpleSAML\Logger;
1212

13+
use function count;
14+
use function is_array;
15+
use function rand;
16+
use function sha1;
17+
use function serialize;
18+
1319
/**
1420
* This file implements functions to read and write to a group of database servers.
1521
*

src/SimpleSAML/Error/BadRequest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ class BadRequest extends Error
3131
*/
3232
public function __construct(string $reason)
3333
{
34+
parent::__construct(['BADREQUEST', '%REASON%' => $reason]);
35+
3436
$this->reason = $reason;
35-
parent::__construct(['BADREQUEST', '%REASON%' => $this->reason]);
3637
$this->httpCode = 400;
3738
}
3839

src/SimpleSAML/Error/ConfigurationError.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
namespace SimpleSAML\Error;
66

7+
use function dirname;
8+
use function str_replace;
9+
710
/**
811
* This exception represents a configuration error.
912
*

0 commit comments

Comments
 (0)