From ad0badc09e7eb16876b3cec7a8ffadc9f0cb7317 Mon Sep 17 00:00:00 2001 From: Alex Cabal Date: Mon, 8 Jan 2024 16:41:44 -0600 Subject: [PATCH] Type hinting fixes --- lib/Contributor.php | 10 +++++----- lib/Image.php | 2 +- lib/Museum.php | 2 +- lib/NewsletterSubscription.php | 6 +++--- lib/OpdsNavigationEntry.php | 2 +- lib/Patron.php | 2 +- lib/User.php | 6 +++--- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/Contributor.php b/lib/Contributor.php index 6748861b..21395138 100644 --- a/lib/Contributor.php +++ b/lib/Contributor.php @@ -2,11 +2,11 @@ class Contributor{ public string $Name; public string $UrlName; - public ?string $SortName; - public ?string $WikipediaUrl; - public ?string $MarcRole; - public ?string $FullName; - public ?string $NacoafUrl; + public ?string $SortName = null; + public ?string $WikipediaUrl = null; + public ?string $MarcRole = null; + public ?string $FullName = null; + public ?string $NacoafUrl = null; public function __construct(string $name, string $sortName = null, string $fullName = null, string $wikipediaUrl = null, string $marcRole = null, string $nacoafUrl = null){ $this->Name = str_replace('\'', '’', $name); diff --git a/lib/Image.php b/lib/Image.php index 1b233879..ead93714 100644 --- a/lib/Image.php +++ b/lib/Image.php @@ -8,7 +8,7 @@ use function Safe\unlink; class Image{ public string $Path; - public ?ImageMimeType $MimeType; + public ?ImageMimeType $MimeType = null; public function __construct(string $path){ $this->Path = $path; diff --git a/lib/Museum.php b/lib/Museum.php index 9c6465b1..ded204a6 100644 --- a/lib/Museum.php +++ b/lib/Museum.php @@ -16,7 +16,7 @@ class Museum extends PropertiesBase{ limit 1; ', [$url], 'Museum'); - if(sizeof($result[0]) == 0){ + if(sizeof($result) == 0){ throw new Exceptions\MuseumNotFoundException(); } diff --git a/lib/NewsletterSubscription.php b/lib/NewsletterSubscription.php index cf9f7059..2690a997 100644 --- a/lib/NewsletterSubscription.php +++ b/lib/NewsletterSubscription.php @@ -7,9 +7,9 @@ use Safe\DateTime; */ class NewsletterSubscription extends PropertiesBase{ public bool $IsConfirmed = false; - public bool $IsSubscribedToSummary; - public bool $IsSubscribedToNewsletter; - public int $UserId; + public bool $IsSubscribedToSummary = false; + public bool $IsSubscribedToNewsletter = false; + public ?int $UserId = null; public DateTime $Created; protected $_User; protected $_Url = null; diff --git a/lib/OpdsNavigationEntry.php b/lib/OpdsNavigationEntry.php index eb409dc3..4f671c4c 100644 --- a/lib/OpdsNavigationEntry.php +++ b/lib/OpdsNavigationEntry.php @@ -4,7 +4,7 @@ class OpdsNavigationEntry{ public string $Url; public string $Rel; public string $Type; - public ?DateTime $Updated; + public ?DateTime $Updated = null; public string $Description; public string $Title; public string $SortTitle; diff --git a/lib/Patron.php b/lib/Patron.php index 756b575c..52db4a30 100644 --- a/lib/Patron.php +++ b/lib/Patron.php @@ -8,7 +8,7 @@ class Patron extends PropertiesBase{ public ?int $UserId = null; protected $_User = null; public bool $IsAnonymous; - public ?string $AlternateName; + public ?string $AlternateName = null; public bool $IsSubscribedToEmails; public ?DateTime $Created = null; public ?DateTime $Ended = null; diff --git a/lib/User.php b/lib/User.php index 354b1032..dfba00f8 100644 --- a/lib/User.php +++ b/lib/User.php @@ -10,11 +10,11 @@ use Safe\DateTime; */ class User extends PropertiesBase{ public int $UserId; - public ?string $Name; - public ?string $Email; + public ?string $Name = null; + public ?string $Email = null; public DateTime $Created; public string $Uuid; - public ?string $PasswordHash; + public ?string $PasswordHash = null; protected ?bool $_IsRegistered = null; protected $_Payments = null; protected ?Benefits $_Benefits = null;