Continue improving type hints

This commit is contained in:
Alex Cabal 2024-05-10 22:28:24 -05:00
parent eb376c87bd
commit 703e1a7a03
73 changed files with 98 additions and 114 deletions

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class ArtistNameRequiredException extends AppException{
/** @var string $message */
protected $message = 'An artist name is required.';
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class ArtistNotFoundException extends AppException{
/** @var string $message */
protected $message = 'We couldnt locate that artist.';
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class ArtworkAlreadyExistsException extends AppException{
/** @var string $message */
protected $message = 'An artwork with this name already exists.';
}

View file

@ -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);
}
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class ArtworkNameRequiredException extends AppException{
/** @var string $message */
protected $message = 'An artwork name is required.';
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class ArtworkNotFoundException extends AppException{
/** @var string $message */
protected $message = 'We couldnt locate that artwork.';
}

View file

@ -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.';
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class InvalidArtistException extends ValidationException{
/** @var string $message */
protected $message = 'Artist is invalid.';
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class InvalidArtworkException extends ValidationException{
/** @var string $message */
protected $message = 'Artwork is invalid.';
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class InvalidArtworkPageUrlException extends InvalidUrlException{
/** @var string $message */
protected $message = 'Invalid link to page with artwork.';
}

View file

@ -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);
}
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class InvalidArtworkTagNameException extends AppException{
/** @var string $message */
protected $message = 'Artwork tags can only contain letters and numbers.';
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class InvalidCaptchaException extends AppException{
/** @var string $message */
protected $message = 'We couldnt validate your CAPTCHA response.';
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class InvalidCompletedYearException extends AppException{
/** @var string $message */
protected $message = 'Invalid year of completion.';
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class InvalidCopyrightPageUrlException extends InvalidUrlException{
/** @var string $message */
protected $message = 'Invalid link to page with copyright details.';
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class InvalidCredentialsException extends AppException{
/** @var string $message */
protected $message = 'Invalid credentials.';
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class InvalidDeathYearException extends AppException{
/** @var string $message */
protected $message = 'Invalid year of death.';
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class InvalidEmailException extends AppException{
/** @var string $message */
protected $message = 'We couldnt understand your email address.';
}

View file

@ -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.';
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class InvalidLoginException extends AppException{
/** @var string $message */
protected $message = 'We couldnt validate your login information.';
}

View file

@ -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.';
}

View file

@ -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);
}
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class InvalidNewsletterSubscription extends ValidationException{
/** @var string $message */
protected $message = 'Newsletter subscription is invalid.';
}

View file

@ -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);
}
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class InvalidPermissionsException extends AppException{
/** @var string $message */
protected $message = 'You dont have permission to perform that action.';
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class InvalidPollVoteException extends ValidationException{
/** @var string $message */
protected $message = 'Vote is invalid.';
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class InvalidPublicationYearException extends AppException{
/** @var string $message */
protected $message = 'Invalid year of publication.';
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class InvalidPublicationYearPageUrlException extends InvalidUrlException{
/** @var string $message */
protected $message = 'Invalid link to page with year of publication.';
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class InvalidRequestException extends AppException{
/** @var string $message */
protected $message = 'Invalid HTTP request.';
}

View file

@ -2,6 +2,7 @@
namespace Exceptions;
class InvalidUrlException extends AppException{
/** @var string $message */
protected $message = 'Invalid URL.';
public function __construct(?string $url = null){

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class MissingEbookException extends AppException{
/** @var string $message */
protected $message = 'Artwork marked as “in use”, but the ebook couldnt be found in the filesystem.';
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class MissingPdProofException extends AppException{
/** @var string $message */
protected $message = 'Missing proof of U.S. public domain status.';
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class MuseumNotFoundException extends AppException{
/** @var string $message */
protected $message = 'We couldnt locate that museum.';
}

View file

@ -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.';
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class NewsletterSubscriptionExistsException extends AppException{
/** @var string $message */
protected $message = 'Youre already subscribed to the newsletter.';
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class NewsletterSubscriptionNotFoundException extends AppException{
/** @var string $message */
protected $message = 'We couldnt find you in our newsletter subscribers list.';
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class PatronNotFoundException extends AppException{
/** @var string $message */
protected $message = 'We couldnt locate you in the Patrons Circle.';
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class PaymentExistsException extends AppException{
/** @var string $message */
protected $message = 'This transaction ID already exists.';
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class PollClosedException extends AppException{
/** @var string $message */
protected $message = 'This poll is not open to voting right now.';
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class PollItemNotFoundException extends AppException{
/** @var string $message */
protected $message = 'We couldnt locate that poll item.';
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class PollItemRequiredException extends AppException{
/** @var string $message */
protected $message = 'You must select an item to vote on.';
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class PollNotFoundException extends AppException{
/** @var string $message */
protected $message = 'We couldnt locate that poll.';
}

View file

@ -2,7 +2,8 @@
namespace Exceptions;
class PollVoteExistsException extends AppException{
public $Vote = null;
public ?\PollVote $Vote = null;
/** @var string $message */
protected $message = 'Youve already voted in this poll.';
public function __construct(?\PollVote $vote = null){

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class PollVoteNotFoundException extends AppException{
/** @var string $message */
protected $message = 'We couldnt locate that vote.';
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class TagsRequiredException extends AppException{
/** @var string $message */
protected $message = 'At least one tag is required.';
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class TooManyTagsException extends AppException{
/** @var string $message */
protected $message = 'Too many tags; the maximum is ' . ARTWORK_MAX_TAGS . '.';
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class UserExistsException extends AppException{
/** @var string $message */
protected $message = 'This email already exists in the database.';
}

View file

@ -2,5 +2,6 @@
namespace Exceptions;
class UserNotFoundException extends AppException{
/** @var string $message */
protected $message = 'We couldnt locate that user.';
}

View file

@ -1,10 +1,8 @@
<?
namespace Exceptions;
/**
* @property array<\Exception> $Exceptions
*/
class ValidationException extends AppException{
/** @var array<\Exception> $Exceptions */
public $Exceptions = [];
public bool $HasExceptions = false;
public bool $IsFatal = false;

View file

@ -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;