Annotate JWT user lookups as User for static analysis

getDocument() is declared as returning Document, so the sessionActive()
calls in the JWT auth paths tripped PHPStan's method.notFound. The users
collection is mapped to User via setDocumentType(), matching the
annotations already on the cookie-path lookups above.
This commit is contained in:
harsh mahajan committed 2026-08-07 14:10:31 +05:30
1 parent 695f0ad4b5
commit ab5dbebbc0
2 files changed
+4

No files matched your search

+2
View File
@@ -288,8 +288,10 @@ return function (Container $container): void {
$jwtUserId = $payload['userId'] ?? '';
if (!empty($jwtUserId)) {
if ($mode === APP_MODE_ADMIN) {
/** @var User $user */
$user = $dbForPlatform->getDocument('users', $jwtUserId);
} else {
/** @var User $user */
$user = $dbForProject->getDocument('users', $jwtUserId);
}
}
+2
View File
@@ -536,8 +536,10 @@ return function (Container $context): void {
$jwtUserId = $payload['userId'] ?? '';
if (! empty($jwtUserId)) {
if ($mode === APP_MODE_ADMIN) {
/** @var User $user */
$user = $dbForPlatform->getDocument('users', $jwtUserId);
} else {
/** @var User $user */
$user = $dbForProject->getDocument('users', $jwtUserId);
}
}