Skip to content

Commit

Permalink
chore: upgraded to PHPStan v2 and Rector v2
Browse files Browse the repository at this point in the history
  • Loading branch information
thorsten committed Jan 8, 2025
1 parent 6012d5b commit 6057de2
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 66 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@
"mikey179/vfsstream": "^1.6",
"phpdocumentor/reflection-docblock": "5.*",
"phpmd/phpmd": "@stable",
"phpstan/phpstan": "^1.0.0",
"phpstan/phpstan": "^2",
"phpunit/phpunit": "11.*",
"rector/rector": "^1.0.0",
"rector/rector": "^2",
"squizlabs/php_codesniffer": "3.*",
"symfony/yaml": "7.*",
"zircote/swagger-php": "^4.8"
Expand Down
117 changes: 60 additions & 57 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion phpmyfaq/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
// Validating token from 2FA if given; else: returns error message
//
if ($token !== '' && !is_null($userId)) {
if (strlen((string)$token) === 6 && is_numeric((string)$token)) {
if (strlen($token) === 6 && is_numeric((string)$token)) {
$user = new CurrentUser($faqConfig);
$user->getUserById($userId);
$tfa = new TwoFactor($faqConfig, $user);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public function check(Request $request): Response
return new RedirectResponse('./');
}

$token = Filter::filterVar($request->get('token'), FILTER_VALIDATE_INT);
$token = Filter::filterVar($request->get('token'), FILTER_SANITIZE_SPECIAL_CHARS);
$userId = Filter::filterVar($request->get('user-id'), FILTER_VALIDATE_INT);

$user = $this->container->get('phpmyfaq.user.current_user');
Expand Down
2 changes: 1 addition & 1 deletion phpmyfaq/src/phpMyFAQ/User/CurrentUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ public static function getCurrentUserGroupId(?CurrentUser $user = null): array
$currentGroups = [-1];
}

if (0 === (is_countable($currentGroups) ? count($currentGroups) : 0)) {
if (count($currentGroups)) {
$currentGroups = [-1];
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions phpmyfaq/src/phpMyFAQ/User/TwoFactor.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ public function getSecret(CurrentUser $currentUser): string|null
/**
* Validates a given token. Returns true if the token is correct.
*/
public function validateToken(int $token, int $userId): bool
public function validateToken(string $token, int $userId): bool
{
if (strlen((string)$token) !== 6) {
if (strlen($token) !== 6) {
return false;
}

Expand Down
Loading

0 comments on commit 6057de2

Please sign in to comment.