Skip to content

Commit

Permalink
Fix psalm nits, suppress truthy alert
Browse files Browse the repository at this point in the history
  • Loading branch information
paragonie-security committed Apr 19, 2024
1 parent 5078f37 commit b764964
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Keys/Version3/SymmetricKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ class SymmetricKey extends BaseSymmetricKey
public function __construct(
string $keyMaterial
) {
return parent::__construct($keyMaterial, new Version3());
parent::__construct($keyMaterial, new Version3());
}
}
2 changes: 1 addition & 1 deletion src/Keys/Version4/SymmetricKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ class SymmetricKey extends BaseSymmetricKey
public function __construct(
string $keyMaterial
) {
return parent::__construct($keyMaterial, new Version4());
parent::__construct($keyMaterial, new Version4());
}
}
1 change: 1 addition & 0 deletions src/Rules/FooterJSON.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public function isValid(JsonToken $token): bool

/** @var array|bool|null $decoded */
$decoded = json_decode($json, true, $this->maxDepth);
/** @psalm-suppress RiskyTruthyFalsyComparison */
if (!$decoded) {
$this->rejectReason = json_last_error_msg();
}
Expand Down
2 changes: 2 additions & 0 deletions src/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,14 @@ public static function calculateJsonDepth(string $json): int

$previous = '';
$depth = 1;
/** @psalm-suppress RiskyTruthyFalsyComparison */
while (!empty($stripped) && $stripped !== $previous) {
$previous = $stripped;
// Remove pairs of tokens
$stripped = str_replace(['[]', '{}'], [], $stripped);
++$depth;
}
/** @psalm-suppress RiskyTruthyFalsyComparison */
if (!empty($stripped)) {
throw new EncodingException(
'Invalid JSON string provided',
Expand Down

0 comments on commit b764964

Please sign in to comment.