Closed
Description
The decode method declares an object return type using docblock, however this is not enforced by either userland runtime checks or a PHP return type, and the function will quite happily return a non-object result if the original JWT was created in such a way:
public function testDecodeNonObject(): void {
$key = 'example';
$token = JWT::encode(123, $key, 'HS256');
$decoded = JWT::decode($token, $key, ['HS256']);
self::assertIsObject($decoded);
}
This causes higher levels of static analysis to either fail to detect a possible error condition when using the return value, or alternatively create a false positive for a redundant check when verifying the return type is an object.
Metadata
Metadata
Assignees
Labels
No labels