From ab5dbebbc077352d87d54d07f8aca8de3fb71750 Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Fri, 7 Aug 2026 14:10:31 +0530 Subject: [PATCH] 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. --- app/init/realtime/connection.php | 2 ++ app/init/resources/request.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/app/init/realtime/connection.php b/app/init/realtime/connection.php index a28b4a35dd..5b44f27946 100644 --- a/app/init/realtime/connection.php +++ b/app/init/realtime/connection.php @@ -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); } } diff --git a/app/init/resources/request.php b/app/init/resources/request.php index a07bd72597..db5d6e2460 100644 --- a/app/init/resources/request.php +++ b/app/init/resources/request.php @@ -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); } }