Skip to content

Commit

Permalink
Fix psalm issues
Browse files Browse the repository at this point in the history
  • Loading branch information
kelunik committed Aug 20, 2023
1 parent c0745b9 commit bac8c10
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,11 @@
<directory name="src" />
</errorLevel>
</MissingClosureReturnType>

<StringIncrement>
<errorLevel type="suppress">
<directory name="src" />
</errorLevel>
</StringIncrement>
</issueHandlers>
</psalm>
3 changes: 2 additions & 1 deletion src/Base64UrlSessionIdGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ final class Base64UrlSessionIdGenerator implements SessionIdGenerator

public function __construct(int $length = 48)
{
if ($length < 0 || $length % 4 !== 0) {
if ($length <= 0 || $length % 4 !== 0) {
throw new \Error('Invalid length (' . $length . '), must be divisible by four');
}

// divisible by four to not waste chars with "=" and simplify regexp.
/** @psalm-suppress PropertyTypeCoercion */
$this->bytes = (int) ($length / 4 * 3);
$this->regex = '/^[A-Za-z0-9_\-]{' . $length . '}$/';

Expand Down

0 comments on commit bac8c10

Please sign in to comment.