Skip to content

Commit

Permalink
ENH Add generic types (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli authored Jan 18, 2024
1 parent c1c6be9 commit 94c0603
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/Extensions/MemberExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@

/**
* Augment `Member` to allow relationship to the LoginSession DataObject
*
* @method SilverStripe\ORM\HasManyList<LoginSession> LoginSessions()
*
* @extends DataExtension<Member>
*/
class MemberExtension extends DataExtension
{
Expand Down
4 changes: 4 additions & 0 deletions src/Extensions/QueuedJobDescriptorExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@

use SilverStripe\Core\Extension;
use SilverStripe\SessionManager\Jobs\GarbageCollectionJob;
use Symbiote\QueuedJobs\DataObjects\QueuedJobDescriptor;

/**
* @extends Extension<QueuedJobDescriptor>
*/
class QueuedJobDescriptorExtension extends Extension
{
/**
Expand Down
3 changes: 3 additions & 0 deletions src/Extensions/RememberLoginHashExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<RememberLoginHash>
*/
class RememberLoginHashExtension extends Extension
{
Expand Down
2 changes: 0 additions & 2 deletions src/FormFields/SessionManagerField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/Middleware/LoginSessionMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Models/LoginSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ public function isCurrent(?HTTPRequest $request = null): bool

/**
* @param Member $member
* @return DataList|LoginSession[]
* @return DataList<LoginSession>
*/
public static function getCurrentSessions(Member $member)
{
Expand Down

0 comments on commit 94c0603

Please sign in to comment.