From c3c588cc1b39c05e711928e90d98bdcec351169b Mon Sep 17 00:00:00 2001 From: Alex Cabal Date: Fri, 8 Nov 2024 13:50:59 -0600 Subject: [PATCH] Add more type hints and work on some code formatting --- config/phpstan/phpstan.neon | 2 +- lib/OpdsFeed.php | 2 +- lib/RssFeed.php | 3 +- scripts/process-pending-payments | 6 +- templates/ArtworkForm.php | 16 ++-- templates/ArtworkList.php | 4 +- templates/ArtworkStatus.php | 24 ++++-- templates/AtomFeed.php | 9 ++ templates/AtomFeedEntry.php | 32 +++++-- templates/BulkDownloadTable.php | 27 +++--- templates/DonationCounter.php | 2 +- templates/EbookGrid.php | 84 +++++++++---------- templates/EmailAdminNewPatron.php | 7 +- templates/EmailAdminNewPatronText.php | 7 +- templates/EmailDonationIngestion.php | 13 --- templates/EmailDonationIngestionText.php | 7 -- templates/EmailDonationProcessingFailed.php | 6 +- .../EmailDonationProcessingFailedText.php | 5 ++ templates/EmailFooter.php | 30 +++---- templates/EmailHeader.php | 4 +- templates/EmailNewsletterConfirmation.php | 20 ++++- templates/EmailNewsletterConfirmationText.php | 7 ++ templates/EmailPatronsCircleCompleted.php | 6 +- templates/EmailPatronsCircleCompletedText.php | 5 ++ templates/EmailPatronsCircleWelcome.php | 11 ++- templates/EmailPatronsCircleWelcomeText.php | 6 ++ templates/Error.php | 11 ++- templates/FeedHowTo.php | 30 +++++-- templates/Header.php | 1 + templates/OpdsAcquisitionEntry.php | 43 +++++++--- templates/OpdsAcquisitionFeed.php | 30 +++++-- templates/OpdsNavigationFeed.php | 17 +++- templates/RssEntry.php | 12 ++- templates/RssFeed.php | 10 ++- templates/SearchForm.php | 11 ++- 35 files changed, 343 insertions(+), 167 deletions(-) delete mode 100644 templates/EmailDonationIngestion.php delete mode 100644 templates/EmailDonationIngestionText.php diff --git a/config/phpstan/phpstan.neon b/config/phpstan/phpstan.neon index cc68076f..9b24277b 100644 --- a/config/phpstan/phpstan.neon +++ b/config/phpstan/phpstan.neon @@ -24,7 +24,7 @@ parameters: - %rootDir%/../../../templates dynamicConstantNames: - SITE_STATUS - - DONATION_DRIVE_ENABLED + - DONATION_DRIVES_ENABLED - DONATION_DRIVE_COUNTER_ENABLED earlyTerminatingMethodCalls: Template: diff --git a/lib/OpdsFeed.php b/lib/OpdsFeed.php index 169ca83c..66c699f0 100644 --- a/lib/OpdsFeed.php +++ b/lib/OpdsFeed.php @@ -2,7 +2,7 @@ use Safe\DateTimeImmutable; use function Safe\file_put_contents; -class OpdsFeed extends AtomFeed{ +abstract class OpdsFeed extends AtomFeed{ public ?OpdsNavigationFeed $Parent = null; /** diff --git a/lib/RssFeed.php b/lib/RssFeed.php index d4e0e065..5783bab6 100644 --- a/lib/RssFeed.php +++ b/lib/RssFeed.php @@ -22,8 +22,7 @@ class RssFeed extends Feed{ protected function GetXmlString(): string{ if($this->XmlString === null){ - $timestamp = NOW->format('r'); - $feed = Template::RssFeed(['url' => $this->Url, 'description' => $this->Description, 'title' => $this->Title, 'entries' => $this->Entries, 'updated' => $timestamp]); + $feed = Template::RssFeed(['url' => $this->Url, 'description' => $this->Description, 'title' => $this->Title, 'entries' => $this->Entries, 'updated' => NOW]); $this->XmlString = $this->CleanXmlString($feed); } diff --git a/scripts/process-pending-payments b/scripts/process-pending-payments index 8afb8c66..d91e430d 100755 --- a/scripts/process-pending-payments +++ b/scripts/process-pending-payments @@ -82,7 +82,7 @@ try{ ) ', [$pendingPayment->TransactionId])){ $log->Write('Donation already exists in database.'); - continue; + continue 2; // `switch` is considered a "loop" by PHP. } $driver->get('https://fundraising.fracturedatlas.org/admin/donations?query=' . $pendingPayment->TransactionId); @@ -115,7 +115,7 @@ try{ } catch(Exception){ $log->Write('Error: Couldn\'t find donation.'); - continue; + continue 2; // `switch` is considered a "loop" by PHP. } $toggleButton->click(); @@ -185,7 +185,7 @@ try{ catch(Exceptions\PaymentExistsException){ // Payment already exists, just continue. $log->Write('Donation already in database.'); - continue; + continue 2; // `switch` is considered a "loop" by PHP. } // Does this payment create a new Patron in the Patrons Circle? diff --git a/templates/ArtworkForm.php b/templates/ArtworkForm.php index 30ef4168..13e251ec 100644 --- a/templates/ArtworkForm.php +++ b/templates/ArtworkForm.php @@ -1,7 +1,7 @@ - AlternateNames as $alternateName){ ?> - + AlternateNames ?? []) as $alternateName){ ?> + @@ -40,7 +40,7 @@ $isEditForm = $isEditForm ?? false; name="artist-year-of-death" inputmode="numeric" pattern="[0-9]{1,4}" - value="Artist->DeathYear) ?>" + value="Artist->DeathYear) ?>" /> @@ -59,7 +59,7 @@ $isEditForm = $isEditForm ?? false; name="artwork-year" inputmode="numeric" pattern="[0-9]{1,4}" - value="CompletedYear) ?>" + value="CompletedYear) ?>" />