From 5c6992317616d92b4b88f8c301cec20a1f72c764 Mon Sep 17 00:00:00 2001 From: Mike Colagrosso Date: Thu, 23 May 2024 22:13:45 -0600 Subject: [PATCH] Workaround a bug in Safe-PHP causes PHPStan errors --- lib/Ebook.php | 9 +++++---- lib/Exceptions/InvalidEbookCreatedDatetimeException.php | 4 +--- lib/Exceptions/InvalidEbookUpdatedDatetimeException.php | 4 +--- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/Ebook.php b/lib/Ebook.php index e51028e7..3f45d5ad 100644 --- a/lib/Ebook.php +++ b/lib/Ebook.php @@ -581,11 +581,12 @@ class Ebook{ // ******* /** - * @throws \Exception * @throws \Exceptions\ValidationException */ public function Validate(): void{ + /** @throws void */ $now = new DateTimeImmutable(); + $error = new Exceptions\ValidationException(); if($this->Identifier == ''){ @@ -744,7 +745,7 @@ class Ebook{ } /** - * @throws \Exception + * @throws Exceptions\ValidationException */ public function CreateOrUpdate(): void{ try{ @@ -1103,7 +1104,7 @@ class Ebook{ } /** - * @throws \Exception + * @throws Exceptions\ValidationException */ public function Create(): void{ $this->Validate(); @@ -1157,7 +1158,7 @@ class Ebook{ } /** - * @throws \Exception + * @throws Exceptions\ValidationException */ public function Save(): void{ $this->Validate(); diff --git a/lib/Exceptions/InvalidEbookCreatedDatetimeException.php b/lib/Exceptions/InvalidEbookCreatedDatetimeException.php index 8381b66e..138f2d63 100644 --- a/lib/Exceptions/InvalidEbookCreatedDatetimeException.php +++ b/lib/Exceptions/InvalidEbookCreatedDatetimeException.php @@ -7,10 +7,8 @@ class InvalidEbookCreatedDatetimeException extends AppException{ /** @var string $message */ protected $message = 'Invalid EbookCreated datetime.'; - /** - * @throws \Exception - */ public function __construct(DateTimeImmutable $createdDatetime){ + /** @throws void */ $now = new DateTimeImmutable(); $this->message = 'Invalid EbookCreated datetime. ' . $createdDatetime->format('Y-m-d') . ' is not between ' . EBOOK_EARLIEST_CREATION_DATE->format('Y-m-d') . ' and ' . $now->format('Y-m-d') . '.'; } diff --git a/lib/Exceptions/InvalidEbookUpdatedDatetimeException.php b/lib/Exceptions/InvalidEbookUpdatedDatetimeException.php index d5c42d1f..49d3aa49 100644 --- a/lib/Exceptions/InvalidEbookUpdatedDatetimeException.php +++ b/lib/Exceptions/InvalidEbookUpdatedDatetimeException.php @@ -7,10 +7,8 @@ class InvalidEbookUpdatedDatetimeException extends AppException{ /** @var string $message */ protected $message = 'Invalid EbookUpdated datetime.'; - /** - * @throws \Exception - */ public function __construct(DateTimeImmutable $updatedDatetime){ + /** @throws void */ $now = new DateTimeImmutable(); $this->message = 'Invalid EbookUpdated datetime. ' . $updatedDatetime->format('Y-m-d') . ' is not between ' . EBOOK_EARLIEST_CREATION_DATE->format('Y-m-d') . ' and ' . $now->format('Y-m-d') . '.'; }