Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH Add generic types #177

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
ENH Add generic types
GuySartorelli committed Jan 12, 2024
commit f3f07f6793a1a58cc6629f56fea87955dda58bff
3 changes: 3 additions & 0 deletions src/Extensions/MemberExtension.php
Original file line number Diff line number Diff line change
@@ -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
{
4 changes: 4 additions & 0 deletions src/Extensions/QueuedJobDescriptorExtension.php
Original file line number Diff line number Diff line change
@@ -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
{
/**
3 changes: 3 additions & 0 deletions src/Extensions/RememberLoginHashExtension.php
Original file line number Diff line number Diff line change
@@ -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
{
2 changes: 0 additions & 2 deletions src/FormFields/SessionManagerField.php
Original file line number Diff line number Diff line change
@@ -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;
1 change: 0 additions & 1 deletion src/Middleware/LoginSessionMiddleware.php
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/Models/LoginSession.php
Original file line number Diff line number Diff line change
@@ -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)
{