diff --git a/src/Lti1p1Key.php b/src/Lti1p1Key.php index 7bd5026e..b67a699d 100644 --- a/src/Lti1p1Key.php +++ b/src/Lti1p1Key.php @@ -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; diff --git a/src/LtiAbstractService.php b/src/LtiAbstractService.php index 0f33d3ad..8f08dcfa 100644 --- a/src/LtiAbstractService.php +++ b/src/LtiAbstractService.php @@ -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, diff --git a/src/LtiAssignmentsGradesService.php b/src/LtiAssignmentsGradesService.php index 52035ecb..9700684e 100644 --- a/src/LtiAssignmentsGradesService.php +++ b/src/LtiAssignmentsGradesService.php @@ -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]); @@ -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'); @@ -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. diff --git a/src/LtiDeepLinkDateTimeInterval.php b/src/LtiDeepLinkDateTimeInterval.php index b26c6687..8639c4aa 100644 --- a/src/LtiDeepLinkDateTimeInterval.php +++ b/src/LtiDeepLinkDateTimeInterval.php @@ -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'); diff --git a/src/LtiDeepLinkResourceIframe.php b/src/LtiDeepLinkResourceIframe.php index 3346c31a..de60ec3f 100644 --- a/src/LtiDeepLinkResourceIframe.php +++ b/src/LtiDeepLinkResourceIframe.php @@ -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; diff --git a/src/LtiDeepLinkResourceWindow.php b/src/LtiDeepLinkResourceWindow.php index 323d706c..194f32a7 100644 --- a/src/LtiDeepLinkResourceWindow.php +++ b/src/LtiDeepLinkResourceWindow.php @@ -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; diff --git a/src/LtiGrade.php b/src/LtiGrade.php index bca75be8..d3f0e18a 100644 --- a/src/LtiGrade.php +++ b/src/LtiGrade.php @@ -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; diff --git a/src/LtiGradeSubmissionReview.php b/src/LtiGradeSubmissionReview.php index a185930f..335590a7 100644 --- a/src/LtiGradeSubmissionReview.php +++ b/src/LtiGradeSubmissionReview.php @@ -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; diff --git a/src/LtiLineitem.php b/src/LtiLineitem.php index 9492c1a6..4223dedc 100644 --- a/src/LtiLineitem.php +++ b/src/LtiLineitem.php @@ -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; diff --git a/src/LtiMessageLaunch.php b/src/LtiMessageLaunch.php index 2f15c69e..d2e00a7e 100644 --- a/src/LtiMessageLaunch.php +++ b/src/LtiMessageLaunch.php @@ -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; @@ -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); } @@ -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); @@ -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)) { @@ -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)) { diff --git a/src/LtiOidcLogin.php b/src/LtiOidcLogin.php index f6582107..5c1d7048 100644 --- a/src/LtiOidcLogin.php +++ b/src/LtiOidcLogin.php @@ -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; @@ -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); } @@ -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) { diff --git a/src/LtiServiceConnector.php b/src/LtiServiceConnector.php index 9cff50d3..16bb9478 100644 --- a/src/LtiServiceConnector.php +++ b/src/LtiServiceConnector.php @@ -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.'); diff --git a/src/Redirect.php b/src/Redirect.php index f90f6961..fa4ba87a 100644 --- a/src/Redirect.php +++ b/src/Redirect.php @@ -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; diff --git a/tests/Certification/Lti13CertificationTest.php b/tests/Certification/Lti13CertificationTest.php index 3c094727..14575d83 100644 --- a/tests/Certification/Lti13CertificationTest.php +++ b/tests/Certification/Lti13CertificationTest.php @@ -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;