Issues (26)

src/Middleware/Base.php (1 issue)

1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Middleware;
6
7
use App\Exception\AuthException;
8
use Firebase\JWT\JWT;
9
10
abstract class Base
11 32
{
12
    protected function checkToken(string $token): object
13
    {
14 32
        try {
15 1
            return JWT::decode($token, $_SERVER['SECRET_KEY'], ['HS256']);
0 ignored issues
show
The call to Firebase\JWT\JWT::decode() has too many arguments starting with array('HS256'). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

15
            return JWT::/** @scrutinizer ignore-call */ decode($token, $_SERVER['SECRET_KEY'], ['HS256']);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
16 1
        } catch (\UnexpectedValueException) {
17
            throw new AuthException('Forbidden: you are not authorized.', 403);
18
        }
19
    }
20
}
21