Skip to content

Commit 2c0a439

Browse files
committed
Fix remaining Psalm-issues
1 parent 48a0f1f commit 2c0a439

6 files changed

Lines changed: 21 additions & 24 deletions

File tree

psalm.xml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,20 @@
2323
</projectFiles>
2424

2525
<issueHandlers>
26-
<!-- Ignore UnresolvableInclude on CLI-scripts -->
27-
<UnresolvableInclude>
28-
<errorLevel type="suppress">
29-
<file name="tests/bootstrap.php" />
30-
</errorLevel>
31-
</UnresolvableInclude>
26+
<!-- Ignore InvalidClassConstantType -->
3227
<InvalidClassConstantType>
3328
<errorLevel type="suppress">
3429
<file name="src/Forms/Controls/CsrfProtection.php" />
3530
</errorLevel>
3631
</InvalidClassConstantType>
3732

33+
<!-- Ignore PossiblyFalseArgument -->
34+
<PossiblyFalseArgument>
35+
<errorLevel type="suppress">
36+
<file name="src/Server/Validators/BearerTokenValidator.php" />
37+
</errorLevel>
38+
</PossiblyFalseArgument>
39+
3840
<!-- Ignore errors related to unused classes, methods... -->
3941
<UnusedClass errorLevel="suppress" />
4042
<PossiblyUnusedMethod errorLevel="suppress" />

src/Forms/Controls/CsrfProtection.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public function __construct(string|Stringable|null $errorMessage, protected Sess
3939
{
4040
// Instead of calling CsrfProtection parent class constructor, go to it's parent (HiddenField), and call
4141
// its constructor. This is to avoid setting a Nette session in CsrfProtection parent, and use the SSP one.
42+
/** @psalm-suppress PossiblyFalseArgument */
4243
$hiddentFieldParent = get_parent_class(get_parent_class($this));
4344

4445
if (!is_string($hiddentFieldParent)) {

src/Helpers/Str.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public function convertScopesStringToArray(string $scopes, string $delimiter = '
2323
*/
2424
public function convertTextToArray(string $text, string $pattern = "/[\t\r\n]+/"): array
2525
{
26+
/** @psalm-suppress PossiblyFalseArgument */
2627
return array_filter(
2728
preg_split($pattern, $text),
2829
fn(string $line): bool => !empty(trim($line)),

src/Server/Validators/BearerTokenValidator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use SimpleSAML\Module\oidc\Server\Exceptions\OidcServerException;
2222
use SimpleSAML\Module\oidc\Services\LoggerService;
2323

24+
use function apache_request_headers;
2425
use function count;
2526
use function date_default_timezone_get;
2627
use function is_array;

src/Services/LoggerService.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,42 +14,42 @@ class LoggerService implements LoggerInterface
1414
{
1515
public function emergency(string|Stringable $message, array $context = []): void
1616
{
17-
Logger::emergency($message . ($context ? " " . var_export($context, true) : ""));
17+
Logger::emergency((string)$message . ($context ? " " . var_export($context, true) : ""));
1818
}
1919

2020
public function alert(string|Stringable $message, array $context = []): void
2121
{
22-
Logger::alert($message . ($context ? " " . var_export($context, true) : ""));
22+
Logger::alert((string)$message . ($context ? " " . var_export($context, true) : ""));
2323
}
2424

2525
public function critical(string|Stringable $message, array $context = []): void
2626
{
27-
Logger::critical($message . ($context ? " " . var_export($context, true) : ""));
27+
Logger::critical((string)$message . ($context ? " " . var_export($context, true) : ""));
2828
}
2929

3030
public function error(string|Stringable $message, array $context = []): void
3131
{
32-
Logger::error($message . ($context ? " " . var_export($context, true) : ""));
32+
Logger::error((string)$message . ($context ? " " . var_export($context, true) : ""));
3333
}
3434

3535
public function warning(string|Stringable $message, array $context = []): void
3636
{
37-
Logger::warning($message . ($context ? " " . var_export($context, true) : ""));
37+
Logger::warning((string)$message . ($context ? " " . var_export($context, true) : ""));
3838
}
3939

4040
public function notice(string|Stringable $message, array $context = []): void
4141
{
42-
Logger::notice($message . ($context ? " " . var_export($context, true) : ""));
42+
Logger::notice((string)$message . ($context ? " " . var_export($context, true) : ""));
4343
}
4444

4545
public function info(string|Stringable $message, array $context = []): void
4646
{
47-
Logger::info($message . ($context ? " " . var_export($context, true) : ""));
47+
Logger::info((string)$message . ($context ? " " . var_export($context, true) : ""));
4848
}
4949

5050
public function debug(string|Stringable $message, array $context = []): void
5151
{
52-
Logger::debug($message . ($context ? " " . var_export($context, true) : ""));
52+
Logger::debug((string)$message . ($context ? " " . var_export($context, true) : ""));
5353
}
5454

5555
public function log(mixed $level, string|Stringable $message, array $context = []): void

src/Utils/FingerprintGenerator.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static function forFile(string $path, string $algo = 'md5'): string
2121
{
2222
$fingerprint = hash_file($algo, $path);
2323

24-
if (false === (bool) $fingerprint) {
24+
if (false === $fingerprint) {
2525
throw new InvalidArgumentException(
2626
'Could not create a fingerprint for provided file using provided algorithm.',
2727
);
@@ -41,14 +41,6 @@ public static function forFile(string $path, string $algo = 'md5'): string
4141
*/
4242
public static function forString(string $content, string $algo = 'md5'): string
4343
{
44-
$fingerprint = hash($algo, $content);
45-
46-
if (false === (bool) $fingerprint) {
47-
throw new InvalidArgumentException(
48-
'Could not create a fingerprint for provided content using provided algorithm.',
49-
);
50-
}
51-
52-
return $fingerprint;
44+
return hash($algo, $content);
5345
}
5446
}

0 commit comments

Comments
 (0)