From 94c0603894e9f4c833ae7f8892bafdf2ced0e25a Mon Sep 17 00:00:00 2001 From: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Fri, 19 Jan 2024 10:31:21 +1300 Subject: [PATCH] ENH Add generic types (#177) --- src/Extensions/MemberExtension.php | 3 +++ src/Extensions/QueuedJobDescriptorExtension.php | 4 ++++ src/Extensions/RememberLoginHashExtension.php | 3 +++ src/FormFields/SessionManagerField.php | 2 -- src/Middleware/LoginSessionMiddleware.php | 1 - src/Models/LoginSession.php | 2 +- 6 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Extensions/MemberExtension.php b/src/Extensions/MemberExtension.php index 34e4a9e..9bd9ac8 100644 --- a/src/Extensions/MemberExtension.php +++ b/src/Extensions/MemberExtension.php @@ -10,7 +10,10 @@ /** * Augment `Member` to allow relationship to the LoginSession DataObject + * * @method SilverStripe\ORM\HasManyList LoginSessions() + * + * @extends DataExtension */ class MemberExtension extends DataExtension { diff --git a/src/Extensions/QueuedJobDescriptorExtension.php b/src/Extensions/QueuedJobDescriptorExtension.php index 3e2f479..5bbb82d 100644 --- a/src/Extensions/QueuedJobDescriptorExtension.php +++ b/src/Extensions/QueuedJobDescriptorExtension.php @@ -4,7 +4,11 @@ use SilverStripe\Core\Extension; use SilverStripe\SessionManager\Jobs\GarbageCollectionJob; +use Symbiote\QueuedJobs\DataObjects\QueuedJobDescriptor; +/** + * @extends Extension + */ class QueuedJobDescriptorExtension extends Extension { /** diff --git a/src/Extensions/RememberLoginHashExtension.php b/src/Extensions/RememberLoginHashExtension.php index b72d0cf..5e922f4 100644 --- a/src/Extensions/RememberLoginHashExtension.php +++ b/src/Extensions/RememberLoginHashExtension.php @@ -5,11 +5,14 @@ use SilverStripe\Control\HTTPRequest; use SilverStripe\Core\Extension; use SilverStripe\Core\Injector\Injector; +use SilverStripe\Security\RememberLoginHash; use SilverStripe\SessionManager\Models\LoginSession; use SilverStripe\SessionManager\Security\LogInAuthenticationHandler; /** * @method LoginSession LoginSession() + * + * @extends Extension */ class RememberLoginHashExtension extends Extension { diff --git a/src/FormFields/SessionManagerField.php b/src/FormFields/SessionManagerField.php index 63233f1..be48bd7 100644 --- a/src/FormFields/SessionManagerField.php +++ b/src/FormFields/SessionManagerField.php @@ -102,7 +102,6 @@ public function getSchemaDataDefaults() if (!$this->value && $this->getForm() && $this->getForm()->getRecord() instanceof Member) { $member = $this->getForm()->getRecord(); } else { - /** @var Member $member */ $member = DataObject::get_by_id(Member::class, $this->value); } @@ -122,7 +121,6 @@ protected function getLoginSessions(Member $member) $logOutEndpoint = LoginSessionController::singleton()->Link(); $loginSessions = []; - /** @var LoginSession $loginSession */ foreach (LoginSession::getCurrentSessions($member) as $loginSession) { if (!$loginSession->canView()) { continue; diff --git a/src/Middleware/LoginSessionMiddleware.php b/src/Middleware/LoginSessionMiddleware.php index e2b0e38..e036b95 100644 --- a/src/Middleware/LoginSessionMiddleware.php +++ b/src/Middleware/LoginSessionMiddleware.php @@ -32,7 +32,6 @@ public function process(HTTPRequest $request, callable $delegate) try { $loginSessionID = $request->getSession()->get($loginHandler->getSessionVariable()); - /** @var LoginSession $loginSession */ $loginSession = LoginSession::get_by_id($loginSessionID); // If the session has already been revoked, or we've got a mismatched diff --git a/src/Models/LoginSession.php b/src/Models/LoginSession.php index e8f8665..3900823 100644 --- a/src/Models/LoginSession.php +++ b/src/Models/LoginSession.php @@ -292,7 +292,7 @@ public function isCurrent(?HTTPRequest $request = null): bool /** * @param Member $member - * @return DataList|LoginSession[] + * @return DataList */ public static function getCurrentSessions(Member $member) {