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

Update linting #115

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/Lti1p1Key.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Lti1p1Key
private $key;
private $secret;

public function __construct(array $key = null)
public function __construct(?array $key = null)
{
$this->key = $key['key'] ?? null;
$this->secret = $key['secret'] ?? null;
Expand Down
2 changes: 1 addition & 1 deletion src/LtiAbstractService.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected function makeServiceRequest(IServiceRequest $request): array
);
}

protected function getAll(IServiceRequest $request, string $key = null): array
protected function getAll(IServiceRequest $request, ?string $key = null): array
{
return $this->serviceConnector->getAll(
$this->registration,
Expand Down
6 changes: 3 additions & 3 deletions src/LtiAssignmentsGradesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function getResourceLaunchLineItem(): ?LtiLineitem
return LtiLineitem::new()->setId($serviceData['lineitem']);
}

public function putGrade(LtiGrade $grade, LtiLineitem $lineitem = null)
public function putGrade(LtiGrade $grade, ?LtiLineitem $lineitem = null)
{
$this->validateScopes([LtiConstants::AGS_SCOPE_SCORE]);

Expand Down Expand Up @@ -107,7 +107,7 @@ public function findOrCreateLineitem(LtiLineitem $newLineItem): LtiLineitem
return $this->findLineItem($newLineItem) ?? $this->createLineitem($newLineItem);
}

public function getGrades(LtiLineitem $lineitem = null)
public function getGrades(?LtiLineitem $lineitem = null)
{
$lineitem = $this->ensureLineItemExists($lineitem);
$resultsUrl = $this->appendLineItemPath($lineitem, '/results');
Expand Down Expand Up @@ -159,7 +159,7 @@ public function getLineItem(string $url): LtiLineitem
return new LtiLineitem($response);
}

private function ensureLineItemExists(LtiLineitem $lineitem = null): LtiLineitem
private function ensureLineItemExists(?LtiLineitem $lineitem = null): LtiLineitem
{
// If no line item is passed in, attempt to use the one associated with
// this launch.
Expand Down
2 changes: 1 addition & 1 deletion src/LtiDeepLinkDateTimeInterval.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class LtiDeepLinkDateTimeInterval
private ?DateTime $start;
private ?DateTime $end;

public function __construct(DateTime $start = null, DateTime $end = null)
public function __construct(?DateTime $start = null, ?DateTime $end = null)
{
if ($start !== null && $end !== null && $end < $start) {
throw new LtiException('Interval start time cannot be greater than end time');
Expand Down
2 changes: 1 addition & 1 deletion src/LtiDeepLinkResourceIframe.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class LtiDeepLinkResourceIframe
private ?int $height;
private ?string $src;

public function __construct(int $width = null, int $height = null, string $src = null)
public function __construct(?int $width = null, ?int $height = null, ?string $src = null)
{
$this->width = $width ?? null;
$this->height = $height ?? null;
Expand Down
2 changes: 1 addition & 1 deletion src/LtiDeepLinkResourceWindow.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class LtiDeepLinkResourceWindow
private ?int $height;
private ?string $window_features;

public function __construct(string $targetName = null, int $width = null, int $height = null, string $windowFeatures = null)
public function __construct(?string $targetName = null, ?int $width = null, ?int $height = null, ?string $windowFeatures = null)
{
$this->target_name = $targetName ?? null;
$this->width = $width ?? null;
Expand Down
2 changes: 1 addition & 1 deletion src/LtiGrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class LtiGrade
private $submission_review;
private $canvas_extension;

public function __construct(array $grade = null)
public function __construct(?array $grade = null)
{
$this->score_given = $grade['scoreGiven'] ?? null;
$this->score_maximum = $grade['scoreMaximum'] ?? null;
Expand Down
2 changes: 1 addition & 1 deletion src/LtiGradeSubmissionReview.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class LtiGradeSubmissionReview
private $url;
private $custom;

public function __construct(array $gradeSubmission = null)
public function __construct(?array $gradeSubmission = null)
{
$this->reviewable_status = $gradeSubmission['reviewableStatus'] ?? null;
$this->label = $gradeSubmission['label'] ?? null;
Expand Down
2 changes: 1 addition & 1 deletion src/LtiLineitem.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class LtiLineitem
private $end_date_time;
private ?bool $grades_released;

public function __construct(array $lineitem = null)
public function __construct(?array $lineitem = null)
{
$this->id = $lineitem['id'] ?? null;
$this->score_maximum = $lineitem['scoreMaximum'] ?? null;
Expand Down
20 changes: 10 additions & 10 deletions src/LtiMessageLaunch.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ class LtiMessageLaunch
*/
public function __construct(
IDatabase $database,
ICache $cache = null,
ICookie $cookie = null,
ILtiServiceConnector $serviceConnector = null
?ICache $cache = null,
?ICookie $cookie = null,
?ILtiServiceConnector $serviceConnector = null
) {
$this->db = $database;

Expand All @@ -98,9 +98,9 @@ public function __construct(
*/
public static function new(
IDatabase $database,
ICache $cache = null,
ICookie $cookie = null,
ILtiServiceConnector $serviceConnector = null
?ICache $cache = null,
?ICookie $cookie = null,
?ILtiServiceConnector $serviceConnector = null
) {
return new LtiMessageLaunch($database, $cache, $cookie, $serviceConnector);
}
Expand All @@ -118,8 +118,8 @@ public static function new(
public static function fromCache(
$launch_id,
IDatabase $database,
ICache $cache = null,
ILtiServiceConnector $serviceConnector = null
?ICache $cache = null,
?ILtiServiceConnector $serviceConnector = null
) {
// @todo: Fix the null here on the next major version
$new = new LtiMessageLaunch($database, $cache, null, $serviceConnector);
Expand Down Expand Up @@ -153,7 +153,7 @@ public function initialize(array $request)
*
* @throws LtiException Will throw an LtiException if validation fails
*/
public function validate(array $request = null)
public function validate(?array $request = null)
{
// @TODO: Remove this on the next major release.
if (!isset($this->request)) {
Expand Down Expand Up @@ -337,7 +337,7 @@ public function getLaunchId()
return $this->launch_id;
}

public static function getMissingRegistrationErrorMsg(string $issuerUrl, string $clientId = null): string
public static function getMissingRegistrationErrorMsg(string $issuerUrl, ?string $clientId = null): string
{
// Guard against client ID being null
if (!isset($clientId)) {
Expand Down
6 changes: 3 additions & 3 deletions src/LtiOidcLogin.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class LtiOidcLogin
* @param ICache $cache instance of the Cache interface used to loading and storing launches
* @param ICookie $cookie instance of the Cookie interface used to set and read cookies
*/
public function __construct(IDatabase $database, ICache $cache = null, ICookie $cookie = null)
public function __construct(IDatabase $database, ?ICache $cache = null, ?ICookie $cookie = null)
{
$this->db = $database;
$this->cache = $cache;
Expand All @@ -34,7 +34,7 @@ public function __construct(IDatabase $database, ICache $cache = null, ICookie $
/**
* Static function to allow for method chaining without having to assign to a variable first.
*/
public static function new(IDatabase $database, ICache $cache = null, ICookie $cookie = null)
public static function new(IDatabase $database, ?ICache $cache = null, ?ICookie $cookie = null)
{
return new LtiOidcLogin($database, $cache, $cookie);
}
Expand All @@ -46,7 +46,7 @@ public static function new(IDatabase $database, ICache $cache = null, ICookie $c
* @param array $request An array of request parameters. If not set will default to $_REQUEST.
* @return Redirect returns a redirect object containing the fully formed OIDC login URL
*/
public function doOidcLoginRedirect($launchUrl, array $request = null)
public function doOidcLoginRedirect($launchUrl, ?array $request = null)
{
// @todo remove this in v6.0
if ($request === null) {
Expand Down
2 changes: 1 addition & 1 deletion src/LtiServiceConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public function getAll(
ILtiRegistration $registration,
array $scopes,
IServiceRequest $request,
string $key = null
?string $key = null
): array {
if ($request->getMethod() !== ServiceRequest::METHOD_GET) {
throw new Exception('An invalid method was specified by an LTI service requesting all items.');
Expand Down
2 changes: 1 addition & 1 deletion src/Redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Redirect
private $referer_query;
private static $CAN_302_COOKIE = 'LTI_302_Redirect';

public function __construct(string $location, string $referer_query = null)
public function __construct(string $location, ?string $referer_query = null)
{
$this->location = $location;
$this->referer_query = $referer_query;
Expand Down
2 changes: 1 addition & 1 deletion tests/Certification/Lti13CertificationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ public function testValidCertificationCases()
$this->assertEquals($casesCount, $testedCases);
}

private function launch($payload, IDatabase $db = null)
private function launch($payload, ?IDatabase $db = null)
{
$db = $db ?? $this->db;

Expand Down