diff --git a/config/phpstan/phpstan.neon b/config/phpstan/phpstan.neon index f2612e52..5322d5df 100644 --- a/config/phpstan/phpstan.neon +++ b/config/phpstan/phpstan.neon @@ -7,12 +7,6 @@ parameters: ignoreErrors: # Ignore errors caused by Template static class reflection - '#Call to an undefined static method Template::[a-zA-Z0-9\\_]+\(\)\.#' - - # Ignore errors caused by no type hints on class properties, as that's not available till PHP 7.4 - - '#Property .+? has no type specified.#' - - # Ignore setters for properties that accept several types - - '#Property Artwork::\$Tags \(array\) does not accept.+#' level: 8 paths: diff --git a/config/sql/se/PollVotes.sql b/config/sql/se/PollVotes.sql index fd2229ad..d57736db 100644 --- a/config/sql/se/PollVotes.sql +++ b/config/sql/se/PollVotes.sql @@ -1,6 +1,6 @@ CREATE TABLE `PollVotes` ( `UserId` int(10) unsigned NOT NULL, `PollItemId` int(10) unsigned NOT NULL, - `Created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `Created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY `idxUnique` (`PollItemId`,`UserId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; diff --git a/lib/Artist.php b/lib/Artist.php index 904f73f1..a276826d 100644 --- a/lib/Artist.php +++ b/lib/Artist.php @@ -8,20 +8,18 @@ use Safe\DateTimeImmutable; * @property ?array $AlternateNames */ class Artist{ - /** - * @var array $_AlternateNames - */ - use Traits\Accessor; public ?int $ArtistId = null; public ?string $Name = null; public ?DateTimeImmutable $Created = null; public ?DateTimeImmutable $Updated = null; + protected ?int $_DeathYear = null; protected ?string $_UrlName = null; protected ?string $_Url = null; - protected $_AlternateNames = null; // Don't type hint this here, otherwise PHPStan will complain + /** @var ?array $_AlternateNames */ + protected $_AlternateNames = null; // ******* // SETTERS diff --git a/lib/Artwork.php b/lib/Artwork.php index 1f3a37f0..cd18d966 100644 --- a/lib/Artwork.php +++ b/lib/Artwork.php @@ -1,12 +1,5 @@ $Tags + * @property-read array $Tags + * @property-write array|string $Tags * @property Artist $Artist * @property string $ImageUrl * @property string $ThumbUrl @@ -56,9 +50,11 @@ class Artwork{ public ?string $Notes = null; public ?ImageMimeType $MimeType = null; public ?ArtworkStatus $Status = null; + protected ?string $_UrlName = null; protected ?string $_Url = null; protected ?string $_EditUrl = null; + /** @var ?array $_Tags */ protected $_Tags = null; protected ?Artist $_Artist = null; protected ?string $_ImageUrl = null; diff --git a/lib/ArtworkTag.php b/lib/ArtworkTag.php index cfef1db0..3605f2b9 100644 --- a/lib/ArtworkTag.php +++ b/lib/ArtworkTag.php @@ -1,7 +1,4 @@ Validate(); diff --git a/lib/AtomFeed.php b/lib/AtomFeed.php index 52ba67f6..5e338081 100644 --- a/lib/AtomFeed.php +++ b/lib/AtomFeed.php @@ -12,7 +12,7 @@ class AtomFeed extends Feed{ * @param string $subtitle * @param string $url * @param string $path - * @param array $entries + * @param array $entries */ public function __construct(string $title, string $subtitle, string $url, string $path, array $entries){ parent::__construct($title, $url, $path, $entries); diff --git a/lib/Ebook.php b/lib/Ebook.php index 3adf0b22..e40ff60c 100644 --- a/lib/Ebook.php +++ b/lib/Ebook.php @@ -11,18 +11,6 @@ use function Safe\preg_replace; use function Safe\sprintf; use function Safe\shell_exec; -/** - * @property array $GitCommits - * @property array $EbookTags - * @property array $LocTags - * @property array $Collections - * @property array $Sources - * @property array $Authors - * @property array $Illustrators - * @property array $Translators - * @property array $Contributors - * @property ?array $TocEntries - */ class Ebook{ public string $WwwFilesystemPath; public string $RepoFilesystemPath; @@ -33,9 +21,13 @@ class Ebook{ public string $KepubUrl; public string $Azw3Url; public bool $HasDownloads; + /** @var array $GitCommits */ public $GitCommits = []; + /** @var array $Tags */ public $Tags = []; + /** @var array $LocTags */ public $LocTags = []; + /** @var array $Collections */ public $Collections = []; public string $Identifier; public string $UrlSafeIdentifier; @@ -60,12 +52,17 @@ class Ebook{ public string $ReadingTime; public ?string $GitHubUrl = null; public ?string $WikipediaUrl = null; + /** @var array $Sources */ public $Sources = []; + /** @var array $Authors */ public $Authors = []; public string $AuthorsHtml; public string $AuthorsUrl; // This is a single URL even if there are multiple authors; for example, /ebooks/karl-marx_friedrich-engels/ + /** @var array $Illustrators */ public $Illustrators = []; + /** @var array $Translators */ public $Translators = []; + /** @var array $Contributors */ public $Contributors = []; public ?string $ContributorsHtml = null; public string $TitleWithCreditsHtml = ''; @@ -75,6 +72,7 @@ class Ebook{ public string $TextSinglePageUrl; public ?string $TextSinglePageSizeNumber = null; public ?string $TextSinglePageSizeUnit = null; + /** @var ?array $TocEntries */ public $TocEntries = null; // A list of non-Roman ToC entries ONLY IF the work has the 'se:is-a-collection' metadata element, null otherwise /** diff --git a/lib/Email.php b/lib/Email.php index 01ab1fc1..d06307fa 100644 --- a/lib/Email.php +++ b/lib/Email.php @@ -2,9 +2,6 @@ use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; -/** - * @property array> $Attachments - */ class Email{ public string $To = ''; public string $ToName = ''; @@ -14,6 +11,7 @@ class Email{ public string $Subject = ''; public string $Body = ''; public string $TextBody = ''; + /** @var array> $Attachments */ public $Attachments = []; public ?string $PostmarkStream = null; diff --git a/lib/Exceptions/ArtistNameRequiredException.php b/lib/Exceptions/ArtistNameRequiredException.php index 6b266f44..a018955f 100644 --- a/lib/Exceptions/ArtistNameRequiredException.php +++ b/lib/Exceptions/ArtistNameRequiredException.php @@ -2,5 +2,6 @@ namespace Exceptions; class ArtistNameRequiredException extends AppException{ + /** @var string $message */ protected $message = 'An artist name is required.'; } diff --git a/lib/Exceptions/ArtistNotFoundException.php b/lib/Exceptions/ArtistNotFoundException.php index 67e0a3d8..6b2c76ef 100644 --- a/lib/Exceptions/ArtistNotFoundException.php +++ b/lib/Exceptions/ArtistNotFoundException.php @@ -2,5 +2,6 @@ namespace Exceptions; class ArtistNotFoundException extends AppException{ + /** @var string $message */ protected $message = 'We couldn’t locate that artist.'; } diff --git a/lib/Exceptions/ArtworkAlreadyExistsException.php b/lib/Exceptions/ArtworkAlreadyExistsException.php index e3aca999..c20771d1 100644 --- a/lib/Exceptions/ArtworkAlreadyExistsException.php +++ b/lib/Exceptions/ArtworkAlreadyExistsException.php @@ -2,5 +2,6 @@ namespace Exceptions; class ArtworkAlreadyExistsException extends AppException{ + /** @var string $message */ protected $message = 'An artwork with this name already exists.'; } diff --git a/lib/Exceptions/ArtworkImageDimensionsTooSmallException.php b/lib/Exceptions/ArtworkImageDimensionsTooSmallException.php index a88172d6..a02d23f0 100644 --- a/lib/Exceptions/ArtworkImageDimensionsTooSmallException.php +++ b/lib/Exceptions/ArtworkImageDimensionsTooSmallException.php @@ -2,10 +2,10 @@ namespace Exceptions; class ArtworkImageDimensionsTooSmallException extends AppException{ - protected $message; - // This has to be initialized in a constructor because we use the number_format() function. public function __construct(){ $this->message = 'Image dimensions are too small. The minimum image size is ' . number_format(ARTWORK_IMAGE_MINIMUM_WIDTH) . ' × ' . number_format(ARTWORK_IMAGE_MINIMUM_HEIGHT) . '.'; + + parent::__construct($this->message); } } diff --git a/lib/Exceptions/ArtworkNameRequiredException.php b/lib/Exceptions/ArtworkNameRequiredException.php index d4e83b41..8786620c 100644 --- a/lib/Exceptions/ArtworkNameRequiredException.php +++ b/lib/Exceptions/ArtworkNameRequiredException.php @@ -2,5 +2,6 @@ namespace Exceptions; class ArtworkNameRequiredException extends AppException{ + /** @var string $message */ protected $message = 'An artwork name is required.'; } diff --git a/lib/Exceptions/ArtworkNotFoundException.php b/lib/Exceptions/ArtworkNotFoundException.php index 18aa15e2..119bb384 100644 --- a/lib/Exceptions/ArtworkNotFoundException.php +++ b/lib/Exceptions/ArtworkNotFoundException.php @@ -2,5 +2,6 @@ namespace Exceptions; class ArtworkNotFoundException extends AppException{ + /** @var string $message */ protected $message = 'We couldn’t locate that artwork.'; } diff --git a/lib/Exceptions/DuplicateDatabaseKeyException.php b/lib/Exceptions/DuplicateDatabaseKeyException.php index 6ec98c8b..dfb8c8d1 100644 --- a/lib/Exceptions/DuplicateDatabaseKeyException.php +++ b/lib/Exceptions/DuplicateDatabaseKeyException.php @@ -2,5 +2,6 @@ namespace Exceptions; class DuplicateDatabaseKeyException extends AppException{ + /** @var string $message */ protected $message = 'An attempted row insertion has violated the database unique index.'; } diff --git a/lib/Exceptions/InvalidArtistException.php b/lib/Exceptions/InvalidArtistException.php index 275fb722..1ba383ee 100644 --- a/lib/Exceptions/InvalidArtistException.php +++ b/lib/Exceptions/InvalidArtistException.php @@ -2,5 +2,6 @@ namespace Exceptions; class InvalidArtistException extends ValidationException{ + /** @var string $message */ protected $message = 'Artist is invalid.'; } diff --git a/lib/Exceptions/InvalidArtworkException.php b/lib/Exceptions/InvalidArtworkException.php index 09d9fc05..5bfa923d 100644 --- a/lib/Exceptions/InvalidArtworkException.php +++ b/lib/Exceptions/InvalidArtworkException.php @@ -2,5 +2,6 @@ namespace Exceptions; class InvalidArtworkException extends ValidationException{ + /** @var string $message */ protected $message = 'Artwork is invalid.'; } diff --git a/lib/Exceptions/InvalidArtworkPageUrlException.php b/lib/Exceptions/InvalidArtworkPageUrlException.php index 72ffcb43..312b8a1d 100644 --- a/lib/Exceptions/InvalidArtworkPageUrlException.php +++ b/lib/Exceptions/InvalidArtworkPageUrlException.php @@ -2,5 +2,6 @@ namespace Exceptions; class InvalidArtworkPageUrlException extends InvalidUrlException{ + /** @var string $message */ protected $message = 'Invalid link to page with artwork.'; } diff --git a/lib/Exceptions/InvalidArtworkTagException.php b/lib/Exceptions/InvalidArtworkTagException.php index b24a28c0..9731803e 100644 --- a/lib/Exceptions/InvalidArtworkTagException.php +++ b/lib/Exceptions/InvalidArtworkTagException.php @@ -2,11 +2,14 @@ namespace Exceptions; class InvalidArtworkTagException extends ValidationException{ + /** @var string $message */ protected $message = 'Artwork tag is invalid.'; public function __construct(?string $tagName){ if($tagName !== null && trim($tagName) != ''){ $this->message = 'Artwork tag ' . $tagName . ' is invalid.'; } + + parent::__construct($this->message); } } diff --git a/lib/Exceptions/InvalidArtworkTagNameException.php b/lib/Exceptions/InvalidArtworkTagNameException.php index dba53335..6fae593d 100644 --- a/lib/Exceptions/InvalidArtworkTagNameException.php +++ b/lib/Exceptions/InvalidArtworkTagNameException.php @@ -2,5 +2,6 @@ namespace Exceptions; class InvalidArtworkTagNameException extends AppException{ + /** @var string $message */ protected $message = 'Artwork tags can only contain letters and numbers.'; } diff --git a/lib/Exceptions/InvalidCaptchaException.php b/lib/Exceptions/InvalidCaptchaException.php index 47e23d6a..b1904287 100644 --- a/lib/Exceptions/InvalidCaptchaException.php +++ b/lib/Exceptions/InvalidCaptchaException.php @@ -2,5 +2,6 @@ namespace Exceptions; class InvalidCaptchaException extends AppException{ + /** @var string $message */ protected $message = 'We couldn’t validate your CAPTCHA response.'; } diff --git a/lib/Exceptions/InvalidCompletedYearException.php b/lib/Exceptions/InvalidCompletedYearException.php index 6f4aa744..e8828ebe 100644 --- a/lib/Exceptions/InvalidCompletedYearException.php +++ b/lib/Exceptions/InvalidCompletedYearException.php @@ -2,5 +2,6 @@ namespace Exceptions; class InvalidCompletedYearException extends AppException{ + /** @var string $message */ protected $message = 'Invalid year of completion.'; } diff --git a/lib/Exceptions/InvalidCopyrightPageUrlException.php b/lib/Exceptions/InvalidCopyrightPageUrlException.php index e35fb451..ff5b9f4c 100644 --- a/lib/Exceptions/InvalidCopyrightPageUrlException.php +++ b/lib/Exceptions/InvalidCopyrightPageUrlException.php @@ -2,5 +2,6 @@ namespace Exceptions; class InvalidCopyrightPageUrlException extends InvalidUrlException{ + /** @var string $message */ protected $message = 'Invalid link to page with copyright details.'; } diff --git a/lib/Exceptions/InvalidCredentialsException.php b/lib/Exceptions/InvalidCredentialsException.php index 5b0dcb0f..4fc8801f 100644 --- a/lib/Exceptions/InvalidCredentialsException.php +++ b/lib/Exceptions/InvalidCredentialsException.php @@ -2,5 +2,6 @@ namespace Exceptions; class InvalidCredentialsException extends AppException{ + /** @var string $message */ protected $message = 'Invalid credentials.'; } diff --git a/lib/Exceptions/InvalidDeathYearException.php b/lib/Exceptions/InvalidDeathYearException.php index b5513c68..0b1d119f 100644 --- a/lib/Exceptions/InvalidDeathYearException.php +++ b/lib/Exceptions/InvalidDeathYearException.php @@ -2,5 +2,6 @@ namespace Exceptions; class InvalidDeathYearException extends AppException{ + /** @var string $message */ protected $message = 'Invalid year of death.'; } diff --git a/lib/Exceptions/InvalidEmailException.php b/lib/Exceptions/InvalidEmailException.php index d2af6ef1..4dcfbe55 100644 --- a/lib/Exceptions/InvalidEmailException.php +++ b/lib/Exceptions/InvalidEmailException.php @@ -2,5 +2,6 @@ namespace Exceptions; class InvalidEmailException extends AppException{ + /** @var string $message */ protected $message = 'We couldn’t understand your email address.'; } diff --git a/lib/Exceptions/InvalidImageUploadException.php b/lib/Exceptions/InvalidImageUploadException.php index 19b9fe60..b5f01181 100644 --- a/lib/Exceptions/InvalidImageUploadException.php +++ b/lib/Exceptions/InvalidImageUploadException.php @@ -3,11 +3,6 @@ namespace Exceptions; class InvalidImageUploadException extends AppException{ - public function __construct(?string $message = null){ - if($message === null){ - $message = 'Uploaded image is invalid.'; - } - - parent::__construct($message); - } + /** @var string $message */ + protected $message = 'Uploaded image is invalid.'; } diff --git a/lib/Exceptions/InvalidLoginException.php b/lib/Exceptions/InvalidLoginException.php index cbc758f8..2a3666e8 100644 --- a/lib/Exceptions/InvalidLoginException.php +++ b/lib/Exceptions/InvalidLoginException.php @@ -2,5 +2,6 @@ namespace Exceptions; class InvalidLoginException extends AppException{ + /** @var string $message */ protected $message = 'We couldn’t validate your login information.'; } diff --git a/lib/Exceptions/InvalidMimeTypeException.php b/lib/Exceptions/InvalidMimeTypeException.php index e014e11e..0c7e8d77 100644 --- a/lib/Exceptions/InvalidMimeTypeException.php +++ b/lib/Exceptions/InvalidMimeTypeException.php @@ -3,5 +3,6 @@ namespace Exceptions; class InvalidMimeTypeException extends AppException{ + /** @var string $message */ protected $message = 'Uploaded image must be a JPG, BMP, PNG, or TIFF file.'; } diff --git a/lib/Exceptions/InvalidMuseumUrlException.php b/lib/Exceptions/InvalidMuseumUrlException.php index 4df7c7f0..02c30ece 100644 --- a/lib/Exceptions/InvalidMuseumUrlException.php +++ b/lib/Exceptions/InvalidMuseumUrlException.php @@ -4,5 +4,7 @@ namespace Exceptions; class InvalidMuseumUrlException extends InvalidUrlException{ public function __construct(string $url, string $exampleUrl){ $this->message = 'Invalid museum URL: <' . $url . '>. Expected a URL like: <'. $exampleUrl . '>.'; + + parent::__construct($this->message); } } diff --git a/lib/Exceptions/InvalidNewsletterSubscription.php b/lib/Exceptions/InvalidNewsletterSubscription.php index af2ae23f..d9f81af6 100644 --- a/lib/Exceptions/InvalidNewsletterSubscription.php +++ b/lib/Exceptions/InvalidNewsletterSubscription.php @@ -2,5 +2,6 @@ namespace Exceptions; class InvalidNewsletterSubscription extends ValidationException{ + /** @var string $message */ protected $message = 'Newsletter subscription is invalid.'; } diff --git a/lib/Exceptions/InvalidPageScanUrlException.php b/lib/Exceptions/InvalidPageScanUrlException.php index a7d37f83..a9825d79 100644 --- a/lib/Exceptions/InvalidPageScanUrlException.php +++ b/lib/Exceptions/InvalidPageScanUrlException.php @@ -4,5 +4,7 @@ namespace Exceptions; class InvalidPageScanUrlException extends InvalidUrlException{ public function __construct(string $url, string $exampleUrl){ $this->message = 'Invalid page scan URL: <' . $url . '>. Expected a URL like: <'. $exampleUrl . '>.'; + + parent::__construct($this->message); } } diff --git a/lib/Exceptions/InvalidPermissionsException.php b/lib/Exceptions/InvalidPermissionsException.php index 0e8ae3c1..06630b1f 100644 --- a/lib/Exceptions/InvalidPermissionsException.php +++ b/lib/Exceptions/InvalidPermissionsException.php @@ -2,5 +2,6 @@ namespace Exceptions; class InvalidPermissionsException extends AppException{ + /** @var string $message */ protected $message = 'You don’t have permission to perform that action.'; } diff --git a/lib/Exceptions/InvalidPollVoteException.php b/lib/Exceptions/InvalidPollVoteException.php index 609eb526..eefddab2 100644 --- a/lib/Exceptions/InvalidPollVoteException.php +++ b/lib/Exceptions/InvalidPollVoteException.php @@ -2,5 +2,6 @@ namespace Exceptions; class InvalidPollVoteException extends ValidationException{ + /** @var string $message */ protected $message = 'Vote is invalid.'; } diff --git a/lib/Exceptions/InvalidPublicationYearException.php b/lib/Exceptions/InvalidPublicationYearException.php index 84925d74..52a16c20 100644 --- a/lib/Exceptions/InvalidPublicationYearException.php +++ b/lib/Exceptions/InvalidPublicationYearException.php @@ -2,5 +2,6 @@ namespace Exceptions; class InvalidPublicationYearException extends AppException{ + /** @var string $message */ protected $message = 'Invalid year of publication.'; } diff --git a/lib/Exceptions/InvalidPublicationYearPageUrlException.php b/lib/Exceptions/InvalidPublicationYearPageUrlException.php index 0824e71e..cf869fe6 100644 --- a/lib/Exceptions/InvalidPublicationYearPageUrlException.php +++ b/lib/Exceptions/InvalidPublicationYearPageUrlException.php @@ -2,5 +2,6 @@ namespace Exceptions; class InvalidPublicationYearPageUrlException extends InvalidUrlException{ + /** @var string $message */ protected $message = 'Invalid link to page with year of publication.'; } diff --git a/lib/Exceptions/InvalidRequestException.php b/lib/Exceptions/InvalidRequestException.php index 68d1b6fc..d6880888 100644 --- a/lib/Exceptions/InvalidRequestException.php +++ b/lib/Exceptions/InvalidRequestException.php @@ -2,5 +2,6 @@ namespace Exceptions; class InvalidRequestException extends AppException{ + /** @var string $message */ protected $message = 'Invalid HTTP request.'; } diff --git a/lib/Exceptions/InvalidUrlException.php b/lib/Exceptions/InvalidUrlException.php index 87a27a0d..a44bc49a 100644 --- a/lib/Exceptions/InvalidUrlException.php +++ b/lib/Exceptions/InvalidUrlException.php @@ -2,6 +2,7 @@ namespace Exceptions; class InvalidUrlException extends AppException{ + /** @var string $message */ protected $message = 'Invalid URL.'; public function __construct(?string $url = null){ diff --git a/lib/Exceptions/MissingEbookException.php b/lib/Exceptions/MissingEbookException.php index b232f252..35308c32 100644 --- a/lib/Exceptions/MissingEbookException.php +++ b/lib/Exceptions/MissingEbookException.php @@ -2,5 +2,6 @@ namespace Exceptions; class MissingEbookException extends AppException{ + /** @var string $message */ protected $message = 'Artwork marked as “in use”, but the ebook couldn’t be found in the filesystem.'; } diff --git a/lib/Exceptions/MissingPdProofException.php b/lib/Exceptions/MissingPdProofException.php index bb07196e..71eaf834 100644 --- a/lib/Exceptions/MissingPdProofException.php +++ b/lib/Exceptions/MissingPdProofException.php @@ -2,5 +2,6 @@ namespace Exceptions; class MissingPdProofException extends AppException{ + /** @var string $message */ protected $message = 'Missing proof of U.S. public domain status.'; } diff --git a/lib/Exceptions/MuseumNotFoundException.php b/lib/Exceptions/MuseumNotFoundException.php index 118eecca..f4b2ba8f 100644 --- a/lib/Exceptions/MuseumNotFoundException.php +++ b/lib/Exceptions/MuseumNotFoundException.php @@ -2,5 +2,6 @@ namespace Exceptions; class MuseumNotFoundException extends AppException{ + /** @var string $message */ protected $message = 'We couldn’t locate that museum.'; } diff --git a/lib/Exceptions/NewsletterRequiredException.php b/lib/Exceptions/NewsletterRequiredException.php index 53a00532..2748b36f 100644 --- a/lib/Exceptions/NewsletterRequiredException.php +++ b/lib/Exceptions/NewsletterRequiredException.php @@ -2,5 +2,6 @@ namespace Exceptions; class NewsletterRequiredException extends AppException{ + /** @var string $message */ protected $message = 'You must select at least one newsletter to subscribe to.'; } diff --git a/lib/Exceptions/NewsletterSubscriptionExistsException.php b/lib/Exceptions/NewsletterSubscriptionExistsException.php index edf0274c..733d30b1 100644 --- a/lib/Exceptions/NewsletterSubscriptionExistsException.php +++ b/lib/Exceptions/NewsletterSubscriptionExistsException.php @@ -2,5 +2,6 @@ namespace Exceptions; class NewsletterSubscriptionExistsException extends AppException{ + /** @var string $message */ protected $message = 'You’re already subscribed to the newsletter.'; } diff --git a/lib/Exceptions/NewsletterSubscriptionNotFoundException.php b/lib/Exceptions/NewsletterSubscriptionNotFoundException.php index fde14f8c..f3197e8d 100644 --- a/lib/Exceptions/NewsletterSubscriptionNotFoundException.php +++ b/lib/Exceptions/NewsletterSubscriptionNotFoundException.php @@ -2,5 +2,6 @@ namespace Exceptions; class NewsletterSubscriptionNotFoundException extends AppException{ + /** @var string $message */ protected $message = 'We couldn’t find you in our newsletter subscribers list.'; } diff --git a/lib/Exceptions/PatronNotFoundException.php b/lib/Exceptions/PatronNotFoundException.php index cbc6c606..cecbac02 100644 --- a/lib/Exceptions/PatronNotFoundException.php +++ b/lib/Exceptions/PatronNotFoundException.php @@ -2,5 +2,6 @@ namespace Exceptions; class PatronNotFoundException extends AppException{ + /** @var string $message */ protected $message = 'We couldn’t locate you in the Patrons Circle.'; } diff --git a/lib/Exceptions/PaymentExistsException.php b/lib/Exceptions/PaymentExistsException.php index cb715cb3..4eb9fc76 100644 --- a/lib/Exceptions/PaymentExistsException.php +++ b/lib/Exceptions/PaymentExistsException.php @@ -2,5 +2,6 @@ namespace Exceptions; class PaymentExistsException extends AppException{ + /** @var string $message */ protected $message = 'This transaction ID already exists.'; } diff --git a/lib/Exceptions/PollClosedException.php b/lib/Exceptions/PollClosedException.php index f3a13f98..3d55bb9d 100644 --- a/lib/Exceptions/PollClosedException.php +++ b/lib/Exceptions/PollClosedException.php @@ -2,5 +2,6 @@ namespace Exceptions; class PollClosedException extends AppException{ + /** @var string $message */ protected $message = 'This poll is not open to voting right now.'; } diff --git a/lib/Exceptions/PollItemNotFoundException.php b/lib/Exceptions/PollItemNotFoundException.php index 87e6d722..2ea58ef1 100644 --- a/lib/Exceptions/PollItemNotFoundException.php +++ b/lib/Exceptions/PollItemNotFoundException.php @@ -2,5 +2,6 @@ namespace Exceptions; class PollItemNotFoundException extends AppException{ + /** @var string $message */ protected $message = 'We couldn’t locate that poll item.'; } diff --git a/lib/Exceptions/PollItemRequiredException.php b/lib/Exceptions/PollItemRequiredException.php index a5dbff60..a62a6cf5 100644 --- a/lib/Exceptions/PollItemRequiredException.php +++ b/lib/Exceptions/PollItemRequiredException.php @@ -2,5 +2,6 @@ namespace Exceptions; class PollItemRequiredException extends AppException{ + /** @var string $message */ protected $message = 'You must select an item to vote on.'; } diff --git a/lib/Exceptions/PollNotFoundException.php b/lib/Exceptions/PollNotFoundException.php index 7fc26b44..f50e4bcf 100644 --- a/lib/Exceptions/PollNotFoundException.php +++ b/lib/Exceptions/PollNotFoundException.php @@ -2,5 +2,6 @@ namespace Exceptions; class PollNotFoundException extends AppException{ + /** @var string $message */ protected $message = 'We couldn’t locate that poll.'; } diff --git a/lib/Exceptions/PollVoteExistsException.php b/lib/Exceptions/PollVoteExistsException.php index 7869c5d2..5c213c3f 100644 --- a/lib/Exceptions/PollVoteExistsException.php +++ b/lib/Exceptions/PollVoteExistsException.php @@ -2,7 +2,8 @@ namespace Exceptions; class PollVoteExistsException extends AppException{ - public $Vote = null; + public ?\PollVote $Vote = null; + /** @var string $message */ protected $message = 'You’ve already voted in this poll.'; public function __construct(?\PollVote $vote = null){ diff --git a/lib/Exceptions/PollVoteNotFoundException.php b/lib/Exceptions/PollVoteNotFoundException.php index a5bf261f..a71b3cdf 100644 --- a/lib/Exceptions/PollVoteNotFoundException.php +++ b/lib/Exceptions/PollVoteNotFoundException.php @@ -2,5 +2,6 @@ namespace Exceptions; class PollVoteNotFoundException extends AppException{ + /** @var string $message */ protected $message = 'We couldn’t locate that vote.'; } diff --git a/lib/Exceptions/TagsRequiredException.php b/lib/Exceptions/TagsRequiredException.php index 42db4db1..9c477c9f 100644 --- a/lib/Exceptions/TagsRequiredException.php +++ b/lib/Exceptions/TagsRequiredException.php @@ -2,5 +2,6 @@ namespace Exceptions; class TagsRequiredException extends AppException{ + /** @var string $message */ protected $message = 'At least one tag is required.'; } diff --git a/lib/Exceptions/TooManyTagsException.php b/lib/Exceptions/TooManyTagsException.php index c1561ffc..c7d7424a 100644 --- a/lib/Exceptions/TooManyTagsException.php +++ b/lib/Exceptions/TooManyTagsException.php @@ -2,5 +2,6 @@ namespace Exceptions; class TooManyTagsException extends AppException{ + /** @var string $message */ protected $message = 'Too many tags; the maximum is ' . ARTWORK_MAX_TAGS . '.'; } diff --git a/lib/Exceptions/UserExistsException.php b/lib/Exceptions/UserExistsException.php index ad89f6ef..1b077b2b 100644 --- a/lib/Exceptions/UserExistsException.php +++ b/lib/Exceptions/UserExistsException.php @@ -2,5 +2,6 @@ namespace Exceptions; class UserExistsException extends AppException{ + /** @var string $message */ protected $message = 'This email already exists in the database.'; } diff --git a/lib/Exceptions/UserNotFoundException.php b/lib/Exceptions/UserNotFoundException.php index 8b6c8731..c91b338b 100644 --- a/lib/Exceptions/UserNotFoundException.php +++ b/lib/Exceptions/UserNotFoundException.php @@ -2,5 +2,6 @@ namespace Exceptions; class UserNotFoundException extends AppException{ + /** @var string $message */ protected $message = 'We couldn’t locate that user.'; } diff --git a/lib/Exceptions/ValidationException.php b/lib/Exceptions/ValidationException.php index 2500f108..8321b2aa 100644 --- a/lib/Exceptions/ValidationException.php +++ b/lib/Exceptions/ValidationException.php @@ -1,10 +1,8 @@ $Exceptions - */ class ValidationException extends AppException{ + /** @var array<\Exception> $Exceptions */ public $Exceptions = []; public bool $HasExceptions = false; public bool $IsFatal = false; diff --git a/lib/Exceptions/WebhookException.php b/lib/Exceptions/WebhookException.php index 3ad9f057..ed7ef92d 100644 --- a/lib/Exceptions/WebhookException.php +++ b/lib/Exceptions/WebhookException.php @@ -2,7 +2,7 @@ namespace Exceptions; class WebhookException extends AppException{ - public $PostData; + public ?string $PostData; public function __construct(string $message = '', string $data = null){ $this->PostData = $data; diff --git a/lib/Feed.php b/lib/Feed.php index 063c7633..156e9e7f 100644 --- a/lib/Feed.php +++ b/lib/Feed.php @@ -5,12 +5,10 @@ use function Safe\file_put_contents; use function Safe\tempnam; use function Safe\unlink; -/** - * @param array $Entries - */ class Feed{ public string $Url; public string $Title; + /** @var array $Entries */ public $Entries = []; public string $Path; public ?string $Stylesheet = null; @@ -20,7 +18,7 @@ class Feed{ * @param string $title * @param string $url * @param string $path - * @param array $entries + * @param array $entries */ public function __construct(string $title, string $url, string $path, array $entries){ $this->Url = $url; diff --git a/lib/Image.php b/lib/Image.php index fee13f0c..bf33dd91 100644 --- a/lib/Image.php +++ b/lib/Image.php @@ -1,8 +1,4 @@ $tags - * @param EbookSort $sort * @return array * @throws Exceptions\AppException */ - public static function FilterEbooks(string $query = null, array $tags = [], EbookSort $sort = null){ + public static function FilterEbooks(string $query = null, array $tags = [], EbookSort $sort = null): array{ $ebooks = Library::GetEbooks(); $matches = $ebooks; diff --git a/lib/Museum.php b/lib/Museum.php index 8dbb5902..248022b7 100644 --- a/lib/Museum.php +++ b/lib/Museum.php @@ -1,10 +1,4 @@ $entries + * @param array $entries * @param OpdsNavigationFeed $parent */ public function __construct(string $title, string $subtitle, string $url, string $path, array $entries, ?OpdsNavigationFeed $parent){ diff --git a/lib/OpdsNavigationFeed.php b/lib/OpdsNavigationFeed.php index 894e8417..03aec048 100644 --- a/lib/OpdsNavigationFeed.php +++ b/lib/OpdsNavigationFeed.php @@ -4,12 +4,7 @@ use function Safe\file_get_contents; class OpdsNavigationFeed extends OpdsFeed{ /** - * @param string $title - * @param string $subtitle - * @param string $url - * @param string $path - * @param array $entries - * @param OpdsNavigationFeed $parent + * @param array $entries */ public function __construct(string $title, string $subtitle, string $url, string $path, array $entries, ?OpdsNavigationFeed $parent){ parent::__construct($title, $subtitle, $url, $path, $entries, $parent); @@ -24,6 +19,7 @@ class OpdsNavigationFeed extends OpdsFeed{ $xml = new SimpleXMLElement(str_replace('xmlns=', 'ns=', file_get_contents($this->Path))); foreach($xml->xpath('//entry') ?: [] as $existingEntry){ foreach($this->Entries as $entry){ + /** @var OpdsNavigationEntry $entry */ if($entry->Id == $existingEntry->id){ $entry->Updated = new DateTimeImmutable($existingEntry->updated); } diff --git a/lib/Patron.php b/lib/Patron.php index 81501089..f860798a 100644 --- a/lib/Patron.php +++ b/lib/Patron.php @@ -8,13 +8,13 @@ class Patron{ use Traits\Accessor; public ?int $UserId = null; - protected $_User = null; public bool $IsAnonymous; public ?string $AlternateName = null; public bool $IsSubscribedToEmails; public ?DateTimeImmutable $Created = null; public ?DateTimeImmutable $Ended = null; + protected ?User $_User = null; // ******* // METHODS diff --git a/lib/Payment.php b/lib/Payment.php index e8ac4e81..a1843def 100644 --- a/lib/Payment.php +++ b/lib/Payment.php @@ -1,7 +1,4 @@ $_PollItems - * @property ?array $_PollItemsByWinner * @property string $Url * @property array $PollItems * @property array $PollItemsByWinner @@ -21,7 +19,9 @@ class Poll{ public DateTimeImmutable $Start; public DateTimeImmutable $End; protected ?string $_Url = null; + /** @var ?array $_PollItems */ protected $_PollItems = null; + /** @var ?array $_PollItemsByWinner */ protected $_PollItemsByWinner = null; protected ?int $_VoteCount = null; diff --git a/lib/PollVote.php b/lib/PollVote.php index 2dbf3fe1..300a258d 100644 --- a/lib/PollVote.php +++ b/lib/PollVote.php @@ -1,6 +1,4 @@ $entries */ public function __construct(string $title, string $description, string $url, string $path, array $entries){ @@ -65,6 +58,7 @@ class RssFeed extends Feed{ $currentEntries = []; foreach($this->Entries as $entry){ + /** @var Ebook $entry */ $obj = new StdClass(); $obj->Size = (string)filesize(WEB_ROOT . $entry->EpubUrl); $obj->Id = preg_replace('/^url:/ius', '', $entry->Identifier); diff --git a/lib/Session.php b/lib/Session.php index 981fb604..5bbe9912 100644 --- a/lib/Session.php +++ b/lib/Session.php @@ -15,9 +15,10 @@ class Session{ use Traits\Accessor; public int $UserId; - protected ?User $_User = null; public DateTimeImmutable $Created; public string $SessionId; + + protected ?User $_User = null; public ?string $_Url = null; diff --git a/lib/Template.php b/lib/Template.php index 899dbaa7..2bb58312 100644 --- a/lib/Template.php +++ b/lib/Template.php @@ -4,7 +4,6 @@ use function Safe\ob_start; class Template{ /** - * @param string $templateName * @param array $arguments */ protected static function Get(string $templateName, array $arguments = []): string{ @@ -23,7 +22,6 @@ class Template{ } /** - * @param string $function * @param array $arguments */ public static function __callStatic(string $function, array $arguments): string{ diff --git a/lib/User.php b/lib/User.php index 2c6f21b2..e693849c 100644 --- a/lib/User.php +++ b/lib/User.php @@ -1,16 +1,15 @@ $Payments - * @property ?bool $IsRegistered + * @property bool $IsRegistered * @property Benefits $Benefits - * @property ?array $_Payments */ class User{ + use Traits\Accessor; public int $UserId; @@ -19,7 +18,9 @@ class User{ public DateTimeImmutable $Created; public string $Uuid; public ?string $PasswordHash = null; + protected ?bool $_IsRegistered = null; + /** @var ?array $_Payments */ protected $_Payments = null; protected ?Benefits $_Benefits = null;